Mojobones commited on
Commit
0195c4d
1 Parent(s): 6116f95

Create new file

Browse files
Files changed (1) hide show
  1. app.py +25 -0
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")
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 = "Gradio 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' target='_blank'>Attention is All You Need in Speech Separation</a> | <a href='https://github.com/speechbrain/speechbrain/tree/develop/recipes/WSJ0Mix/separation' '_blank'>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()