Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pydub - How to change frame rate without changing playback speed

I have a couple audio files that I open in Pydub with AudioSegment.

I want to decrease the audio quality from frame rate 22050 to 16000 Hz. (One channel files)

If I simply change the frame rate of AudioSegment, what I get is the exact same wave played in slower speed. Well, fair enough.

But how do I actually change the waves to fit a lower quality, same speed playback?

(Manual interpolation is the only thing I can think of, but I don't want to get into that trouble)

like image 681
Daniel Möller Avatar asked May 17 '17 21:05

Daniel Möller


1 Answers

You can use:

sound = AudioSegment.from_file(…)
sound = sound.set_frame_rate(16000)
like image 145
Jiaaro Avatar answered Oct 20 '22 02:10

Jiaaro