Shokoufehhh commited on
Commit
788e6fb
·
verified ·
1 Parent(s): 6625621

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,16 +1,16 @@
1
  import gradio as gr
2
- import torch
3
 
4
- # Load the model
5
- model = torch.hub.load("speechbrain/metricgan-plus-voicebank", "enhance")
6
 
7
- # Define the function to pass audio through the model
8
- def enhance_speech(audio):
9
- # Process the audio file through the loaded model
10
- enhanced_audio = model(audio)
11
  return enhanced_audio
12
 
13
- # Create Gradio Interface
14
  iface = gr.Interface(
15
  fn=enhance_speech,
16
  inputs=gr.Audio(source="upload", type="filepath"),
@@ -18,5 +18,5 @@ iface = gr.Interface(
18
  title="Speech Enhancement"
19
  )
20
 
21
- # Launch the interface
22
  iface.launch()
 
1
  import gradio as gr
2
+ from speechbrain.pretrained import MetricGAN
3
 
4
+ # Load the MetricGAN model from Hugging Face
5
+ model = MetricGAN.from_hparams(source="speechbrain/metricgan-plus-voicebank")
6
 
7
+ # Define a function to enhance speech
8
+ def enhance_speech(audio_path):
9
+ # Process the uploaded audio file through the model
10
+ enhanced_audio = model.enhance(audio_path)
11
  return enhanced_audio
12
 
13
+ # Set up the Gradio interface
14
  iface = gr.Interface(
15
  fn=enhance_speech,
16
  inputs=gr.Audio(source="upload", type="filepath"),
 
18
  title="Speech Enhancement"
19
  )
20
 
21
+ # Launch the Gradio interface
22
  iface.launch()