Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torchaudio
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from clearvoice import ClearVoice
|
| 5 |
+
|
| 6 |
+
myClearVoice = ClearVoice(task='speech_enhancement', model_names=['FRCRN_SE_16K'])
|
| 7 |
+
|
| 8 |
+
def fn_clearvoice(aud):
|
| 9 |
+
# Load and add fake batch dimension
|
| 10 |
+
"""
|
| 11 |
+
noisy = enhance_model.load_audio(
|
| 12 |
+
aud
|
| 13 |
+
).unsqueeze(0)
|
| 14 |
+
enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
|
| 15 |
+
"""
|
| 16 |
+
output_wav_dict = myClearVoice(input_path='input.wav', online_write=False)
|
| 17 |
+
key = next(iter(output_wav_dict))
|
| 18 |
+
output_wav = output_wav_dict[key]
|
| 19 |
+
torchaudio.save('enhanced.wav', output_wav.cpu(), 16000)
|
| 20 |
+
return 'enhanced.wav'
|
| 21 |
+
|
| 22 |
+
inputs = gr.Audio(sources=["upload"], label="Input Audio", type="filepath")
|
| 23 |
+
outputs = gr.Audio(label="Output Audio", type="filepath")
|
| 24 |
+
title = "ClearVoice"
|
| 25 |
+
description = "Gradio demo for Speech enhancement with ClearVoice. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
|
| 26 |
+
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2206.07293' target='_blank'>FRCRN: Boosting Feature Representation Using Frequency Recurrence for Monaural Speech Enhancement</a> | <a href='https://github.com/speechbrain/speechbrain' target='_blank'>Github Repo</a></p>"
|
| 27 |
+
examples = [
|
| 28 |
+
['input.wav']
|
| 29 |
+
]
|
| 30 |
+
gr.Interface(fn_clearvoice, inputs, outputs, title=title, description=description, article=article, examples=examples).launch()
|