25 from scipy.io
import wavfile
39 def energyDenoise(self, audio_file, scale, denoised_audio_file, energy_denoising_debug):
40 if not os.path.isfile(audio_file):
42 samp_freq, signal = wavfile.read(audio_file)
43 samples = signal.shape[0]
44 sq_signal = signal * 1.0
46 if energy_denoising_debug:
47 timearray = arange(0, samples*1.0, 1)
48 timearray /= samp_freq
51 plot(timearray, signal, color =
'k')
53 for i
in range(0, len(sq_signal)):
54 sq_signal[i] *= sq_signal[i]
55 mean_sq = mean(sq_signal)
57 for i
in range(0, len(sq_signal)):
58 if sq_signal[i] < scale * mean_sq:
61 if energy_denoising_debug:
62 timearray = arange(0, samples*1.0, 1)
63 timearray /= samp_freq
66 plot(timearray, signal, color =
'k')
68 if energy_denoising_debug:
71 wavfile.write(denoised_audio_file, samp_freq, signal)
def energyDenoise
Performs energy-based denoising.
Performs energy denoising on an audio file.