Matlab男声变女声
FFT实现长序列卷积,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('转化后语音信号频谱');
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]