Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
·
cc88ae6
1
Parent(s):
1b17be5
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from speechbrain.pretrained import SepformerSeparation as separator
|
| 2 |
+
import torchaudio
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
model = separator.from_hparams(source="speechbrain/sepformer-wsj02mix", savedir='pretrained_models/sepformer-wsj02mix')
|
| 6 |
+
|
| 7 |
+
def speechbrain(aud):
|
| 8 |
+
est_sources = model.separate_file(path=aud.name)
|
| 9 |
+
torchaudio.save("source1hat.wav", est_sources[:, :, 0].detach().cpu(), 8000)
|
| 10 |
+
torchaudio.save("source2hat.wav", est_sources[:, :, 1].detach().cpu(), 8000)
|
| 11 |
+
return "source1hat.wav", "source2hat.wav"
|
| 12 |
+
|
| 13 |
+
inputs = gr.inputs.Audio(label="Input Audio", type="file")
|
| 14 |
+
outputs = [
|
| 15 |
+
gr.outputs.Audio(label="Output Audio One", type="file"),
|
| 16 |
+
gr.outputs.Audio(label="Output Audio Two", type="file")
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
title = "Speech Seperation"
|
| 20 |
+
description = "demo for Speech Seperation by SpeechBrain. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
|
| 21 |
+
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2010.13154'>Attention is All You Need in Speech Separation</a> | <a href='https://github.com/speechbrain/speechbrain/tree/develop/recipes/WSJ0Mix/separation'>Github Repo</a></p>"
|
| 22 |
+
examples = [
|
| 23 |
+
['samples/audio_samples/test_mixture.wav']
|
| 24 |
+
]
|
| 25 |
+
gr.Interface(speechbrain, inputs, outputs, title=title, description=description, article=article, examples=examples).launch()
|