debal commited on
Commit
9d32fd7
·
verified ·
1 Parent(s): d2cdadd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1,3 +1,25 @@
 
 
1
  import gradio as gr
2
 
3
- gr.load("models/speechbrain/sepformer-wham16k-enhancement").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-wham16k-enhancement", savedir='pretrained_models/sepformer-wham16k-enhancement')
6
+
7
+ def speechbrain(aud):
8
+
9
+
10
+ # for custom file, change path
11
+ est_sources = model.separate_file(path=aud)
12
+ torchaudio.save("enhanced_wham16k.wav", est_sources[:, :, 0].detach().cpu(), 16000)
13
+ return "enhanced_wham16k.wav"
14
+
15
+ inputs = gr.inputs.Audio(label="Input Audio", type="filepath")
16
+ outputs = [
17
+ gr.outputs.Audio(label="Output Audio", type="filepath"),
18
+ ]
19
+
20
+ title = "Speech Enhancer"
21
+ description = "Gradio demo for Speech Enhance by SpeechBrain. To use it, simply upload your audio, or click one of the examples to load them"
22
+ examples = [
23
+ ['example_wham16k.wav']
24
+ ]
25
+ gr.Interface(speechbrain, inputs, outputs, title=title, description=description, article=article, examples=examples).launch()