function [fmap,pt2] = ftrack(y,fs)
% FTRACK Tracks the formants through a method of averaging different resolutions
% of time frequency lpc based spectrograms. In addition it also determines the
% pitch contour of the speech signal.
%
% This is a very preliminary attempt at tracking. IT SHOULD THEREFORE BE USED
% WITH DUE CAUTION.
%
% Satrajit Ghosh, 2002
% SpeechLab, Department of Cognitive and Neural Systems, Boston University
bDisplay = 1;
Fsamps = 256; % sampling resolution in frequency dimension
Tsamps = round(length(y)/18000*256); % sampling resolution in time dimension
% The final maps are generated such that time is divided into Tsamps
% number of points. This should be scaled with length of speech input
% Frequency dimension is broken into Fsamps number of points.
tmp_img1 = zeros(Fsamps,Tsamps);
ct = 0;
numiter = 8; % number of iterations to run. seemed like a good number
% Iterate through different frequency resolutions. The time resolution is
% automatically determined as time_pts*freq_pts = length of signal
for i=2.^(8-8*exp(-linspace(1.5,10,numiter)/1.4)),
% Determine the time-frequency distribution at the current
[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 resolution
tmp_img2 = interp2(tmp_img1,xi,yi);
ct = ct+1;
% Interpolate formant tracks and pitch tracks
pt2(:,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)')';
% Normalize
tmp_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 track
anisomask = 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');
没有合适的资源?快使用搜索试试~ 我知道了~
jiance.rar_matlab语音合成_共振峰 合成_语音_语音合成
共6个文件
m:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 94 浏览量
2022-07-14
02:30:21
上传
评论 1
收藏 5KB RAR 举报
温馨提示
用于对语音信号的共振峰进行检测,从而进行语音识别或语音合成。
资源详情
资源评论
资源推荐
收起资源包目录
jiance.rar (6个子文件)
共振峰检测
frmnts1.m 1KB
pitch.m 2KB
lpcsgram.m 2KB
ftrack.m 4KB
anisodiff.m 2KB
demo01.m 283B
共 6 条
- 1
刘良运
- 粉丝: 77
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0