I have to downsample a wav file from 44100Hz to 16000Hz without using any external Python libraries, so preferably wave and/or audioop. I tried jus
I tried using Librosa but for some reasons even after giving the line y, s = librosa.load('test.wav', sr=16000) and librosa.output.write_wav(filename, y, sr), the sound files are not getting saved with the given sample rate(16000, downsampled from 44kHz).
But pydub works well. An awesome library by jiaaro, I used the following commands:
from pydub import AudioSegment as am
sound = am.from_file(filepath, format='wav', frame_rate=22050)
sound = sound.set_frame_rate(16000)
sound.export(filepath, format='wav')
The above code states that the file that I reading with a frame_rate of 22050 is changed to rate of 16000 and export function overwrites the existing files with this file with a new frame_rate. It works better than librosa but I am looking ways to compare the speed between two packages but haven't yet figured it out since I have very less data !!!
Refernce: https://github.com/jiaaro/pydub/issues/232