梅尔倒谱系数 matlab,melcepst-noted.m 源代码在线查看 - 计算Mel倒谱系数的matlab程序: MELCEPST Calculate the mel cepstrum of ...

该博客介绍了MATLAB中用于计算信号梅尔倒谱系数(MELCEPST)的函数。函数接受多个参数,如采样率、 cepstral系数数量、滤波器数量等,并提供了不同类型的窗口和滤波器形状选项。它还支持包括log能量、一阶和二阶导数 cepstral系数的计算。博客提到了代码的一些已知问题,并提供了VOICEBOX,这是一个用于语音处理的MATLAB工具箱的链接。
摘要由CSDN通过智能技术生成

function c=melcepst(s,fs,w,nc,p,n,inc,fl,fh)%MELCEPST Calculate the mel cepstrum of a signal C=(S,FS,W,NC,P,N,INC,FL,FH)%%% Simple use: c=melcepst(s,fs)% calculate mel cepstrum with 12 coefs, 256 sample frames% c=melcepst(s,fs,'e0dD') % include log energy, 0th cepstral coef, delta and delta-delta coefs%% Inputs:% s speech signal% fs sample rate in Hz (default 11025)% nc number of cepstral coefficients excluding 0'th coefficient (default 12)% n length of frame (default power of 2 % p number of filters in filterbank (default floor(3*log(fs)) )% inc frame increment (default n/2)% fl low end of the lowest filter as a fraction of fs (default = 0)% fh high end of highest filter as a fraction of fs (default = 0.5)%%w any sensible combination of the following:%%'R' rectangular window in time domain%'N'Hanning window in time domain%'M'Hamming window in time domain (default)%% 't' triangular shaped filters in mel domain (default)% 'n' hanning shaped filters in mel domain% 'm' hamming shaped filters in mel domain%%'p'filters act in the power domain%'a'filters act in the absolute magnitude domain (default)%% '0' include 0'th order cepstral coefficient%'e' include log energy%'d'include delta coefficients (dc/dt)%'D'include delta-delta coefficients (d^2c/dt^2)%% 'z' highest and lowest filters taper down to zero (default)% 'y' lowest filter remains at 1 down to 0 frequency and% highest filter remains at 1 up to nyquist freqency%% If 'ty' or 'ny' is specified, the total power in the fft is preserved.%% Outputs:c mel cepstrum output: one frame per row. Log energy, if requested, is the% first element of each row followed by the delta and then the delta-delta% coefficients.%% BUGS: (1) should have power limit as 1e-16 rather than 1e-6 (or possibly a better way of choosing this)% and put into VOICEBOX% (2) get rdct to change the data length (properly) instead of doing it explicitly (wrongly)% Copyright (C) Mike Brookes 1997% Version: $Id: melcepst.m,v 1.6 2007/05/04 07:01:39 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% http://www.gnu.org/copyleft/gpl.html or by writing to% Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if narginif narginif narginif narginif narginif nargin fh=0.5; if nargin fl=0; if nargin inc=floor(n/2); end endendif length(w)==0 w='M';endif any(w=='R') z=enframe(s,n,inc);elseif any (w=='N') z=enframe(s,hanning(n),inc);else z=enframe(s,hamming(n),inc);endf=rfft(z.');[m,a,b]=melbankm(p,n,fs,fl,fh,w);pw=f(a:b,:).*conj(f(a:b,:));pth=max(pw(:))*1E-20;if any(w=='p') y=log(max(m*pw,pth));else ath=sqrt(pth); y=log(max(m*abs(f(a:b,:)),ath));endc=rdct(y).';nf=size(c,1);nc=nc+1;if p>nc c(:,nc+1:end)=[];elseif p c=[c zeros(nf,nc-p)];endif ~any(w=='0') c(:,1)=[]; nc=nc-1;endif any(w=='e') c=[log(sum(pw)).' c]; nc=nc+1;end% calculate derivativeif any(w=='D') vf=(4:-1:-4)/60; af=(1:-1:-1)/2; ww=ones(5,1); cx=[c(ww,:); c; c(nf*ww,:)]; vx=reshape(filter(vf,1,cx(:)),nf+10,nc); vx(1:8,:)=[]; ax=reshape(filter(af,1,vx(:)),nf+2,nc); ax(1:2,:)=[]; vx([1 nf+2],:)=[]; if any(w=='d') c=[c vx ax]; else c=[c ax]; endelseif any(w=='d') vf=(4:-1:-4)/60; ww=ones(4,1); cx=[c(ww,:); c; c(nf*ww,:)]; vx=reshape(filter(vf,1,cx(:)),nf+8,nc); vx(1:8,:)=[]; c=[c vx];end if nargout [nf,nc]=size(c); t=((0:nf-1)*inc+(n-1)/2)/fs; ci=(1:nc)-any(w=='0')-any(w=='e'); imh = imagesc(t,ci,c.'); axis('xy'); xlabel('Time (s)'); ylabel('Mel-cepstrum coefficient');map = (0:63)'/63;colormap([map map map]);colorbar;end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值