Open Jun711 opened 2 years ago
In general, I wouldn't advise following code examples from medium posts.
Your example calls both time-stretch and pitch-shift. If you only want time stretching, then only call time-stretch.
@bmcfee
I want to change the playbackRate of the audio without changing the pitch. I am trying to achieve what html5 audio.playbackRate does. When I use time_stretch
alone, it seems to introduce some noise. is that expected?
When I use
time_stretch
alone, it seems to introduce some noise. is that expected?
I'm not sure how to answer that without more detail: "some noise" could mean a lot of things.
Time stretching is not a perfect process, and there will always be artifacts, but what kind of artifacts you see will depend on the properties of your signal. The default parameters might not be optimal for your particular use case, but you might be able to improve things by playing around with them. See https://breakfastquay.com/rubberband/documentation.html
pyrubberband is just a wrapper for the rubberband library, so you can pass through any parameters you like when calling time_stretch.
@bmcfee
y_stretch = pyrb.time_stretch(audioData, sampleRate, audioSpeed)
soundfile.write(f'{tmp_name}.wav', y_stretch, sampleRate, format='wav')
wavAudio = AudioSegment.from_wav(f'{tmp_name}.wav')
wavAudio.export(f'{tmp_name}.mp3', format="mp3")
This is how it looks like when you drag and drop the html file onto a Chrome browser
regarding the documentation, which rubberband's function is time_stretch mapped to? I need some help with using the documentation
I just installed rubberband and ran rubberband -h
. If I want to turn on this smoothing option, is this the right way to pass it in?
y_stretch = pyrb.time_stretch(audioData, sampleRate, audioSpeed, {'--smoothing': True})
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.
--smoothing Apply window presum and time-domain smoothing
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?
I have also tried the following by passing the output of time_stretch to the input of pitch_shift