
Music_source = MusicSource'
N = 256% window length,N = 100 -- 1000
Hamm = hamming(N)% create Hamming window
frame = input('请键入渣肆早想要处理的帧位置如雀 = ')
% origin is current frame
origin = Music_source(((frame - 1) * (N / 2) + 1):((frame - 1) * (N / 2) + N))
Frame = origin .* Hamm'
%
%Short Time Fourier Transform
%
[s1,f1,t1] = specgram(MusicSource,N,N/2,N)
[Xs1,Ys1] = size(s1)
for i = 1:Xs1
FTframe1(i) = s1(i,frame)
end
N1 = input('请键入预测器阶数 = ')% N1 is predictor's order
[coef,gain] = lpc(Frame,N1)% LPC analysis using Levinson-Durbin recursion
est_Frame = filter([0 -coef(2:end)],1,Frame)% estimate frame(LP)
FFT_est = fft(est_Frame)
err = Frame - est_Frame% error
% FFT_err = fft(err)
subplot(2,1,1),plot(1:N,Frame,1:N,est_Frame,'-r')gridtitle('原始语音帧vs.预测后语音帧')
subplot(2,1,2),plot(err)gridtitle('误差')
pause
%subplot(2,1,2),plot(f',20*log(abs(FTframe2)))gridtitle('短时谱')
%
% Gain solution using G^2 = Rn(0) - sum(ai*Rn(i)),i = 1,2,...,P
%
fLength(1 : 2 * N) = [origin,zeros(1,N)]
Xm = fft(fLength,2 * N)
X = Xm .* conj(Xm)
Y = fft(X , 2 * N)
Rk = Y(1 : N)
PART = sum(coef(2 : N1 + 1) .* Rk(1 : N1))
G = sqrt(sum(Frame.^2) - PART)
A = (FTframe1 - FFT_est(1 : length(f1'))) ./ FTframe1 % inverse filter A(Z)
subplot(2,1,1),plot(f1',20*log(abs(FTframe1)),f1'雹哪,(20*log(abs(1 ./ A))),'-r')gridtitle('短时谱')
subplot(2,1,2),plot(f1',(20*log(abs(G ./ A))))gridtitle('LPC谱')
pause
%plot(abs(ifft(FTframe1 ./ (G ./ A))))gridtitle('excited')
%plot(f1',20*log(abs(FFT_est(1 : length(f1')) .* A / G )))grid
%pause
%
% find_pitch
%
temp = FTframe1 - FFT_est(1 : length(f1'))
% not move higher frequnce
pitch1 = log(abs(temp))
pLength = length(pitch1)
result1 = ifft(pitch1,N)
% move higher frequnce
pitch1((pLength - 32) : pLength) = 0
result2 = ifft(pitch1,N)
% direct do real cepstrum with err
pitch = fftshift(rceps(err))
origin_pitch = fftshift(rceps(Frame))
subplot(211),plot(origin_pitch)gridtitle('原始语音帧倒谱(直接调用函数)')
subplot(212),plot(pitch)gridtitle('预测误差倒谱(直接调用函数)')
pause
%subplot(211),plot(1:length(result1),fftshift(real(result1)))gridtitle('预测误差倒谱(根据定义编写,没有去除高频分量)')
%subplot(212),plot(1:length(result2),fftshift(real(result2)))gridtitle('预测误差倒谱(根据定义编写,去除高频分量)')
coef
你好,matlab里面以关键字 function 返回值=函数名(输入);这样形式的都是被调用函数。就好比c里面让胡稿的函数,别的程序做清可以直接调用它。
就拿你这里来说,需要另外一个程序。你可以这样写:
clear all
clc
a=wavread('E:\GMM文献\失真下说话人识别研究文献\abc.wav')%这是读入一个wav文件的语句
b=mfcccoef(a)%这样就可以求得mfcc参数了
%%不过你这程序里坦孝面包含很多的调用程序,比如那个enframe推荐你看一下《MATLAB扩展编程》这本书。
利用函数melcepst.m可以没则得到直接计算语音信号s的MFCC参数:c = melcepst(s, fs。这一命令默认地以256点为枯洞棚帧长计算12阶MFCC参数,如果s比较长,将会按照128点的间颤派隔将s分为若干帧,再分别计算。即s为你定义的信号,不是长度,fs可以取8000。欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)