bmcfee / pyrubberband

python wrapper for rubberband
ISC License
154 stars 20 forks source link

Error: Please verify that rubberband-cli is installed #18

Closed srajan-jha closed 4 years ago

srajan-jha commented 5 years ago

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 !

bmcfee commented 5 years ago

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

That should have worked -- are you sure that it installed properly? Does it work from the command-line when you use it?

Alternately, did you try the brew-based installation described in the project readme? https://github.com/bmcfee/pyrubberband

srajan-jha commented 5 years ago

@bmcfee No, there was some issue installing that on my OS as well, also the brew version mentioned, works only on the OS X if I'm not wrong. Do you have any other leads instead of that?

bmcfee commented 5 years ago

(Sorry, I misread your initial post and thought you were on OSX.)

No, there was some issue installing that on my OS as well

I'd need more detail to know what's going on, but if you can't get the rubberband CLI installed, pyrubberband is not going to work.

srajan-jha commented 4 years ago

There was some issue regarding installation of rubberband in windows OS and hence i couldn't work with pyrubberband. Also, there were no exact installation instructions of rubberband anywhere around the web.

Anyway, thanks for your help, I am now using sox and pysox for audio related manipulations.

franPul commented 4 years ago

I am trying to run pyrubberband on Win10. I installed the rubberband CLI, tried it and works, When I am trying to use pyrubberband I always get, RuntimeError: Failed to execute rubberband. Please verify that rubberband-cli is installed.

How can I link my rubberband CLI to pyrubberband? Thanks

bmcfee commented 4 years ago

@franPul That's strange -- can you provide a full traceback of the error? I suspect that the cli is installed, but not in your executable path, so it's probably just a matter of setting an environment variable.

qo4on commented 4 years ago

I also have the same error on Windows 10. I unzipped this, added the folder to path and sucessfully ran it from command line:

C:\Users\asd>rubberband

Rubber Band
An audio time-stretching and pitch-shifting library and utility program.
Copyright 2007-2018 Particular Programs Ltd.

   Usage: rubberband [options] <infile.wav> <outfile.wav>

You must specify at least one of the following time and pitch ratio options.

  -t<X>, --time <X>       Stretch to X times original duration, or
  -T<X>, --tempo <X>      Change tempo by multiple X (same as --time 1/X), or
  -T<X>, --tempo <X>:<Y>  Change tempo from X to Y (same as --time X/Y), or
  -D<X>, --duration <X>   Stretch or squash to make output file X seconds long

  -p<X>, --pitch <X>      Raise pitch by X semitones, or
  -f<X>, --frequency <X>  Change frequency by multiple X

  -M<F>, --timemap <F>    Use file F as the source for key frame map

A map file consists of a series of lines each having two numbers separated
by a single space.  These are source and target sample frame numbers for fixed
time points within the audio data, defining a varying stretch factor through
the audio.  You must specify an overall stretch factor using e.g. -t as well.

The following options provide a simple way to adjust the sound.  See below
for more details.

  -c<N>, --crisp <N>      Crispness (N = 0,1,2,3,4,5,6); default 5 (see below)
  -F,    --formant        Enable formant preservation when pitch shifting

The remaining options fine-tune the processing mode and stretch algorithm.
These are mostly included for test purposes; the default settings and standard
crispness parameter are intended to provide the best sounding set of options
for most situations.  The default is to use none of these options.

  -L,    --loose          Relax timing in hope of better transient preservation
  -P,    --precise        Ignored: The opposite of -L, this is default from 1.6
  -R,    --realtime       Select realtime mode (implies --no-threads)
         --no-threads     No extra threads regardless of CPU and channel count
         --threads        Assume multi-CPU even if only one CPU is identified
         --no-transients  Disable phase resynchronisation at transients
         --bl-transients  Band-limit phase resync to extreme frequencies
         --no-lamination  Disable phase lamination
         --window-long    Use longer processing window (actual size may vary)
         --window-short   Use shorter processing window
         --smoothing      Apply window presum and time-domain smoothing
         --detector-perc  Use percussive transient detector (as in pre-1.5)
         --detector-soft  Use soft transient detector
         --pitch-hq       In RT mode, use a slower, higher quality pitch shift
         --centre-focus   Preserve focus of centre material in stereo
                          (at a cost in width and individual channel quality)

  -d<N>, --debug <N>      Select debug level (N = 0,1,2,3); default 0, full 3
                          (N.B. debug level 3 includes audible ticks in output)
  -q,    --quiet          Suppress progress output

  -V,    --version        Show version number and exit
  -h,    --help           Show this help

