CXDJY commited on
Commit
bd53b31
·
1 Parent(s): 791f610

removed noise

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -23,15 +23,15 @@ def preprocess_mp3(sample, index):
23
  return spectrogram
24
 
25
  def greet(name):
26
- wave = load_audio_to_tensor(name)
27
- power = sum(wave * 2) / len(wave) # audio signal power
28
- SNR = 3.5 # signal-to-noise ratio
29
- SNR_linear = 10 ** (SNR / 10) # convert SNR to linear scale
30
- noise_power = power / SNR_linear # noise power
31
-
32
- # add noise to audio to simulate environment
33
- noise = np.random.normal(0, noise_power ** 0.5, wave.shape) # generate noise
34
- wave = (wave + noise) * 32768.0 # add noise to the audio signal
35
  tensor_wave = tf.convert_to_tensor(wave, dtype=tf.float32) # convert to tensor
36
  min_wave = min(wave)
37
  if len(wave) > 16000:
 
23
  return spectrogram
24
 
25
  def greet(name):
26
+ wave, volume = load_audio_to_tensor(name)
27
+ # power = sum(wave * 2) / len(wave) # audio signal power
28
+ # SNR = 3.5 # signal-to-noise ratio
29
+ # SNR_linear = 10 ** (SNR / 10) # convert SNR to linear scale
30
+ # noise_power = power / SNR_linear # noise power
31
+
32
+ # # add noise to audio to simulate environment
33
+ # noise = np.random.normal(0, noise_power ** 0.5, wave.shape) # generate noise
34
+ # wave = (wave + noise) * 32768.0 # add noise to the audio signal
35
  tensor_wave = tf.convert_to_tensor(wave, dtype=tf.float32) # convert to tensor
36
  min_wave = min(wave)
37
  if len(wave) > 16000: