matlab2013b
首先,整体框架的基本构架如下所示:
编码:
解码:
传统的AMDF算法或者ACF算法都无法满足实际的需求,这里,通过计算AMDF/ACF值或者ACF/AMDF值。这里选择效果更好的ACF/AMDF方法进行。
矢量量化采用一种逐帧的LPC VQ方案,这里,基本流程:
得到的音调预测和增益直接进行量化,而线性预测则需要进行矢量量化器进行量化,并进行组帧。
其中矢量编码解码的基本结构如下所示:
登录后复制
clc;clear;close all;warning off;addpath 'func\'addpath 'Train\'RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));%读取待处理的声音文件[yOri,Fs,nbits] = wavread('test1.wav');sound(yOri,Fs);plotFlag = 0; %绘图标识位istrain = 0;%1.预处理,滤波%1.预处理,滤波n = 8; Wn = ([60,3600]/4000);[b,a] = butter(n,Wn,'bandpass'); yPre = filter(b,a,yOri);plot1;%2.预加重 %2.预加重 a = 1;b = [1 -0.9375];yPw = filter(b,a,yPre);plot2;%3.清、浊音判决的分析及量化%低带能量:通过一个截止频率为900Hz 阻带为10dB的低通滤波器Wp = 900/4000;[b,a]= cheby2(6,10,Wp,'low');yLF = filter(b,a,yPre);plot3;%成帧[yFrame,nF] = func_enFrame(yLF); %短时能量来区分清/浊音VoiceSoundFlag = func_short_energy(yFrame,nF);%二阶逆滤波(白化滤波)yFrame = inverseFilter(yFrame,nF); %获得基音周期(AMDF)pitchT = func_GetPitch(yFrame,VoiceSoundFlag,nF); %计算增益(RMS)RMS = func_RMS(yFrame,VoiceSoundFlag,pitchT,nF);%LPC预测阶数[Vlpc,Vlsf] = func_LPC_Order(yFrame,nF);%矢量量化采用王炳锡书5.8章红圈的方法,并组帧%训练,得到码本,这里需要大量的语音库,这里仅仅提供算法流程,训练库使用少量样本if istrain == 1 tops; load Train\code_save.mat else load Train\code_save.mat endfigure;K1 = 1;K2 = 2;plot(lsf{1}(K1,:), lsf{1}(K2,:), 'xr');hold on;plot(code{1}(K1,:),code{1}(K2,:), 'vk');hold on;plot(lsf{2}(K1,:), lsf{2}(K2,:), 'xb');hold on;plot(code{2}(K1,:),code{2}(K2,:), '+k');hold on;xlabel('2th Dimension');ylabel('6th Dimension');legend('Speaker 1', 'Codebook 1', 'Speaker 2', 'Codebook 2');title('2D plot of accoustic vectors');%VQ发送Frame = func_vq_trans(Vlsf,pitchT,RMS,VoiceSoundFlag,nF,code);%计算压缩对比Rate = func_size_cal(yOri,Frame);%接收,矢量解码器[Vlsf3,VQ_decode,lsf_code,VoiceSoundFlag3,RMS3,pitchT3] = func_vq_rec(Frame,nF,code);%解码yCom = func_decode(Vlsf3,VoiceSoundFlag3,pitchT3,RMS3,nF);%去加重b = 1;a = [1 -0.9375];yCom = filter(b,a,yCom);sound(yCom,Fs); figure;subplot(311);plot(yOri);subplot(312);plot(pitchT);subplot(313);plot(yCom); 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删