加载音频,查看长度和采样率
import librosa audio_data = 'data/Data_MGTV/angry/audio_1027.wav' x , sr = librosa.load(audio_data) print(x.shape, sr)
把某一文件夹下的所有音频,按照采样率16000读取,并重新存储到另一文件夹下(即批量修改采样率)
import librosa import soundfile # 10000条音频,文件名为00001 - 10000 # 输入一个自然数,返回该形式的文件名 def get_6_name(ind): res = str(ind) while len(res) < 6: res = "0"+res return res if __name__ == '__main__': for i in range(1, 10001): audio_path = "baker_waves-22050/"+get_6_name(i)+".wav" y, sr = librosa.load(audio_path, sr=16000) soundfile.write("baker_waves/"+get_6_name(i)+".wav", y, 16000) if i % 500 == 0: print(i, "waves finished!")
参考:
python librosa 或 ffmpeg 改变音频采样率
https://blog.csdn.net/weixin_44493841/article/details/121287033
【Python】librosa音频处理教程https://blog.csdn.net/fengdu78/article/details/124875505
标签:__,name,Python,res,音频,处理,librosa,audio From: https://www.cnblogs.com/zhaoke271828/p/17007046.html