使用matlab在语音信号上实现声门脉冲

时间:2014-04-09 12:57:43

标签: matlab plot signals speech pulse

我得到了声门脉冲的代码,当我试图通过初始化参数来运行时,我得到一个脉冲。但是,当我尝试在信号上实现它时,我无法获得输出。我收到的错误是:

订阅的分配维度不匹配

fs= 11025;
f0= 190;
N1=12;
N2=17;
T=1/f0;     %period in seconds
pulselength=floor(T*fs);    %length of one period of pulse
%select N1 and N2 for duty cycle
N2=floor(pulselength*N2);
N1=floor(N1*N2);
gn=zeros(1,N2);
%calculate pulse samples
for n=1:N1-1
    gn(n)=0.5*(1-cos(pi*(n-1)/N1));
end
for n=N1:N2
    gn(n)=cos(pi*(n-N1)/(N2-N1)/2);
end
gn=[gn zeros(1,(pulselength-N2))];
plot(gn);

请仔细检查代码并帮助我解决问题。

1 个答案:

答案 0 :(得分:1)

我认为您的代码段来自http://www.mattmontag.com/projects/speech/rosenberg.m。 将N1N2设置为0到1之间的值。

从帮助到rosenberg.m

N2 is duty cycle of the pulse, from 0 to 1.
N1 is the duration of the glottal opening as a fraction of the total pulse, from 0 to 1.

Rosenberg pulse with different values for N1 and N2