【共振峰跟踪】通过平均不同分辨率的方法跟踪共振峰,基于时频lpc的频谱图的MATLAB仿真
生活随笔
收集整理的這篇文章主要介紹了
【共振峰跟踪】通过平均不同分辨率的方法跟踪共振峰,基于时频lpc的频谱图的MATLAB仿真
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.軟件版本
MATLAB2021a
2.本算法理論知識
? ? ? ? 通過平均不同分辨率的方法跟蹤共振峰,基于時頻lpc的頻譜圖。此外,它還決定了語音信號的基音輪廓。
3.核心代碼
function [fmap,pt2] = ftrack(y,fs)bDisplay = 1;Fsamps = 256; % sampling resolution in frequency dimension Tsamps = round(length(y)/18000*256); % sampling resolution in time dimensiontmp_img1 = zeros(Fsamps,Tsamps); ct = 0;numiter = 8; % number of iterations to run. seemed like a good numberfor i=2.^(8-8*exp(-linspace(1.5,10,numiter)/1.4)), % Determine the time-frequency distribution at the current fix(length(y)/round(i))round(i)[tmp_img1,ft1,pt1] = lpcsgram(y,fix(length(y)/round(i)),round(i),fs);% Get the dimensions of the output time-frequency image[M,N] = size(tmp_img1);% Create a grid of the final resolution[xi,yi] = meshgrid(linspace(1,N,Tsamps),linspace(1,M,Fsamps));% Interpolate returned TF image to final resolutiontmp_img2 = interp2(tmp_img1,xi,yi);ct = ct+1;% Interpolate formant tracks and pitch trackspt2(:,ct) = interp1([1:length(pt1)]',pt1(:),linspace(1,length(pt1),Tsamps)');ft2(:,:,ct) = interp1(linspace(1,length(y),fix(length(y)/round(i)))',Fsamps*ft1',linspace(1,length(y),Tsamps)')';% Normalizetmp_img3(:,:,ct) = tmp_img2/max(tmp_img2(:));if bDisplay,subplot(221);imagesc(tmp_img1);axis xy;subplot(222);imagesc(tmp_img2);axis xy;subplot(223);imagesc(squeeze(mean(tmp_img3,3)));axis xy;drawnow;end; end% Determine mean tfr image and formant track tmp_img4 = squeeze(mean(tmp_img3,3)); % tfr ft3 = squeeze(nanmean(permute(ft2,[3 2 1]))); % if bDisplay,subplot(224);imagesc(tmp_img4);axis xy;hold on;plot(ft3,'y'); end;% convert fmnts to image tmap = repmat([1:Tsamps]',1,3); idx = find(~isnan(sum(ft3,2))); fmap = ft3(idx,:); tmap = tmap(idx,:);% filter formant tracks to remove noise [b,a] = butter(9,0.1); fmap = round(filtfilt(b,a,fmap));pt3 = nanmean(pt2'); pt3 = (pt3-nanmin(pt3))/(nanmax(pt3)-nanmin(pt3));% Rescaling is done after display code if bDisplay,imap = zeros(Fsamps,Tsamps);ind = sub2ind(size(imap),fmap(:),tmap(:));imap(ind) = 1;tpts = tmap(:,1);figure;subplot(221);imagesc(imap);axis xy;hold on;plot(tpts,fmap(:,1),tpts,fmap(:,2),tpts,fmap(:,3));idx = [1:5]';plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');subplot(222);% Create a wider formant trackanisomask = anisodiff(imap,6,50,0.01,1);imagesc(anisomask>0);axis xy;hold on;plot(tpts,fmap(:,1),tpts,fmap(:,2),tpts,fmap(:,3));idx = [1:5]';plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');subplot(223);imagesc(tmp_img4);axis xy;hold on;plot(tpts,fmap(:,1),'r',tpts,fmap(:,2),'r',tpts,fmap(:,3),'r');idx = [1:5]';plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');subplot(224);imagesc(tmp_img4.*(anisomask>0));axis xy;hold on;plot(tpts,fmap(:,1),'r-',tpts,fmap(:,2),'r-',tpts,fmap(:,3),'r-'); % idx = [1:5]'; % plot(tpts(idx),fmap(idx,1),'.-',tpts(idx),fmap(idx,2),'.-',tpts(idx),fmap(idx,3),'.-');plot(256*pt3,'y.-'); end;% Rescale to Actual Formants and take the mean of pitch tracks fmap = (fs/2)*(fmap/256); pt2 = nanmean(pt2');4.操作步驟與仿真結論
?
5.參考文獻
[1]楊凌, 楊海波, 高新春. 基于跟蹤共振峰的語音增強算法[J]. 電子與信息學報, 2009(10):5.
D201
6.完整源碼獲得方式
方式1:微信或者QQ聯系博主
方式2:訂閱MATLAB/FPGA教程,免費獲得教程案例以及任意2份完整源碼
總結
以上是生活随笔為你收集整理的【共振峰跟踪】通过平均不同分辨率的方法跟踪共振峰,基于时频lpc的频谱图的MATLAB仿真的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【维纳滤波】通过MATLAB自带的维纳滤
- 下一篇: 【CUDA7.5】MATLAB中配置Wi