用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')
输出结果如下:
文章来源:https://www.toymoban.com/news/detail-572058.html
文章来源地址https://www.toymoban.com/news/detail-572058.html
到了这里,关于用 pesq 给 torchaudio 读取的音频数据打分的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!