语音信号处理实验报告集锦
- 格式:doc
- 大小:257.50 KB
- 文档页数:12
语音信号处理实验报告集锦
【实验一】
一、实验题目
Short time analysis(短时间分析)
二、实验要求
Write a MA TLAB program to analyze a speech and simultaneously, on a single page, plot the following measurements:
1. the entire speech waveform
2. the short-time energy, En
3. the short-time magnitude, Mn
4. the short-time zero-crossing, Zn
5. the narrowband spectrogram
6. the wideband spectrogram
Use both the speech waveforms in the wznjdx_normal.wav. Choose appropriate window sizes, window shifts, and window for the analysis. Explain your choice of these parameters.
写一个程序来分析语音的同时,在一个单页,情节如下措施:
1。
整个语音波形
2。
短时间能量
3。
短时幅度,锰
4。
短时过零,锌
5。
窄带语谱图
6。
宽带语谱图
在wznjdx_normal.wav使用语音波形。
选择合适的窗口大小,窗口移动和窗口进行分析。
解释你对这些参数的选择。
三、实验程序
clear
[x,fs]=wavread('wznjdx_normal.wav');
n=length(x);
N=320;
subplot(4,1,1);plot(x);
h=linspace(1,1,N);
En=conv(h,x.*x);
subplot(4,1,2);plot(En);
Mn=conv(h,abs(x));
subplot(4,1,3);plot(Mn);
for i=1:n-1
if x(i)>=0 y(i)=1;
else y(i)=-1;
end
if x(i+1)>=0 y(i+1)=1;
else y(i+1)=-1;
end
w(i)=abs(y(i+1)-y(i));
end
k=1;
j=0;
while (k+N-1)<n
Zm(k)=0;
for i=0:N-1
Zm(k)=Zm(k)+w(k+i);
end
j=j+1;
k=k+N/2;
end
for w=1:j
Q(w)=Zm(160*(w-1)+1)/(2*N);
end
subplot(4,1,4);plot(Q);grid;
figure(2);
subplot(2,1,1);spectrogram(x,h,256,200,0.0424*fs); subplot(2,1,2);spectrogram(x,h,256,200,0.0064*fs);
四、实验结果
语谱图:(Matlab 7.0 用不了spectrogram)
【实验二】
一、实验题目
Homomorphic analysis同态分析
二、实验要求
Write a MATLAB program to compute the real cepstrums of a section of voiced speech and unvoiced speech.
Plot the signal, the log magnitude spectrum, the real cepstrum, and the lowpass liftered log magnitude spectrum.
写一个程序来计算实际倒谱一段浊音和清音。
小区的信号,对数幅度谱,真正的倒谱,和低通liftered对数幅度谱。
三、实验程序
nfft=256;
[x,fs] = wavread('wznjdx_normal.wav');
fx=x;
Xvm=log(abs(fft(fx,nfft)));
xhv=real(ifft(Xvm,nfft));
lifter=zeros(1,nfft);
lifter(1:30)=1;
lifter(nfft-28:nfft)=1;
fnlen=0.02*fs; % 20ms
win=hamming(fnlen);%加窗
n=fnlen;%窗宽度赋给循环自变量n noverlap=0.5*fnlen;
while(n<=length(x)-1)
fx=x(n-fnlen+1:n).*win;
n=n+noverlap;
end
xhvp=xhv.*lifter';
figure;
subplot(4,1,1)
plot(lifter);
title('倒谱滤波器');
subplot(4,1,2)
plot(x);
title('语音信号波形');
subplot(4,1,3)
plot(Xvm);
title('Xvm');
subplot(4,1,4)
plot(xhv);
title('xhv');
四、实验结果
【实验三】
一、实验题目
LP analysis线性分析
二、实验要求
Write a MATLAB program to convert from a frame of speech to a set of linear prediction coefficients. Plot the LPC spectrum superimposed on the corresponding STFT.
写一个程序将从语音到一组线性预测系数的框架。
情节的LPC谱叠加在相应的变换。
三、实验程序
clear;
[x,fs]=wavread('wznjdx_normal.wav');
fx=x(4000:4160-1);
p=10;
[a,e,k]=aryule(fx,p);
G=sqrt(e*length(fx));
f=log(abs(fft(fx)));
h0=zeros(1,160);
h=log(G)-log(abs(fft(a,160)));
figure(1);
subplot(211);plot(fx);
subplot(212);plot(f);
hold on;
plot((0:160-1),h,'r');
四、实验结果
【实验四】
一、实验题目
Pitch estimation
二、实验内容
Write a program to implement the pitch estimation and the voiced/unvoiced decision using the LPC-based method.
三、实验程序
clear
[x,fs]=wavread('wznjdx_normal.wav');
n=length(x);
Q = x';
NFFT=512;
N = 256;
Hamm = hamming(N);
frame = 30;
M = Q(((frame -1) * (N / 2) + 1):((frame - 1) * (N / 2) + N)); Frame = M .* Hamm';
% lowpass filter
[b2,a2]=butter(2,900/4000);
speech2=filter(b2,a2,Frame); % filter
% residual
[a,e] = lpc(speech2,20);
errorlp=filter(a,1,speech2); % residual
% Short-term autocorrelation.
re = xcorr(errorlp);
% Find max autocorrelation for lags in the interval minlag to maxlag. minlag = 17; % F0: 450Hz
maxlag =160; % F0: 50Hz
fnlen=256;
[remax,idx] = max(re(fnlen+minlag:fnlen+maxlag));
figure
subplot(3,1,1);plot(Frame);
subplot(3,1,2);plot(speech2);
subplot(3,1,3);plot(re);text(500,0,'idx');
idx=idx-1+minlag
remax
四、实验结果
【实验五】
一、实验题目
Speech synthesis语音合成
二、实验内容
Write a program to analyze a speech and synthesize it using the LPC-based method. 写一个程序来分析语音和综合使用LPC法。
三、实验程序
主程序
clear;
[x,sr] = wavread('wznjdx_normal.wav');
p=[1 -0.9];
x=filter(p,1,x);
N=256;
inc=128;
y=lpcsyn(x,N,inc);
wavplay(y,sr);
子程序lpcsyn
function y=lpcsyn(x,N,inc)
%[x,sr] = wavread('wznjdx_normal.wav');
%pre = [1 -0.97];
%x = filter(pre,1,x);
%N=256;
%inc=128;
fn=floor(length(x)/inc);
y=zeros(1,50000);
for (i=1:fn)
order=16;
x(1:N,i)=x((i-1)*inc+1:(i+1)*inc);
[A(i,:),G(i),P(i),fnlen,fnshift] = lpcana(x(1:N,i),order);
if (P(i)) % V oiced frame.
e = zeros(N,1);
e(1:P(i):N) = 1; % Impulse-train excitation.
else % Unvoiced frame.
e = randn(N,1); % White noise excitation. end
yt=filter(G(i),A(i,:),e);
j=(i-1)*inc+[1:N];
y(j) = y(j)+yt';
end;
end
子程序lpcana
function [A,G,P,fnlen,fnshift] = lpcana(x,order)
fnlen=256;
fnshift=fnlen/2;
n=length(x);
[b2,a2]=butter(2,900/4000);
speech2=filter(b2,a2,x);
[A,e]=lpc(speech2,order);
errorlp=filter(A,1,speech2);
re=xcorr(errorlp);
G=sqrt(e*length(speech2));
minlag=17;
maxlag=160;
[remax,idx]=max(re(n+minlag:n+maxlag));
P=idx-1+minlag;
end
四、实验结果
【实验六】
一、实验题目
Speech enhancement语音增强
二、实验内容
Write a program to implement the basic spectral magnitude subtraction. 编写一个程序,实现基本的谱幅度减法。
三、实验程序
clear
[speech,fs,nbits]=wavread('wznjdx_normal.wav');%读入数据
alpha=0.04;%噪声水平
winsize=256;%窗长
size=length(speech);%语音长度
numofwin=floor(size/winsize);%帧数
hamwin=zeros(1,size);%定义汉明窗长度
enhanced=zeros(1,size);%定义增强语音的长度
ham=hamming(winsize)';%%产生汉明窗
x=speech'+alpha*randn(1,size);%信号加噪声
noisy=alpha*randn(1,winsize);%噪声估计
N=fft(noisy);
nmag=abs(N);%噪声功率谱
%分帧
for q=1:2*numofwin-1
frame=x(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2);%对带噪语音帧间重叠一半取值hamwin(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)=...
hamwin(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)+ham;%加窗y=fft(frame.*ham);
mag=abs(y);%带噪语音功率谱
phase=angle(y);%带噪语音相位
%幅度谱减
for i=1:winsize
if mag(i)-nmag(i)>0
clean(i)=mag(i)-nmag(i);
else clean(i)=0;
end
end
%频域中重新合成语音
spectral=clean.*exp(j*phase);
%反傅里叶变换并重叠相加
enhanced(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)=...
enhanced(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)+real(ifft(spectral));
end
figure(1);
subplot(3,1,1);plot(speech);xlabel('样点数');ylabel('幅度');title('原始语音波形');
subplot(3,1,2);plot(x);xlabel('样点数');ylabel('幅度');title('语音加噪波形');
subplot(3,1,3);plot(enhanced);xlabel('样点数');ylabel('幅度');title('增强语音波形');
四、实验结果。