Documentos de Académico
Documentos de Profesional
Documentos de Cultura
reconstructed_frames = ifft(sqrt(clean_spec).*exp(phase),NFFT,2);
reconstructed_frames = real(reconstructed_frames(:,1:WINLEN*fs)); %
sometimes small complex residuals stay behind
enhanced_signal =
deframe_sig(reconstructed_frames,length(sig),WINLEN*fs,WINSTEP*fs,@hamming);
Traducido
[sig fs] = read_NIST_file (nombre de archivo); % lee el archivo de entrada,
asume que se proporciona el nombre de archivo
NFFT = 1024 ;
WINLEN = 0.025 ; % de longitud de trama en ms
WINSTEP = 0.01 ;
marcos = frame_sig (sig, WINLEN * fs, WINSTEP * fs, @hamming);
cspec = fft (cuadros, NFFT, 2 ); % espectro complejo
pspec = abs (cspec). ^ 2; % de espectro de potencia de señal ruidosa
fase = ángulo (cspec);
[y,Fe]=audioread('sample.wav');
Nx=length(x);
%algorithm parameters
beta1=0.5;
beta2=1;
lambda=3;
%STFT parameters
NFFT=1024;
window_length=round(0.031*Fe);
window=hamming(window_length);
window = window(:);
%Signal parameters
%construct spectrogram
[Nf,Nw]=size(S);
absS_noise=abs(S(:,t_index)).^2;
noise_specgram=repmat(noise_spectrum,1,Nw);
%Estimate SNR
absS=abs(S).^2;
SNR_est=max((absS./noise_specgram)-1,0);
if apriori_SNR==1
SNR_est=filter((1-alpha),[1 -alpha],SNR_est);
end
an_lk=max((1-lambda*((1./(SNR_est+1)).^beta1)).^beta2,0);
STFT=an_lk.*S;
ind=mod((1:window_length)-1,Nf)+1;
output_signal=zeros((Nw-1)*overlap+window_length,1);
left_index=((indice-1)*overlap) ;
index=left_index+[1:window_length];
temp_ifft=real(ifft(STFT(:,indice),NFFT));
output_signal(index)= output_signal(index)+temp_ifft(ind).*window;
end
subplot(2,1,1);
plot([1:length(x)]/Fe,x);
xlabel('Time (s)');
ylabel('Amplitude');
hold on;
noise_interval=floor([T(t_index(1))*Fe:T(t_index(end))*Fe]);
plot(noise_interval/Fe,x(noise_interval),'r');
hold off;
title('Original Sound');
subplot(2,1,2);
plot([1:length(output_signal)]/Fe,output_signal );
xlabel('Time (s)');
ylabel('Amplitude');
%show spectrogram
t_epsilon=0.001;
figure
pcolor(T,F(1:end/2),10*log10(abs(S_one_sided)));
shading interp;
colormap('hot');
title('Spectrogram: speech + noise');
xlabel('Time (s)');
ylabel('Frequency (Hz)');
figure
pcolor(T,F(1:end/2),10*log10(abs(S_one_sided)));
shading interp;
colormap('hot');
xlabel('Time (s)');
ylabel('Frequency (Hz)');
%Listen results
audioplayer(x(1:5*Fe),Fe);
fprintf(' OK\n');
audioplayer(output_signal(1:5*Fe),Fe);
fprintf('OK\n');
fprintf('Write denoised_speech.wav');
audiowrite('denoised_signal.wav',output_signal,Fe);
Contact GitHub
Pricing
API
Training
Blog
About