⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 00001.txt

📁 可用于对信号的频谱进行分析,希望站长能整理好,以便大家互相学习
💻 TXT
字号:
function [ss,po]=specsubm(s,fs,p)
%SPECSUBM performs speech enhancement using spectral subtraction [SS,PO]=(S,FS,P)
%
% implementation of spectral subtraction algorithm by R Martin (rather slow)
% algorithm parameters: t* in seconds, f* in Hz, k* dimensionless
% 1: tg = smoothing time constant for signal power estimate (0.04): high=reverberant, low=musical
% 2: ta = smoothing time constant for signal power estimate
%        used in noise estimation (0.1)
% 3: tw = fft window length (will be rounded up to 2^nw samples)
% 4: tm = length of minimum filter (1.5): high=slow response to noise increase, low=distortion
% 5: to = time constant for oversubtraction factor (0.08)
% 6: fo = oversubtraction corner frequency (800): high=distortion, low=musical
% 7: km = number of minimisation buffers to use (4): high=waste memory, low=noise modulation
% 8: ks = oversampling constant (4)
% 9: kn = noise estimate compensation (1.5)
% 10:kf = subtraction floor (0.02): high=noisy, low=musical
% 11:ko = oversubtraction scale factor (4): high=distortion, low=musical
%
% Refs:
%    (a) R. Martin. Spectral subtraction based on minimum statistics. In Proc EUSIPCO, pages 1182-1185, Edinburgh, Sept 1994.
%    (b) R. Martin. Noise power spectral density estimation based on optimal smoothing and minimum statistics.
%        IEEE Trans. Speech and Audio Processing, 9(5):504-512, July 2001.


%      Copyright (C) Mike Brookes 2004
%      Version: $Id: specsubm.m,v 1.3 2005/02/21 15:22:14 dmb Exp $
%
%   VOICEBOX is a MATLAB toolbox for speech processing.
%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   This program is free software; you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation; either version 2 of the License, or
%   (at your option) any later version.
%
%   This program is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You can obtain a copy of the GNU General Public License from
%   ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0 or by writing to
%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin<3 po=[0.04 0.1 0.032 1.5 0.08 400 4 4 1.5 0.02 4].'; else po=p; end
ns=length(s);
ts=1/fs;
ss=zeros(ns,1);

ni=pow2(nextpow2(fs*po(3)/po(8)));
ti=ni/fs;
nw=ni*po(8);
nf=1+floor((ns-nw)/ni);
nm=ceil(fs*po(4)/(ni*po(7)));

win=0.5*hamming(nw+1)/1.08;win(end)=[];
zg=exp(-ti/po(1));
za=exp(-ti/po(2));
zo=exp(-ti/po(5));

