Use pyrb.time_stretch(y, sr, ratio, rbargs=None) to change the playback speed of an audio signal without changing its pitch.
y: The audio signal (numpy array).sr: The sampling rate.ratio: The stretch factor (e.g., 2.0 for double speed).rbargs: A dictionary of command-line arguments supported by the Rubberband CLI. Keys are the flags (e.g., '-c') and values are the argument values (e.g., '5'). For flags without values, use an empty string ''.
import soundfile as sf
import pyrubberband as pyrb
# Read mono wav file
y, sr = sf.read("test.wav")
# Play back at double speed
y_stretch = pyrb.time_stretch(y, sr, 2.0)
# Use custom Rubberband CLI arguments
y_stretch = pyrb.time_stretch(y, sr, 2.0, rbargs={'-c':'5', '--no_transients':''})