Geek7 commited on
Commit
dd39c7c
·
verified ·
1 Parent(s): 9e29bb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -1,12 +1,18 @@
1
  import gradio as gr
2
- from transformers import pipeline
 
3
 
4
- # Load the model separately
5
- model = pipeline("automatic-speech-recognition", model="speechbrain/mtl-mimic-voicebank")
6
 
7
- # Define a function to make predictions using the loaded model
8
  def transcribe(audio):
9
- return model(audio)["text"]
 
 
 
 
 
10
 
11
  # Define a CSS string to hide the footer
12
  custom_css = """
 
1
  import gradio as gr
2
+ import torchaudio
3
+ from speechbrain.pretrained import EncoderClassifier
4
 
5
+ # Load the SpeechBrain model separately
6
+ model = EncoderClassifier.from_hparams(source="speechbrain/mtl-mimic-voicebank", savedir="tmp")
7
 
8
+ # Define the function to transcribe audio
9
  def transcribe(audio):
10
+ # Load and process the audio file using torchaudio
11
+ signal, rate = torchaudio.load(audio)
12
+
13
+ # Make predictions using the SpeechBrain model
14
+ output = model.classify_batch(signal)
15
+ return output
16
 
17
  # Define a CSS string to hide the footer
18
  custom_css = """