I am trying to generate a wav file with G. 711 alaw companding from a mp3 file using Pydub library. The wav file is getting generated but it is not resampled to frequency 8 kHz. I have tried following code:
from_path = '/home/nikhil/Music/m1.mp3' #this is a mp3 file
to_path = '/home/nikhil/Music/m1.wav' #resulted file
from_format = 'mp3'
to_format = 'wav'
params = ["-acodec", "pcm_alaw", "-ar", "8000"]
AudioSegment.from_file(from_path, from_format).export(to_path, format=to_format, parameters=params)
Can someone help me?
Changing
to
resolves the problem in the replay