Matlab男聲變女聲
FFT實現(xiàn)長序列卷積,256點
FIR濾波器
-------------------------------------------------------Code-------------------------------------------------------------
clear;
clc;
[y,fs]=audioread('C:\Users\shinelon\Documents\錄音\number2.wav');
figure
plot(y);
y = y(:, 1)';
for?i=0:1:1158
%sound(y,fs);
y_temp=y((i*256+1):1:(i+1)*256);
S=fft(y_temp,256);
%figure
%subplot(2,1,1);
%plot(y);
%title('原語音信號波形');
%subplot(2,1,2);
%plot(abs(S));
%title('原語音信號頻譜');
?
Hd = FIR1;
female_freq = filter(Hd,S);
%figure(2);
%subplot(2,1,1);
%plot(abs(female_freq));
%title('轉(zhuǎn)化后語音信號頻譜');
????if?i==0
???????female = real(ifft(female_freq,256))';
????else
????????temp = real(ifft(female_freq,256))';
????????female =[female;temp];
????end
end
figure(2);
plot(female);
audiowrite('C:\Users\shinelon\Documents\錄音\transform.wav',female*100,fs);
?
?
?
?
?
--------------------------------------------------
function?Hd = FIR1
%FIR1 Returns a discrete-time filter object.
?
% MATLAB Code
% Generated by MATLAB(R) 9.1 and the DSP System Toolbox 9.3.
% Generated on: 06-Nov-2022 23:42:27
?
% Equiripple Highpass filter designed using the FIRPM function.
?
% All frequency values are in Hz.
Fs = 48000; ?% Sampling Frequency
?
Fstop = 150; ????????????% Stopband Frequency
Fpass = 1000; ???????????% Passband Frequency
Dstop = 0.0001; ?????????% Stopband Attenuation
Dpass = 0.057501127785; ?% Passband Ripple
dens ?= 20; ?????????????% Density Factor
?
% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fstop, Fpass]/(Fs/2), [0 1], [Dstop, Dpass]);
?
% Calculate the coefficients using the FIRPM function.
b ?= firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);
?
% [EOF]