Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -68,7 +68,13 @@ def transcribe(apikey, upload, audio, choice1):
|
|
68 |
|
69 |
tts.tts_to_file(chat_response, speaker_wav = upload, language="en", file_path="output.wav")
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
enhance_model = SpectralMaskEnhancement.from_hparams(
|
74 |
source="speechbrain/metricgan-plus-voicebank",
|
@@ -77,21 +83,13 @@ def transcribe(apikey, upload, audio, choice1):
|
|
77 |
)
|
78 |
|
79 |
noisy = enhance_model.load_audio(
|
80 |
-
|
81 |
).unsqueeze(0)
|
82 |
|
83 |
enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
|
84 |
torchaudio.save("enhanced.wav", enhanced.cpu(), 16000)
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
reduced_noise = nr.reduce_noise(y=data, sr=rate, prop_decrease= 0.95, stationary=True)
|
89 |
-
#reduced_noise = nr.reduce_noise(y = data, sr=rate, prop_decrease= 0.85)
|
90 |
-
#reduced_noise = nr.reduce_noise(y = data, sr=rate, thresh_n_mult_nonstationary=2, stationary=False)
|
91 |
-
|
92 |
-
wavfile.write("audio1.wav", rate, reduced_noise)
|
93 |
-
|
94 |
-
return [result.text, chat_response, "audio1.wav"]
|
95 |
|
96 |
output_1 = gr.Textbox(label="Speech to Text")
|
97 |
output_2 = gr.Textbox(label="ChatGPT Output")
|
|
|
68 |
|
69 |
tts.tts_to_file(chat_response, speaker_wav = upload, language="en", file_path="output.wav")
|
70 |
|
71 |
+
rate, data = wavfile.read("output.wav")
|
72 |
+
|
73 |
+
reduced_noise = nr.reduce_noise(y=data, sr=rate, prop_decrease= 0.95, stationary=True)
|
74 |
+
#reduced_noise = nr.reduce_noise(y = data, sr=rate, prop_decrease= 0.85)
|
75 |
+
#reduced_noise = nr.reduce_noise(y = data, sr=rate, thresh_n_mult_nonstationary=2, stationary=False)
|
76 |
+
|
77 |
+
wavfile.write("audio1.wav", rate, reduced_noise)
|
78 |
|
79 |
enhance_model = SpectralMaskEnhancement.from_hparams(
|
80 |
source="speechbrain/metricgan-plus-voicebank",
|
|
|
83 |
)
|
84 |
|
85 |
noisy = enhance_model.load_audio(
|
86 |
+
"audio1.wav"
|
87 |
).unsqueeze(0)
|
88 |
|
89 |
enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
|
90 |
torchaudio.save("enhanced.wav", enhanced.cpu(), 16000)
|
91 |
|
92 |
+
return [result.text, chat_response, "enhanced.wav"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
output_1 = gr.Textbox(label="Speech to Text")
|
95 |
output_2 = gr.Textbox(label="ChatGPT Output")
|