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

📄 vcs1.m

📁 这是一个用于语音信号处理的工具箱
💻 M
字号:
% Script: vc1.m is a m-file to execute the voice conversion algorithm which
%         matches the speaking rate to the target speaker.
%
%         vc1 is a call function evoked by vcapp.m on figure(vwin_f)
 
  %---------------------------------------------------
  % time-align speech1 to match to the pace of speech2
  %---------------------------------------------------
     
  road_temp=road;
  vcidx11_temp=vcidx11;
  vcidx12_temp=vcidx12;
  vcidx21_temp=vcidx21;
  vcidx22_temp=vcidx22;
  
  for kfr=1:length(vcidx21_temp)
     thisseg=seg(seg>=vcidx21_temp(kfr) & seg<=vcidx22_temp(kfr));
     if isempty(thisseg)
        thisseg=[vcidx21_temp(kfr) vcidx22_temp(kfr)];
     end
     if thisseg(1)>vcidx21_temp(kfr)+2
        thisseg=[vcidx21_temp(kfr) thisseg];
     end
     for pseg=1:length(thisseg)-1
        vcidx21=thisseg(pseg);
        vcidx22=thisseg(pseg+1)-1;
        idx1=find(road_temp(1,:)==vcidx21);
        idx2=find(road_temp(1,:)==vcidx22);
        vcidx11=road_temp(2,idx1);
        vcidx12=road_temp(2,idx2);
        road=road_temp(:,road_temp(1,:)>=vcidx21 & road_temp(1,:)<=vcidx22);
        vc1;
        if kfr==1 & pseg==1
           gci3_temp=gci3;
           gm3(1)=gm3(2);
           gm3(length(gm3))=gm3(length(gm3)-1);
           gm3_temp=gm3;
           gpcf3_temp=gpcf3;
           ngm3_temp=ngm3;
           FF3_temp=FF3;
           FB3_temp=FB3;
        else
           if length(gci3)==length(gci2)
              gci3_temp=gci3;
           else
              idxnew=find(gci3>gci3_temp(length(gci3_temp))+30);   
              gci3(idxnew(1))=gci3_temp(length(gci3_temp))+fix((gci3(idxnew(2))-gci3_temp(length(gci3_temp)))/2);
              gci3_temp=[gci3_temp gci3(idxnew)];
           end
           if length(gm3)==length(gm2)
              gm3_temp=gm3;
           else
              gm3(1)=gm3(2);
              gm3(length(gm3))=gm3(length(gm3)-1);
              gm3_temp=[gm3_temp gm3(idxnew)];
           end   
           gpcf3_temp(vcidx21:vcidx22,:)=gpcf3(vcidx21:vcidx22,:);
           ngm3_temp(vcidx21:vcidx22,:)=ngm3(vcidx21:vcidx22,:);
           FF3_temp(vcidx21:vcidx22,:)=FF3(vcidx21:vcidx22,:);
           FB3_temp(vcidx21:vcidx22,:)=FB3(vcidx21:vcidx22,:);
        end
     end
     if thisseg(length(thisseg))~=vcidx22_temp(kfr) |length(thisseg)==1
        vcidx21=thisseg(length(thisseg));
        vcidx22=vcidx22_temp(kfr);
        idx1=find(road_temp(1,:)==vcidx21);
        idx2=find(road_temp(1,:)==vcidx22);
        vcidx11=road_temp(2,idx1);
        vcidx12=road_temp(2,idx2);
        road=road_temp(:,road_temp(1,:)>=vcidx21 & road_temp(1,:)<=vcidx22);
        vc1;
        if length(gci3)==length(gci2)
           gci3_temp=gci3;
        else
           idxnew=find(gci3>gci3_temp(length(gci3_temp))+30);              
           gci3_temp=[gci3_temp gci3(idxnew)];
        end
        if length(gm3)==length(gm2)
           gm3_temp=gm3;
        else
           gm3(1)=gm3(2);
           gm3(length(gm3))=gm3(length(gm3)-1);
           gm3_temp=[gm3_temp gm3(idxnew)];
        end   
        gpcf3_temp(vcidx21:vcidx22,:)=gpcf3(vcidx21:vcidx22,:);
        ngm3_temp(vcidx21:vcidx22,:)=ngm3(vcidx21:vcidx22,:);
        FF3_temp(vcidx21:vcidx22,:)=FF3(vcidx21:vcidx22,:);
        FB3_temp(vcidx21:vcidx22,:)=FB3(vcidx21:vcidx22,:);
     end    
  end   
  
  % Back to the original values
  road=road_temp;
  vcidx11=vcidx11_temp;
  vcidx12=vcidx12_temp;
  vcidx21=vcidx21_temp;
  vcidx22=vcidx22_temp;

  gm3=gm3_temp;
  % Median filtering to avoid peaks in gain and pitch contours
  for pp=4:length(gm3)-3
     gm3_temp(pp)=median(gm3(pp-3:pp+3)');
  end
  gm3=gm3_temp;
  for pp=1:length(vcidx21)
     spoint=(vcidx21(pp)-1)*m_len+1;
     epoint=(vcidx22(pp)-1)*m_len+1;
     idxgci=find(gci3_temp>spoint & gci3_temp<epoint );
     pitchs=diff( gci3_temp( idxgci ) );
     pitchssmo=pitchs;
     for pp1=4:length(pitchs)-3
        pitchssmo(pp1)=median(pitchs(pp1-3:pp1+3)');
     end
     for pp1=2:length(idxgci)
        gci3_temp(idxgci(pp1))=gci3_temp(idxgci(pp1)-1)+pitchssmo(pp1-1);
     end
  end
  gci3=gci3_temp;
  gpcf3=gpcf3_temp;
  ngm3=ngm3_temp;
  FF3=FF3_temp;
  FB3=FB3_temp;
  clear road_temp vcidx11_temp vcidx12_temp vcidx21_temp vcidx22_temp;
  clear gci3_temp gm3_temp gpcf3_temp ngm3_temp FF3_temp FB3_temp seg;

⌨️ 快捷键说明

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