Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,21 +6,22 @@ from clearvoice import ClearVoice
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
-
def fn_clearvoice_sr(input_wav,
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
output_wav_dict = myClearVoice(input_path=input_wav, online_write=False)
|
| 17 |
if isinstance(output_wav_dict, dict):
|
| 18 |
key = next(iter(output_wav_dict))
|
| 19 |
output_wav = output_wav_dict[key]
|
| 20 |
else:
|
| 21 |
output_wav = output_wav_dict
|
| 22 |
-
sf.write('
|
| 23 |
-
return '
|
| 24 |
|
| 25 |
@spaces.GPU
|
| 26 |
def fn_clearvoice_se(input_wav, sr):
|
|
@@ -86,7 +87,7 @@ sr_demo = gr.Interface(
|
|
| 86 |
fn=fn_clearvoice_sr,
|
| 87 |
inputs = [
|
| 88 |
gr.Audio(label="Input Audio", type="filepath"),
|
| 89 |
-
gr.Checkbox(["Apply Enhancement"], label="Apply Speech Enhancement"),
|
| 90 |
],
|
| 91 |
outputs = [
|
| 92 |
gr.Audio(label="Output Audio", type="filepath"),
|
|
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
+
def fn_clearvoice_sr(input_wav, apply_se):
|
| 10 |
+
|
| 11 |
+
myClearVoice = ClearVoice(task='speech_super_resolution', model_names=['MossFormer2_SR_48K'])
|
| 12 |
+
fs = 48000
|
| 13 |
+
if apply_se:
|
| 14 |
+
myClearVoice_se = ClearVoice(task='speech_enhancement', model_names=['MossFormer2_SE_48K'])
|
| 15 |
+
output_wav_dict = myClearVoice_se(input_path=input_wav, online_write=True, output_path='enhanced.wav')
|
| 16 |
+
input_wav = 'enhanced.wav'
|
| 17 |
output_wav_dict = myClearVoice(input_path=input_wav, online_write=False)
|
| 18 |
if isinstance(output_wav_dict, dict):
|
| 19 |
key = next(iter(output_wav_dict))
|
| 20 |
output_wav = output_wav_dict[key]
|
| 21 |
else:
|
| 22 |
output_wav = output_wav_dict
|
| 23 |
+
sf.write('enhanced_high_res.wav', output_wav, fs)
|
| 24 |
+
return 'enhanced_high_res.wav'
|
| 25 |
|
| 26 |
@spaces.GPU
|
| 27 |
def fn_clearvoice_se(input_wav, sr):
|
|
|
|
| 87 |
fn=fn_clearvoice_sr,
|
| 88 |
inputs = [
|
| 89 |
gr.Audio(label="Input Audio", type="filepath"),
|
| 90 |
+
gr.Checkbox(["Apply Speech Enhancement"], label="Apply Speech Enhancement"),
|
| 91 |
],
|
| 92 |
outputs = [
|
| 93 |
gr.Audio(label="Output Audio", type="filepath"),
|