px=zeros(1+nw/2,1);
pxn=px;
os=px;
mb=ones(1+nw/2,po(7))*nw/2;
im=0;
osf=po(11)*(1+(0:nw/2).'*fs/(nw*po(6))).^(-1);

imidx=[13 21]';
x2im=zeros(length(imidx),nf);
osim=x2im;
pnim=x2im;
pxnim=x2im;
qim=x2im;

for is=1:nf
   idx=(1:nw)+(is-1)*ni;
   x=rfft(s(idx).*win);
   x2=x.*conj(x);
   
   pxn=za*pxn+(1-za)*x2;
   im=rem(im+1,nm);
   if im
      mb(:,1)=min(mb(:,1),pxn);
   else
      mb=[pxn,mb(:,1:po(7)-1)];
   end
   pn=po(9)*min(mb,[],2);
   %os= oversubtraction factor
   os=zo*os+(1-zo)*(1+osf.*pn./(pn+pxn));
   
   px=zg*px+(1-zg)*x2;
   q=max(po(10)*sqrt(pn./x2),1-sqrt(os.*pn./px)); 
   ss(idx)=ss(idx)+irfft(x.*q);
   
end
if nargout==0
   soundsc([s; ss],fs);
end

**************************************************88
语音函数下载网站:
   1: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
   2:http://bbs.matwav.com/post/view?bid=93&id=449616&sty=1&tpg=1&age=10
   3:www.matwav.com
   4:http://tcts.fpms.ac.be/~ris/
   
********************************
使用这个函数消噪后的语音,为什么开始部分没有起到什么消噪作用,后面的部分还好?
有没有用过这个函数的?不知道是我使用的不对,还是这个程序的问题,请高手指教~~谢了先!! 

rfft函数:
function y=rfft(x,n,d)
%RFFT FFT of real data Y=(X,N)
% Data is truncated/padded to length N if specified.
% N even:  (N+2)/2 points are returned with
%       the first and last being real
% N odd:  (N+1)/2 points are returned with the
%       first being real
% In all cases fix(1+N/2) points are returned

% Copyright (C) Mike Brookes 1998
% Version: $Id: rfft.m,v 1.3 2005/02/21 15:22:14 dmb Exp $
%
% VOICEBOX is a MATLAB toolbox for speech processing.
% Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You can obtain a copy of the GNU General Public License from
% ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0 or by writing to
% Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

s=size(x);
if prod(s)==1
y=x
else
if nargin <3
d=find(s>1);
d=d(1);
if nargin<2
n=s(d);
end
end
if isempty(n) 
n=s(d);
end
y=fft(x,n,d);
y=reshape(y,prod(s(1:d-1)),n,prod(s(d+1:end))); 
s(d)=1+fix(n/2);
y(:,s(d)+1:end,=[];
y=reshape(y,s);
end 

*******************************8
问答:
——————小弟用谱减发做语音增强,FFT变换时要对信号采样分帧,为减小截断效应,分帧时应该将帧重叠,比如我做 256 点 FFT,半帧重叠,我的问题是:比如我共有 128*3 个采样点,按照我的分帧方法,可以产生两帧信号,做谱减后同样是两帧信号,即产生了 256*2个样点,这好象有问题啊,请问大家分帧处理后怎样恢复到原来样点个数的信号啊? 

——————我也想知道怎么恢复和原始语音相同的采样点数目啊 

——————对信号进行频谱分析时,需要进行帧间叠接以及加合适的窗,为的是通过一段信号估计整个信号的频谱,并且减少矩形窗的影响
在增强处理的整个过程中,从原理到实现,我没有看出非要进行帧间叠接的必要性,因为就没有用到过整个信号的频谱,都是对一帧信号从时域转到频域再进行处理,不知道那位大侠从数学上解释一下叠接后有什么好处 

——————语音信号之所以进行加窗和分帧处理是因为语音信号短时平稳的,这样有助于分析它的特性。采用叠加的处理方法是为了保持帧间连续性,即使帧间平滑过渡,保持语音连续性。如果不进行叠加处理,然后采用谱减法进行语音增强,恢复的语音信号中会出现嘟嘟的声音。
语音经过分帧加窗和谱减处理后,要恢复原来的信号长度,可以用下面程序:
sound=zeros(n,1); %n为语音的长度
for i=1:3 %i为总帧数
for j=1:256 %j为帧长
sound((i-1)*128+j,1)=s(i,j); %s为经过加窗分帧和谱减的语音
end
end 

——————另外在用wavread读入文件后分帧,感觉现有的程序是把一整个文件变换成一个以帧为列向量的矩阵,那么对与要求实时处理的接受机来说,就需要用到一个缓冲器,来一帧处理一帧,请问这个具体用matlab实现要注意哪些问题? 

——在matlab命令窗口输入[y,fs,nbits]=wavread('Alice.wav',[1 5000]);save y
然后用Wavelet里的一维连续小波分析工具的load Signal选项load以上我保存为mat格式的y,但是提示错误(说是不包含一维信号),这是怎么回事??
我想用图形界面下的一维连续小波分析工具分析下这个名字为Alice的wav文件的1到5000的数据,应该怎么办啊? 

——qq: 23886519
建立的一个语音处理的群。
欢迎加入。 

——————《MATLAB扩展编程》网址:http://sshtm.ssreader.com/html/pages/showbook.asp?ssid=10844613

—————————我的图书馆:http://mylib.duxiu.com/   ——》holyi  code:635241

——————语音信号处理共享资源汇总贴:http://bbs.matwav.com/post/view?bid=93&id=188655&sty=1&tpg=1&age=0


























⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -