Guest User

Untitled

a guest
Dec 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. def noise_reduction_ourrec(dirName):
  2. types = ('*.wav', '*.aif', '*.aiff', '*.mp3', '*.au', '*.ogg')
  3. wav_file_list = []
  4. for files in types:
  5. wav_file_list.extend(glob.glob(os.path.join(dirName, files)))
  6. wav_file_list = sorted(wav_file_list)
  7. wav_file_list2 = []
  8. print(os.getcwd())
  9. for i, wavFile in enumerate(wav_file_list):
  10. j=1
  11.  
  12. Frequency,samples =read(wavFile)
  13. FourierTransformation = sp.fft(samples) # Calculating the fourier transformation of the signal
  14. scale = sp.linspace(0, Frequency, len(samples))
  15. b,a = signal.butter(5, 9800/(Frequency/2), btype='highpass') # ButterWorth filter 4350
  16. filteredSignal = signal.lfilter(b,a,samples)
  17. c,d = signal.butter(5, 200/(Frequency/4), btype='lowpass') # ButterWorth low-filter
  18. newFilteredSignal = signal.lfilter(c,d,filteredSignal) # Applying the filter to the signal
  19. name = "Wavfile"+str(i)
  20. j=j+1
  21. print(name)
  22. librosa.output.write_wav(name, newFilteredSignal,Frequency)
Add Comment
Please, Sign In to add comment