This was developed by G Nike Gnanateja for mixing speech signals with noise at difference signal to noise ratios.
This function mixes the speech and noise signals in terms of the RMS signal to noise ratios.
Hope you find it useful
This program has been written by G. Nike Gnanateja, Junior Research Fellow, Dept. of Audiology
All India Institute of Speech and hearing, Mysore,for mixing the speech signals
and noise at desired Signal to Noise Ratios
If you are new to matlab, try any of these
1. Just copy the entire script and paste it in the command window
2. Select all and press F9 (on windows)
3. Drag the speechmix1_rev_1.m file onto the command window
If you desire an SNR lower than -10dB , Change the value of dbs to lower
values eg; -5, -2 etc.Change the File name in the wavwrite command if you
desire a different file name
Changes from the earlier version :
1. The instruction is much better described in the help section for non-matlab users
2. The Speech files selection has been changed to selection of multiple files
rather than selection of a directory as earlier. This allows users to
flexibly choose the files that they desire. The output directory cannot
be selected. I can actually incorporate this (Very easy), but I feel that
the user has to click a lot of dialog boxes and as the script is intended
for non-matlab users, it might be too much.
3. The Verbose file is an important addition. I feel this is very important,
as it helps in identifying location of the original input and output data files.
Copyright : G. Nike Gnanateja (2017)
Nike (2020). Speech in noise mixing, signal to noise ratio (https://www.mathworks.com/matlabcentral/fileexchange/37842-speech-in-noise-mixing-signal-to-noise-ratio), MATLAB Central File Exchange. Retrieved .
It will be helpful if one example for input case in the instructions can be provided i.e creating a noisy file of _ db using noise only file with duration_ sec and _ sec cleanSpeech file with_ sec delay in speech file.
I am getting this error with wavread, 70 error(message('MATLAB:audiovideo:wavread:InvalidFile', msg));
however my noise file and speech files are all in .wav format. Do you have any advice? I'm not very experienced with matlab.
yes it is.
the duration of speech wav files varies but noise file's duration is fixed.
Is there any difference between the duration of speech and noise ?
I need speech & noise mixed wav files with no level adjustment.
for example, I have a noise file, its RMS level is -25 dB
and speech files RMS ranges from -22 to -27 dB.
I need just mix these files with no level adjustment
how can i do?
sir how i suppose to add my noise file or i have to create new file with noise
You didn't tell me the duration of the noise file.
Any case, in the meantime try changing this line
rep = 5*round(diff+1);
rep = 20*round(diff+1);
if yu give me the noise duration I can tell you exactly what to do
sorry for the inconvenience sir. My speech signal duration is 3.84 sec
Hi Manjutha ,
What are the durations of your speech and noise files?
can you help me to clear this sir.
Index exceeds matrix dimensions.
Error in vad_2 (line 82)
noise = noise(start:ending,1);
You can delete lines number 54 and 54 in the script and replace it by the two lines below. That should work.
dbn = -25 ;
dbs = dbn+snr;
I have a noise file and signal files(their RMS values -25 dB).
I'd like to make -4dB SNR wav files(noise RMS value fixed: -25 dB)
I tried it using your code, but noise file's RMS value was changed
Could you please tell me How I have to do?
It looks like the script is adding a space at the end of the filename so it is 'filename.wav ' instead of 'filename.wav'
Thanks for your interest and rating rajan
Very useful for persons like me to create stimuli for various testings. Thanks to the developer for making our work easy. Easy to use and stimuli is ready within seconds. Great work
Hi Ahmed, I am sorry that you experienced errors. I may be able to help you if you can share the contents if the error message.
Hi Nike I working to make noising speeches database with diffrent dB(-10,-5,0,5,10,20,Clean) to use it in my project so I need to use this submission for creating this database and use diffrents speeches and noises ...But there is some errors that happened when using it with Matlab 2014a ...
do update the rating on the file if you find the program useful
very glad that you have replied to my query this quickly
we are been using your submission in evaluation of performance of Voice activity detection algorithms
by the way i have some doubts it seems you are a expert in this field :)
ok as you said i will use your submission
do you have any idea where we can get a corpus of indian speech data base and some subway noise,resturant noise etc
many countries like japan,turkey,uk,us have their database poor india has got nothing like that it i think india should also have the database
any wayz i have got some subway and resturant noises can i use your submission in mixing them with my speech file ? is that feasible
Sampling Rate:8Khz,16bit signed sample
I am glad that you downloaded my submission and put it to use.
If You want an SNR of 0 dB then just don't edit anything in the code anything. Just run the code and enter the SNR when you are asked.
The dbs is just an attenuation factor for the speech signal,I have fixed it at -10dB. The maximum amplitude which can be provided in in a wav file written in matlab is 0 dB.
So if we need to have SNR of -15 dB with the signal attenuation at -10 dB, then the noise needs to be at an attenuation of +5dB which is not possible. That is the reason why, you need to change the dbs in case you need SNRs lower than -10dB.
the values which you pointed out were typos, I meant -15 an -12 dB.
P.S: If you do not know how to run matlab codes, please put in a reply , I'll walk you through..
why two snr dbs and dbn in you file and you also say values less than -10 which are -5 -2
what are you trying to say is -5 less than -10 :) please explain your code if i need 0dB snr where should i apply dbs or dbn ???????
Very Useful Submission
Thank you very much
If you find this content useful, Don't forget to cite this content as follows
Gnanateja, G. N. (2012). Speech in noise mixing, signal to noise ratio.http://www.mathworks.com/matlabcentral/fileexchange/37842-speech-in-noise-mixing-signal-to-noise-ratio, Matlab Central File Exchange. Retrieved on dd-mm-yy
Please don't forget to cite us if you find the code useful
Dont forget to drop in your comments and also rate the upload, it will help us make it better
Corrected small glitches in silence padding and processing of a single stimulus
Check the description for the update notes
The previous version could only mix the signals with the same sampling rate, however the current update mix signals differing in their sampling rates