khalida1wwin commited on
Commit
eb9c657
·
1 Parent(s): aca6b51

update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -154,9 +154,9 @@ audio_output_prediction, sample_rate, min_duration, frame_length, hop_length_fra
154
  print("Loaded model from disk")
155
 
156
  # Extracting noise and voice from folder and convert to numpy
157
- # audio = audio_files_to_numpy(audio_dir_prediction, audio_input_prediction, sample_rate,
158
- # frame_length, hop_length_frame, min_duration)
159
- audio = audioData
160
  #Dimensions of squared spectrogram
161
  dim_square_spec = int(n_fft / 2) + 1
162
  print(dim_square_spec)
@@ -190,17 +190,13 @@ audio_output_prediction, sample_rate, min_duration, frame_length, hop_length_fra
190
  sf.write(dir_save_prediction + audio_output_prediction , denoise_long[0, :], sample_rate)
191
 
192
  def denoise_audio(audioName):
193
- # print("typppppeeeeee:",type(audioName))
194
- testNo = audioName
195
- # audio_dir_prediction = os.path.abspath("/")+ str(testNo) +".wav"
196
- sample_rate, datalist = audioName[0], audioName[1]
197
- print("typppppeeeeee:")
198
- print(type(datalist))
199
- data = np.ndarray(datalist)
200
  len_data = len(data) # holds length of the numpy array
201
- print("typppppeeeeee:")
202
- print(type(data))
203
- print(data)
204
 
205
  t = len_data / sample_rate # returns duration but in floats
206
  print("t:",t)
@@ -233,7 +229,7 @@ examples = [
233
 
234
 
235
  iface = gr.Interface(fn = denoise_audio,
236
- inputs=[gr.Audio(source="microphone", type="numpy")],
237
  outputs = 'audio',
238
  verbose = True,
239
  title = 'audio to denoised Audio Application',
 
154
  print("Loaded model from disk")
155
 
156
  # Extracting noise and voice from folder and convert to numpy
157
+ audio = audio_files_to_numpy(audio_dir_prediction, audio_input_prediction, sample_rate,
158
+ frame_length, hop_length_frame, min_duration)
159
+ # audio = audioData
160
  #Dimensions of squared spectrogram
161
  dim_square_spec = int(n_fft / 2) + 1
162
  print(dim_square_spec)
 
190
  sf.write(dir_save_prediction + audio_output_prediction , denoise_long[0, :], sample_rate)
191
 
192
  def denoise_audio(audioName):
193
+ sr, data = audioName
194
+ sf.write("temp.wav",data, sr)
195
+ testNo = "temp"
196
+ audio_dir_prediction = os.path.abspath("/")+ str(testNo) +".wav"
197
+ sample_rate, data = audioName[0], audioName[1]
 
 
198
  len_data = len(data) # holds length of the numpy array
199
+
 
 
200
 
201
  t = len_data / sample_rate # returns duration but in floats
202
  print("t:",t)
 
229
 
230
 
231
  iface = gr.Interface(fn = denoise_audio,
232
+ inputs = 'audio',
233
  outputs = 'audio',
234
  verbose = True,
235
  title = 'audio to denoised Audio Application',