用 pesq 给 soundfile 读取的录音数据打分

该代码示例展示了如何利用Python的soundfile和pesq库对音频文件进行读取和质量评估。它计算了不同噪声水平下音频文件相对于原始清洁音频的PESQ(PerceptualEvaluationofSpeechQuality)分数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

音频文件来源 NOIZEUS: Noisy speech corpus - Univ. Texas-Dallas

很多python库都能计算pesq分数,如pypesq跟pesq两个库,这里讲的的是pesq的库

import soundfile as sf
from pesq import pesq

# 读取音频文件
audio_clean, src = sf.read('./audio/NOIZEUS/clean/sp01.wav')
audio_0dB, sr0 = sf.read('./audio/NOIZEUS/bable/0dB/sp01_babble_sn0.wav')
audio_5dB, sr5 = sf.read('./audio/NOIZEUS/bable/5dB/sp01_babble_sn5.wav')
audio_10dB, sr10 = sf.read('./audio/NOIZEUS/bable/10dB/sp01_babble_sn10.wav')
audio_15dB, sr15 = sf.read('./audio/NOIZEUS/bable/15dB/sp01_babble_sn15.wav')

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')

输出结果如下 

# MOS-PESQ The project is a tool that can get MOS(PESQ) score for the voice. PESQ measure: ------------- Usage of the PESQ objective measure is as follows: [pesq_mos]=pesq(cleanfile.wav,enhanced.wav) where 'cleanfile.wav' contains the clean speech file and 'enhanced.wav' contains the enhanced file. Example: To run the PESQ objective measure with the example files provided, type in MATLAB: >> pesq('sp09.wav','enhanced_logmmse.wav') ans = 2.2557 Source code for the PESQ implementation is available from a CD-ROM included in the following book: Loizou, P. (2007) "Speech enhancement: Theory and Practice", CRC Press. COMPOSITE MEASURE: ----------------- Usage: [Csig,Cbak,Covl]=composite(cleanfile.wav,enhanced.wav) where 'Csig' is the predicted rating of speech distortion 'Cbak' is the predicted rating of background distortion 'Covl' is the predicted rating of overall quality. You may run example files included in the zip file. In MATLAB, type: >> [c,b,o]=composite('sp09.wav','enhanced_logmmse.wav') LLR=0.681368 SNRseg=3.991727 WSS=49.671978 PESQ=2.255732 c = 3.3050 b = 2.6160 o = 2.7133 where 'sp09.wav' is the clean file and 'enhanced_logmmse.wav' is the enhanced file. The predicted ratings for overall quality was 2.7133, for background was 2.61 and for signal distortion it was 3.3050. Operating steps: ----------------- >> ./matlab-PESQ/readme.txt Thank: ----------------- Any questions, please E_mail: [email protected]/[email protected] 操作步骤 1.将所录序列加载如当前工作路径,也可以按自己工作路径自行加载; 2.在read.m中修改参考序列,默认为ref.wav,16KHz采样; 3.利用wavdivide.m对所录多组序列文件进行拆分(支持多种采样频率),并按序保证至当前路径; 4.运行tongji.m计算PESQ_MOS得分并通过excel/txt输出至指定路径; NOTE: 对于步骤4,每次执行记得修改excel中输出列位置,如cellnames2=['B',num2str(k+1),':B',num2str(k+1)];, 指定写入B列,下次执行改为C列,以此类推; 其中ref_8k.wav为8KHz采样测试序列,ref.wav为16KHz,ref_3s.wav只是为方便测试在ref.wav语音前加3s静音;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值