2018/01/26

Matlab: Divide a speech utterance into 3 bands


>> load mtlb %Load the 'Matlab' speech / dimention: 4001x1
>> sound(mtlb,Fs); %Play the original sound
>> len = length(mtlb); %Number of points
>> time = [1:len]/Fs; %x-axis time vector / dimention: 1x4001
>> subplot(5,1,1);
>> plot(time,mtlb);
>> title('Original Speech');

>> Fco1 = 1000/(Fs/2); %Cutoff freq. 1
>> Fco2 = 2000/(Fs/2); %Cutoff freq. 2

>> [Bhpf, Ahpf] = butter(4,Fco2,'high'); %design a HPF
>> [Bbpf, Abpf] = butter(4,[Fco1 Fco2],'bandpass'); %design a BPF
>> [Blpf, Alpf] = butter(4,Fco1,'low'); %design a LPF


>> y_hpf = filter(Bhpf, Ahpf, mtlb); %get time domain result

>> y_bpf = filter(Bbpf, Abpf, mtlb); %get time domain result
>> y_lpf = filter(Blpf, Alpf, mtlb); %get time domain result

>> subplot(5,1,2);
>> y_reconstruct = y_hpf + y_bpf + y_lpf;
>> plot(time,y_reconstruct);
>> title('Reconstructed Speech');
>> sound(y_reconstruct,Fs); %Play the reconstructed sound

>> subplot(5,1,3);
>> plot(time,y_hpf);
>> title('HPF Speech');
>> sound(y_hpf,Fs); %Play the HPF sound


>> subplot(5,1,4);
>> plot(time,y_bpf);
>> title('BPF Speech');
>> sound(y_bpf,Fs); %Play the BPF sound


>> subplot(5,1,5);
>> plot(time,y_lpf);
>> title('LPF Speech');
>> sound(y_lpf,Fs); %Play the LPF sound


Result:


沒有留言:

張貼留言