khalida1wwin
commited on
Commit
·
fa0d485
1
Parent(s):
d7d8acc
update app.py
Browse files
app.py
CHANGED
@@ -138,7 +138,7 @@ def inv_scaled_ou(matrix_spec):
|
|
138 |
return matrix_spec
|
139 |
|
140 |
|
141 |
-
def prediction(weights_path, name_model,
|
142 |
audio_output_prediction, sample_rate, min_duration, frame_length, hop_length_frame, n_fft, hop_length_fft):
|
143 |
""" This function takes as input pretrained weights, noisy voice sound to denoise, predict
|
144 |
the denoise sound and save it to disk.
|
@@ -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 |
-
|
159 |
-
|
160 |
#Dimensions of squared spectrogram
|
161 |
dim_square_spec = int(n_fft / 2) + 1
|
162 |
print(dim_square_spec)
|
@@ -191,8 +191,8 @@ audio_output_prediction, sample_rate, min_duration, frame_length, hop_length_fra
|
|
191 |
|
192 |
def denoise_audio(audioName):
|
193 |
testNo = audioName
|
194 |
-
|
195 |
-
sample_rate, data =
|
196 |
len_data = len(data) # holds length of the numpy array
|
197 |
|
198 |
|
@@ -204,7 +204,7 @@ def denoise_audio(audioName):
|
|
204 |
dir_save_prediction = os.path.abspath("/")
|
205 |
audio_output_prediction = "test"+ testNo+".wav"
|
206 |
audio_input_prediction = [testNo +".wav"]
|
207 |
-
|
208 |
min_duration = t
|
209 |
frame_length = 8064
|
210 |
hop_length_frame = 8064
|
@@ -213,10 +213,10 @@ def denoise_audio(audioName):
|
|
213 |
|
214 |
dim_square_spec = int(n_fft / 2) + 1
|
215 |
|
216 |
-
prediction(weights_path, name_model,
|
217 |
audio_output_prediction, sample_rate, min_duration, frame_length, hop_length_frame, n_fft, hop_length_fft)
|
218 |
print(audio_output_prediction)
|
219 |
-
return audio_output_prediction
|
220 |
|
221 |
|
222 |
examples = [
|
|
|
138 |
return matrix_spec
|
139 |
|
140 |
|
141 |
+
def prediction(weights_path, name_model, audioData, dir_save_prediction, audio_input_prediction,
|
142 |
audio_output_prediction, sample_rate, min_duration, frame_length, hop_length_frame, n_fft, hop_length_fft):
|
143 |
""" This function takes as input pretrained weights, noisy voice sound to denoise, predict
|
144 |
the denoise sound and save it to disk.
|
|
|
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)
|
|
|
191 |
|
192 |
def denoise_audio(audioName):
|
193 |
testNo = audioName
|
194 |
+
# audio_dir_prediction = os.path.abspath("/")+ str(testNo) +".wav"
|
195 |
+
sample_rate, data = audioName[0], audioName[1]
|
196 |
len_data = len(data) # holds length of the numpy array
|
197 |
|
198 |
|
|
|
204 |
dir_save_prediction = os.path.abspath("/")
|
205 |
audio_output_prediction = "test"+ testNo+".wav"
|
206 |
audio_input_prediction = [testNo +".wav"]
|
207 |
+
|
208 |
min_duration = t
|
209 |
frame_length = 8064
|
210 |
hop_length_frame = 8064
|
|
|
213 |
|
214 |
dim_square_spec = int(n_fft / 2) + 1
|
215 |
|
216 |
+
prediction(weights_path, name_model, data, dir_save_prediction, audio_input_prediction,
|
217 |
audio_output_prediction, sample_rate, min_duration, frame_length, hop_length_frame, n_fft, hop_length_fft)
|
218 |
print(audio_output_prediction)
|
219 |
+
return audio_output_prediction[0]
|
220 |
|
221 |
|
222 |
examples = [
|