"Crispness" levels:
  -c 0   equivalent to --no-transients --no-lamination --window-long
  -c 1   equivalent to --detector-soft --no-lamination --window-long (for piano)
  -c 2   equivalent to --no-transients --no-lamination
  -c 3   equivalent to --no-transients
  -c 4   equivalent to --bl-transients
  -c 5   default processing options
  -c 6   equivalent to --no-lamination --window-short (may be good for drums)
C:\Users\asd>rubberband "C:\0.wav" -p 2 "C:\out.wav"
Using crispness level: 5 (Crisp monophonic instrumental)
Using time ratio 1 and frequency ratio 1.12246
Pass 1: Studying...
Calculating profile...
Pass 2: Processing...

in: 158558, out: 158558, ratio: 1, ideal output: 158558, error: 0
elapsed time: 0.156 sec, in frames/sec: 1.0164e+06, out frames/sec: 1.0164e+06

Then I ran your code:

import soundfile as sf
import pyrubberband as pyrb
y, sr = sf.read(r"C:\0.wav")
y_shift = pyrb.pitch_shift(y, sr, 2)
print(y_shift)

and got the error in line y_shift = pyrb.pitch_shift(y, sr, 2):

Traceback (most recent call last):
  File "C:\Users\asd\miniconda3\lib\site-packages\pyrubberband\pyrb.py", line 74, in __rubberband
    subprocess.check_call(arguments, stdout=DEVNULL, stderr=DEVNULL)
  File "C:\Users\asd\miniconda3\lib\subprocess.py", line 358, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Users\asd\miniconda3\lib\subprocess.py", line 339, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\asd\miniconda3\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:\Users\asd\miniconda3\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\asd\Desktop\!!!!!\test.py", line 48, in <module>
    y_shift = pyrb.pitch_shift(y, sr, 2)
  File "C:\Users\asd\miniconda3\lib\site-packages\pyrubberband\pyrb.py", line 257, in pitch_shift
    return __rubberband(y, sr, **rbargs)
  File "C:\Users\asd\miniconda3\lib\site-packages\pyrubberband\pyrb.py", line 87, in __rubberband
    exc)
  File "<string>", line 3, in raise_from
RuntimeError: Failed to execute rubberband. Please verify that rubberband-cli is installed.
qo4on commented 4 years ago

Suddenly, it started to work after restart.

Do you know what is the best settings for shifting pitch +0.5 for a female voice?

marathomas commented 4 years ago

I have the same issue. I'm working on google colab. Maybe someone has run into the same issue and knows how to fix it?

Install (seems to work fine) with: !pip install pyrubberband==0.3.0

Collecting pyrubberband==0.3.0 Downloading https://files.pythonhosted.org/packages/66/03/079d3adead19dc0af62a02c7850318055aa2dec9453c92886219b642b904/pyrubberband-0.3.0.tar.gz Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from pyrubberband==0.3.0) (1.12.0) Collecting pysoundfile>=0.8.0 Downloading https://files.pythonhosted.org/packages/2a/b3/0b871e5fd31b9a8e54b4ee359384e705a1ca1e2870706d2f081dc7cc1693/PySoundFile-0.9.0.post1-py2.py3-none-any.whl Requirement already satisfied: cffi>=0.6 in /usr/local/lib/python3.6/dist-packages (from pysoundfile>=0.8.0->pyrubberband==0.3.0) (1.14.0) Requirement already satisfied: pycparser in /usr/local/lib/python3.6/dist-packages (from cffi>=0.6->pysoundfile>=0.8.0->pyrubberband==0.3.0) (2.20) Building wheels for collected packages: pyrubberband Building wheel for pyrubberband (setup.py) ... done Created wheel for pyrubberband: filename=pyrubberband-0.3.0-cp36-none-any.whl size=4283 sha256=2097d6c70cba3e2aa9895016ff43d39363be94b4e51e118b6c07207f3df958b6 Stored in directory: /root/.cache/pip/wheels/aa/b3/2e/e1f66716b0d9b1e18136227ee204682100d837e72c5ea57b1d Successfully built pyrubberband Installing collected packages: pysoundfile, pyrubberband Successfully installed pyrubberband-0.3.0 pysoundfile-0.9.0.post1

