0

I'm attempting to add noise to a speech signal (.wav file) in matlab using the following method:

load handel.mat;

hfile= 'noisy.wav';

y = wavread('daveno.wav');
y = y + randn(size(y)) * (1/100);
wavwrite(y, Fs, hfile);
nsamples=Fs;

This adds the noise, however, it removes the actual speech spoken word and therefore, the noise is only contained. Do I need to multiply by a bigger number, or, could anyone please suggest a way to fix this problem?

Amro
  • 123,847
  • 25
  • 243
  • 454
Phorce
  • 2,632
  • 13
  • 43
  • 76
  • 1
    if you leave off the line where you add the noise, does it work? If it does then maybe you just need noise with a smaller amplitude. Maybe you can try `y = y + randn(size(y)) * (max(abs(y)/100));` – Dan Apr 19 '13 at 10:01
  • @Dan Thanks for the reply. When I leave off the line where I add noise, it completely messes up the signal, in that, it sounds like a robot and the timing is completely out. Any suggestions? – Phorce Apr 19 '13 at 10:04
  • 2
    What is `Fs`, maybe you're not sampling at a high enough frequency. Maybe try `[y, Fs] = wavread('daveno.wav')` to get a good `Fs`? – Dan Apr 19 '13 at 10:05
  • @Dan You could be right. Is there a way to read in the sampling rate at read in, and, keep it, and, then write with the same sampling frequency? – Phorce Apr 19 '13 at 10:06
  • @Dan Got it :) Please make your comment an answer and I'll accept! Thank you for your help – Phorce Apr 19 '13 at 10:08

1 Answers1

5

The issue is that you are writing the file at the wrong sampling frequency. Find the correct sampling frequency (i.e. the value for Fs) using the second output of wavread

   [y, Fs] = wavread('daveno.wav')
Dan
  • 45,079
  • 17
  • 88
  • 157
  • 1
    Thank you for taking the time to help me, greatly appreciated. Enjoy the rest of your day/evening/night :) – Phorce Apr 19 '13 at 10:26