Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,24 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
# Load the model
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
)
|
| 8 |
|
| 9 |
# Launch the interface
|
|
|
|
| 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 = """
|
| 13 |
+
footer {visibility: hidden;}
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
# Create the Gradio interface
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
fn=transcribe, # Function to process input
|
| 19 |
+
inputs=gr.Audio(source="microphone", type="filepath"), # Take audio input
|
| 20 |
+
outputs="text", # Display output as text
|
| 21 |
+
css=custom_css # Hide the Gradio footer
|
| 22 |
)
|
| 23 |
|
| 24 |
# Launch the interface
|