复倒频谱 - 基频估计
此示例说明如何使用复倒频谱估计说话者的基频。此示例同时使用过零方法估计基频,并比较两种方法所得的结果。
加载语音信号。录音内容是女声朗读的 "MATLAB"。采样频率为 7418 Hz。以下代码将语音波形 mtlb
和采样频率 Fs
加载到 MATLAB® 工作区中。
load mtlb
使用频谱图识别一个浊音段进行分析。
segmentlen = 100;
noverlap = 90;
NFFT = 128;
spectrogram(mtlb,segmentlen,noverlap,NFFT,Fs,'yaxis')
提取从 0.1 到 0.25 秒的段进行分析。提取的段大致对应于 "MATLAB" 中的第一个元音 /ae/。
dt = 1/Fs; I0 = round(0.1/dt); Iend = round(0.25/dt); x = mtlb(I0:Iend);
获得复倒频谱。
c = cceps(x);
选择 2 到 10 ms 的时间范围,对应的频率范围大约为 100 到 500 Hz。确定所选范围内倒频谱的最高峰值。找到对应于该峰值的频率。使用该峰值作为基频的估计值。
t = 0:dt:length(x)*dt-dt;
trng = t(t>=2e-3 & t<=10e-3);
crng = c(t>=2e-3 & t<=10e-3);
[~,I] = max(crng);
fprintf('Complex cepstrum F0 estimate is %3.2f Hz.\n',1/trng(I))
Complex cepstrum F0 estimate is 239.29 Hz.
绘制选定时间范围内的倒频谱,并叠加绘制峰值。
plot(trng*1e3,crng) xlabel('ms') hold on plot(trng(I)*1e3,crng(I),'o') hold off
对经过低通滤波和形式调整的元音使用 zerocrossrate
函数来估计基频。
[b0,a0] = butter(2,325/(Fs/2));
xin = abs(x);
xin = filter(b0,a0,xin);
xin = xin-mean(xin);
zc = zerocrossrate(xin);
F0 = 0.5*Fs*zc;
fprintf('Zero-crossing F0 estimate is %3.2f Hz.\n',F0)
Zero-crossing F0 estimate is 234.94 Hz.