Then running a pyrubberband function fails: import soundfile as sf import pyrubberband as pyrb y = spec_df.loc[100,'spectrograms'] sr = spec_df.loc[100,'samplerate_hz'] y_stretch = pyrb.time_stretch(y, sr, 2.0)

FileNotFoundError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/pyrubberband/pyrb.py in rubberband(y, sr, kwargs) 73 ---> 74 subprocess.check_call(arguments, stdout=DEVNULL, stderr=DEVNULL) 75 7 frames /usr/lib/python3.6/subprocess.py in check_call(*popenargs, *kwargs) 305 """ --> 306 retcode = call(popenargs, kwargs) 307 if retcode: /usr/lib/python3.6/subprocess.py in call(timeout, *popenargs, *kwargs) 286 """ --> 287 with Popen(popenargs, **kwargs) as p: 288 try: /usr/lib/python3.6/subprocess.py in init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors) 728 errread, errwrite, --> 729 restore_signals, start_new_session) 730 except: /usr/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) 1363 err_msg += ': ' + repr(err_filename) -> 1364 raise child_exception_type(errno_num, err_msg, err_filename) 1365 raise child_exception_type(err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'rubberband': 'rubberband' The above exception was the direct cause of the following exception: RuntimeError Traceback (most recent call last)

in () 6 sr = spec_df.loc[100,'samplerate_hz'] 7 #Play back at double speed ----> 8 y_stretch = pyrb.time_stretch(y, sr, 2.0) /usr/local/lib/python3.6/dist-packages/pyrubberband/pyrb.py in time_stretch(y, sr, rate, rbargs) 140 rbargs.setdefault('--tempo', rate) 141 --> 142 return __rubberband(y, sr, **rbargs) 143 144 /usr/local/lib/python3.6/dist-packages/pyrubberband/pyrb.py in __rubberband(y, sr, **kwargs) 85 'Please verify that rubberband-cli ' 86 'is installed.'), ---> 87 exc) 88 89 finally: /usr/local/lib/python3.6/dist-packages/six.py in raise_from(value, from_value) RuntimeError: Failed to execute rubberband. Please verify that rubberband-cli is installed.

To fix the problem, I tried installing rubberband-cli with !pip install rubberband-cli

but it resulted in this error:

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

afey89 commented 3 years ago

I had the same problems on windows. What I did to solve: 1 Download rubberband library ( folder containing rubberband.exe and libsndfile-1.dll 2 Go to Windows System Environment and Add the folder to Path 3 Create System Variable with Variable name "rubberband" and path to the rubberband.exe 4 Make sure all your relevant users can access the path and the rubberband variable (for me, I had to set it up for the admin account and my local user account). This can be checked by opening cmd and typing "rubberband". If the command works, the library is recognized.

  1. Restart the Program in which you want to access the library (e.g. restart Visual Studio)
Archanciel commented 2 years ago

Thank you, afey89, your solution worked for me. Here's the link pointing to the zip containing rubberband.exe and sndfile.dll: https://breakfastquay.com/files/releases/rubberband-1.9.2-gpl-executable-windows.zip.

Superklez commented 2 years ago

If you're using Google Colaboratory, do this. It worked for for me.

taliasa commented 2 years ago

re all your relevant users can access the path an

It didn't work for me for some reson though I did all the listed steps

arashhmt90 commented 1 year ago

How To Install "rubberband-cli" Package on Ubuntu: sudo apt-get update -y sudo apt-get install -y rubberband-cli

SatyaDewangan05 commented 3 months ago

How To Install "rubberband-cli" Package on Ubuntu: sudo apt-get update -y sudo apt-get install -y rubberband-cli

Then I'm getting this error


  File "/home/satya/satya-space/personal_projects/voice-speeding/speeder.py", line 31, in <module>
    transition_start = pyrb.time_stretch(combined_audio[:transition_duration].get_array_of_samples(), combined_audio[:transition_duration].frame_rate, end_speed - start_speed)
  File "/home/satya/.local/lib/python3.10/site-packages/pyrubberband/pyrb.py", line 142, in time_stretch
    return __rubberband(y, sr, **rbargs)
  File "/home/satya/.local/lib/python3.10/site-packages/pyrubberband/pyrb.py", line 80, in __rubberband
    if y.ndim == 1:
AttributeError: 'array.array' object has no attribute 'ndim'```
bmcfee commented 3 months ago

It looks like your input buffer is not a numpy ndarray.

SatyaDewangan05 commented 3 months ago

It looks like your input buffer is not a numpy ndarray.

yes, fixed that issue and problem solved