How can I generated Speech Shaped Noise(SSN)
조회 수: 32 (최근 30일)
이전 댓글 표시
Hello all
I had a question about generated Speech Shaped Noise.
I had followed a document from The University of Texas at Dallas, Speech Perception Laboratory. Thanks them. http://www.utdallas.edu/~assmann/hcs7367/lec8.pdf
They also provide code to calculate the long-term average speech spectrum. And according to the document I generated a Speech shaped noise already.
But, there some problem here. I use the code as below to generated SSN.
mag=10.^(ltass/20);
freq=linespace(0,1,length(mag));
FIR_ltass=fir2(512,freq,mag);
noise=randn(npts,1);
SSN=conv(noise,FIR_ltass);
where ltass as the Speech's LTASS that I used, and npts as the sample points of the speech shaped noise that I want to create. This is to make a FIR filter which had the response that same as the LTASS, then convoluted the FIR filter and white noise to generated a noise which had the same LTASS as speech.
After all, I calculated the Speech shaped noise's LTASS.
As we can seen, the red line is Speech's LTASS and blue line is SSN's LTASS. Although they have same trend, but the SSN's amplitude was lower then Speech. They speech which I used to calculated LTASS are 320 sentences and all of those RMS are 0.075. And the SSN also adjust RMS to 0.075 to calculated LTASS.
I didn't know that this is normal result or I did wrong at somewhere?
Appreciate your time reading my question.
댓글 수: 0
채택된 답변
Nike
2012년 11월 9일
This should beable to solve your problem... cheers..
file = uigetfile('*.wav', 'Select the wave file');
[data,fs] = wavread(file);
data = data/sqrt((sum(data.^2))/length(data));
[a,g]= lpc(data,6);
noise = randn(length(data),1);
out= filter(g,a,noise);
finout = out/sqrt((sum(out.^2))/length(data));
[H,F] = freqz(g,a,256,fs);
plot(F,log(abs(H)),'b');
hold on
[a,g]= lpc(finout,6);
[H,F] = freqz(g,a,256, fs);
plot(F,log(abs(H)),'r');
추가 답변 (4개)
Jacob D
2016년 11월 14일
편집: Jacob D
2016년 11월 14일
I know this question is a few years old but here is a simple solution for the record...
(2) Put the toolbox into a class folder, +Tools, on the MATLAB search path.
(3) Run the following code with your noise signal and you'll get (1/n)-th octave smoothed speech shaped noise, SSN:
Fs = 16000; % Sampling frequency
Nfft = 1024; % FFT length
OctaveBandSpace = 1/6; % 1/6 octave band smoothing
noise; % White Gaussian Noise
% (or other statistically distributed white spectrum noise)
SpeechFolderOrVector = ... A folder path or vector of speech samples
'SpeechFiles\';
[spect, frqs] = Tools.LTASS... Compute LTASS spectrum
(SpeechFolderOrVector, Nfft, Fs );
SSN = Tools.ArbitraryOctaveFilt... Speech shaped noise
(noise, spect, frqs, Nfft, Fs, OctaveBandSpace);
Here is the spectrum I obtain with White Gaussian Noise and speech files from the TIMIT corpus:
sxx=pwelch(SSN/rms(SSN),rectwin(Nfft),0,Nfft,Fs,'power').^.5;
pl=plot(frqs/1e3,mag2db([spect,sxx]),'linewidth',2);pl(1).Color='r';pl(2).Color='b';
ax=gca;ax.XScale='log';fm=Fs/2/1e3;xlim([0.05 fm]);ax.XTick=[0.1,1,fm];grid on; grid minor;
xlabel('Frequency (kHz)');ylabel('Magnitude (dB)');legend({'LTASS';'SSN'});
댓글 수: 0
Nike
2012년 11월 14일
Reading each file will take a rather long time, why dont you just normalize all the speech files, concatenate them and find the lpc of the whole signal and use its coefficients to generate the speech noise.typically it should bedone for all the speech files together.
You can use the below mentioned code for concatenating all the speech files in one go.
Coming to your other question about the order, I don't think an order of 125 should be a problem as long as the order is less than length(data)-1
files = uigetdir('C:\*.wav', 'Select the directory with the speech stimuli');
type = '\*.wav';
filepath = strcat(files,type);
files = dir(filepath);
nfiles = length(files);
list=1:1:nfiles;
files = char(files.name);
stimlist=files(list,:);
maxdur = 2;
for i = 1:nfiles
z = stimlist(i,:) ;
[speech,fs] = wavread(z);
n = length(speech);
silence = maxdur*fs + 2*fs;
sil = silence-length(speech);
gap = zeros(sil,1);
signal = [speech;gap];
mix(:,i) = signal;
stretch = mix(:);
end
stretch = stretch/sqrt((sum(stretch.^2))/length(stretch));
[a,g]= lpc(stretch,125);
noise = randn(length(stretch),1);
out= filter(g,a,noise);
finout = out/sqrt((sum(out.^2))/length(stretch));
[H,F] = freqz(g,a,256,fs);
plot(F,log(abs(H)),'b');
hold on
[a,g]= lpc(finout,125);
[H,F] = freqz(g,a,256, fs);
plot(F,log(abs(H)),'r');
wavwrite(finout,fs,'speechnoise.wav')
Hope you find it useful,
Cheers
Nike
댓글 수: 1
Emilia Butters
2020년 3월 25일
Hi, when I try this method i get the following error:
Unrecognized function or variable 'stretch'.
Error in Test (line 23)
stretch = stretch/sqrt((sum(stretch.^2))/length(stretch));
Do you know why this may be happening?
Nike
2016년 3월 8일
Hi,
You can find a better version of code for generating the speech shaped noise in the attached link
regards,
Nike
댓글 수: 0
Peidong Wang
2016년 5월 27일
Combining the instruction on http://www.utdallas.edu/~assmann/hcs7367/lec8.pdf and the code on http://www.utdallas.edu/~assmann/hcs7367/classnotes.html (ltass.m, fftpsd.m and hanning.m) will work well.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!