Code Monkey home page Code Monkey logo

pyrubberband's People

Contributors

abbioro avatar bmcfee avatar faroit avatar nwh avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pyrubberband's Issues

[Not a Bug] How to time_stretch without changing the pitch?

I followed this example that I found on Medium but it doesn't seem to work. When the playbackRate is increased, how can I correct the pitch so that it is the same as the original audio?

Screen Shot 2021-09-21 at 7 55 27 PM

I have also tried the following by passing the output of time_stretch to the input of pitch_shift

# Play back at 1.5X speed
y_stretch = pyrb.time_stretch(audioData, sampleRate, audioSpeed)
# Play back two 1.5x tones
y_shift = pyrb.pitch_shift(y_stretch, sampleRate, audioSpeed)
soundfile.write(f'{tmp_name}.wav', y_shift, sampleRate, format='wav')

Report runtime failures transparently

We currently route all output to DEVNULL, but this isn't helpful when things break.

Instead, we should route to a logging file descriptor, and return the log when a runtime exception occurs.

Error: Please verify that rubberband-cli is installed

Description

I am new to this project and have been searching for time-stretching and pitch-shifting functionalities in python when I found this so, to test its working, I ran the "Example Usage" code from the pyrubberband github with one of my file but I got this error (image below).

1

2

I tried finding the solution to this on web, but had no leads as of now.

Versions

Windows-10-10.0.17134-SP0
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
NumPy 1.16.4
SoundFile 0.9.0

Moreover

I think the problem is with the OS (I'm using windows, but found OS X codes around the web), and by the way I also tried pip install rubberband-cli in the prompt, cuz the error said "rubberband-cli not installed" but that generated another error :-

Collecting rubberband-cli
ERROR: Could not find a version that satisfies the requirement rubberband-cli (from versions: none)
ERROR: No matching distribution found for rubberband-cli

Later, I downloaded rubberband cli from here and tried installing that as well but that too didn't help.

So finally I am here, hoping to get some positive response from the community. Thanks !

Low sample rate signal hang with rubberband

I've noticed that when you try to use rubberband on very low-samplerate signals (anything 210Hz and below) rubberband will hang.

These both hang:

y = np.random.rand(1024)

shifted = pyrubberband.pitch_shift(y=y, sr=210, n_steps=2)
stretched = pyrubberband.time_stretch(y=y, sr=210, rate=0.5)

These both work

y = np.random.rand(1024)

shifted = pyrubberband.pitch_shift(y=y, sr=211, n_steps=2)
stretched = pyrubberband.time_stretch(y=y, sr=211, rate=0.5)

The rubberband CLI has the same behavior; it hangs during the first studying pass at 99% CPU until you send it a break:

$ rubberband -d3 -t 2.0 /tmp/tmpzGl2Zt.wav /tmp/tmpzGl2Zt_2.wav
Using crispness level: 5 (Crisp monophonic instrumental)
Using time ratio 2 and frequency ratio 1
RubberBandStretcher::Impl::Impl: rate = 125, options = 16
configure: effective ratio = 2
configure: analysis window size = 8, synthesis window size = 8, fft size = 8, increment = 0 (approx output increment = 0)
configure: outbuf size = 8192
Window area: 0.5; synthesis window area: 0.5
FFT::FFT(8): using implementation: fftw
Not real time mode: prefilling
configure: effective ratio = 2
configure: analysis window size = 8, synthesis window size = 8, fft size = 8, increment = 0 (approx output increment = 0)
configure: outbuf size = 8192
Not real time mode: prefilling
configure: effective ratio = 2
configure: analysis window size = 8, synthesis window size = 8, fft size = 8, increment = 0 (approx output increment = 0)
configure: outbuf size = 8192
Pass 1: Studying...

Interestingly, this only seems to be an issue when rate for time_stretch < 1 or when n_steps for pitch_shift > 0, otherwise it runs fine.

I haven't had time to dig into the rubberband source and likely will not any time soon but I've noticed that passing the --window-long flag will allow it to run to completion. IE these both run fine:

y = np.random.rand(1024)

shifted = pyrubberband.pitch_shift(y=y, sr=210, n_steps=2, rbargs={"-q":"--window-long"})
stretched = pyrubberband.time_stretch(y=y, sr=210, rate=0.5, rbargs={"-q":"--window-long"})

It's hacky, but would it make sense to simply add a conditional that would add the --window-long flag to any sr <= 210?

Suppress console spam

There's a lot of spam on the output whenever rubberband executes. We should stop this.

Can't pass flags (rbargs) with keyword but no value

Description

Some flags in rubberband are not followed by a value, e.g. --no-lamination or --pitch-hq. The current implementation always expects rbargs as pairs of keyword and argument (in dict format), making it impossible to use flags that don't take values.

Steps/Code to Reproduce

import pyrubberband

# Generate a random signal and time-stretch it
sr = 22050
y = np.random.randn(5 * sr)

y_stretch = pyrubberband.time_stretch(y, sr, rate=1.5, rbargs={"-c": "6"})  # works
y_stretch = pyrubberband.time_stretch(y, sr, rate=1.5, rbargs={"--pitch-hq": ""})  # fails
y_stretch = pyrubberband.time_stretch(y, sr, rate=1.5, rbargs={"--pitch-hq": " "})  # fails
y_stretch = pyrubberband.time_stretch(y, sr, rate=1.5, rbargs={"--pitch-hq": None})  # fails

Expected Results

Should be possible to call no-value flags such as --pitch-hq. Included some examples above of syntax that could be supported with dicts (e.g. None). Alternative dict could be replaced with e.g. tuple that can have either 1 or 2 elements.

Actual Results

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
<ipython-input-45-8758af91c0ad> in <module>
      5 filename = '/Users/salamon/dev/scaper/tests/data/audio/foreground/human_voice/42-Human-Vocal-Voice-all-aboard_edit.wav'
      6 audio, sr = soundfile.read(filename)
----> 7 audio_pitch = pyrubberband.pitch_shift(audio, sr, 1, rbargs=params)
      8 Audio(data=audio_pitch.T, rate=sr)

~/dev/miniconda3/envs/scaper35/lib/python3.5/site-packages/pyrubberband/pyrb.py in pitch_shift(y, sr, n_steps, rbargs)
    255     rbargs.setdefault('--pitch', n_steps)
    256 
--> 257     return __rubberband(y, sr, **rbargs)

~/dev/miniconda3/envs/scaper35/lib/python3.5/site-packages/pyrubberband/pyrb.py in __rubberband(y, sr, **kwargs)
     72         arguments.extend([infile, outfile])
     73 
---> 74         subprocess.check_call(arguments, stdout=DEVNULL, stderr=DEVNULL)
     75 
     76         # Load the processed audio.

~/dev/miniconda3/envs/scaper35/lib/python3.5/subprocess.py in check_call(*popenargs, **kwargs)
    269         if cmd is None:
    270             cmd = popenargs[0]
--> 271         raise CalledProcessError(retcode, cmd)
    272     return 0
    273 

CalledProcessError: Command '['rubberband', '-q', '-c', '6', '--pitch-hq', ' ', '--pitch', '1', '/var/folders/j4/2cgkdym179b76zljmlm1d6yc0000gn/T/tmpu311s4a2.wav', '/var/folders/j4/2cgkdym179b76zljmlm1d6yc0000gn/T/tmpermm7whf.wav']' returned non-zero exit status 2

Versions

Darwin-18.2.0-x86_64-i386-64bit
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:30:03)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
NumPy 1.18.2
SoundFile 0.9.0

Speed Problem

Description

Steps/Code to Reproduce

Expected Results

Actual Results

Versions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.