You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not getting back the expected audio length in the target sample rate but I do w/ resampy (sinc_window). When I provide a 44_100 source sampled signal, I do get back the expected. When I provide a 48_000 source sampled signal, pedalboard is one sample shy. Any idea why this may be? It is an issue in the code because function expects to get back the expected # of samples under the target sample rate. Here's a snip to reproduce it:
importioimportnumpyasnpimportsoundfileassffrompedalboardimportResamplefrompedalboard.ioimportAudioFile, StreamResampler# equals target_sampless_sr=44_100# does not equal target_samples!# s_sr = 48_000t_sr=22_050dur=5source_samples=s_sr*dur# source_samples / s_sr = 5.0 in this case so np.round or np.floor doesn't mattertarget_samples=int(np.floor((source_samples/s_sr) *t_sr))
noise=np.random.rand(source_samples).astype(np.float32)
audio_filelike=io.BytesIO()
withsf.SoundFile(
audio_filelike,
"w",
channels=1,
samplerate=s_sr,
format="WAV",
subtype="PCM_16",
) asf:
f.write(noise)
audio_filelike.seek(0)
audio=np.copy(sf.SoundFile(audio_filelike, "r").read(dtype="float32"))
resampler=StreamResampler(
source_sample_rate=s_sr,
target_sample_rate=t_sr,
num_channels=1,
quality=Resample.Quality.WindowedSinc
)
resampled=np.concatenate([resampler.process(audio), resampler.process(None)], axis=1).squeeze()
print(resampled.shape, target_samples)
The text was updated successfully, but these errors were encountered:
I am not getting back the expected audio length in the target sample rate but I do w/ resampy (sinc_window). When I provide a 44_100 source sampled signal, I do get back the expected. When I provide a 48_000 source sampled signal, pedalboard is one sample shy. Any idea why this may be? It is an issue in the code because function expects to get back the expected # of samples under the target sample rate. Here's a snip to reproduce it:
The text was updated successfully, but these errors were encountered: