用torchaudio读取的音频文件,在输入pesq之前需要进行格式处理与转换。
import torchaudio
from pesq import pesq
# 读取音频文件
audio_clean, src = torchaudio.load('./audio/NOIZEUS/clean/sp01.wav')
audio_0dB, sr0 = torchaudio.load('./audio/NOIZEUS/bable/0dB/sp01_babble_sn0.wav')
audio_5dB, sr5 = torchaudio.load('./audio/NOIZEUS/bable/5dB/sp01_babble_sn5.wav')
audio_10dB, sr10 = torchaudio.load('./audio/NOIZEUS/bable/10dB/sp01_babble_sn10.wav')
audio_15dB, sr15 = torchaudio.load('./audio/NOIZEUS/bable/15dB/sp01_babble_sn15.wav')
audio_clean = audio_clean.squeeze(0).numpy()
audio_0dB = audio_0dB.squeeze(0).numpy()
audio_5dB = audio_5dB.squeeze(0).numpy()
audio_10dB = audio_10dB.squeeze(0).numpy()
audio_15dB = audio_15dB.squeeze(0).numpy()
score_c_c = pesq(fs = src, ref = audio_clean, deg = audio_clean, mode = 'nb')
score_c_15 = pesq(fs = src, ref = audio_clean, deg = audio_15dB, mode = 'nb')
score_c_10 = pesq(fs = src, ref = audio_clean, deg = audio_10dB, mode = 'nb')
score_c_5 = pesq(fs = src, ref = audio_clean, deg = audio_5dB, mode = 'nb')
score_c_0 = pesq(fs = src, ref = audio_clean, deg = audio_0dB, mode = 'nb')
score_0_0 = pesq(fs = src, ref = audio_0dB, deg = audio_0dB, mode = 'nb')
输出结果如下:
版权声明:本文为ljl86400原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。