Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
justinsalamon opened this issue May 1, 2020 · 1 comment
Open

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

justinsalamon opened this issue May 1, 2020 · 1 comment

Comments

@justinsalamon
Copy link

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

@justinsalamon justinsalamon changed the title Can't provide pass flags (rbargs) with keyword but no value Can't pass flags (rbargs) with keyword but no value May 1, 2020
adityatb added a commit to adityatb/pyrubberband that referenced this issue Feb 12, 2021
@eyaler
Copy link

eyaler commented Oct 22, 2021

in the mean time you can just pass e.g. rbargs={'--realtime': '--realtime'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants