一、ffmpeg
pip install python-ffmpeg
簡單代碼:
import ffmpeg
ffmpeg.input('input.mp3').output('output.mp3', ar=16000).run()
二、librosa庫
import librosa
# to install librosa package
# > conda install -c conda-forge librosa
filename = 'ClapSound.wav'
newFilename = 'ClapSound_8k.wav'
y, sr = librosa.load(filename, sr=48000)
y_8k = librosa.resample(y,sr,8000)
librosa.output.write_wav(newFilename, y_8k, 8000)
參考:
https://blog.csdn.net/u010070526/article/details/85218613
https://www.v2ex.com/t/561239
https://www.cnblogs.com/xingshansi/p/6799994.html