15

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)

Daniel Möller
  • 84,878
  • 18
  • 192
  • 214

2 Answers2

34

You can use:

sound = AudioSegment.from_file(…)
sound = sound.set_frame_rate(16000)
Jiaaro
  • 74,485
  • 42
  • 169
  • 190
1

Or you can do this instead also:

import librosa

y, sr = librosa.load(path, sr=16000)

and use it further as per your requirement.

Bao Huynh Lam
  • 974
  • 4
  • 12