Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from nemo.collections.asr.models import
|
| 3 |
|
| 4 |
-
# Load the model
|
| 5 |
-
|
| 6 |
|
| 7 |
-
# Define
|
| 8 |
def transcribe_audio(audio):
|
| 9 |
# Perform transcription
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
batch_size=16 # Batch size for inference
|
| 13 |
-
)
|
| 14 |
-
return predicted_text[0]
|
| 15 |
|
| 16 |
-
# Interface with microphone input
|
| 17 |
inputs = gr.inputs.Microphone(label="Speak into the microphone")
|
| 18 |
outputs = gr.outputs.Textbox(label="Transcription")
|
| 19 |
-
title = "
|
| 20 |
description = "Transcribe speech from the microphone using the NeMo Canary ASR model."
|
| 21 |
interface = gr.Interface(transcribe_audio, inputs, outputs, title=title, description=description)
|
| 22 |
|
| 23 |
-
# Launch interface
|
| 24 |
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from nemo.collections.asr.models import ASRModel
|
| 3 |
|
| 4 |
+
# Load the ASR model
|
| 5 |
+
model = ASRModel.from_pretrained("nvidia/canary-1b")
|
| 6 |
|
| 7 |
+
# Define a function to transcribe audio from the microphone
|
| 8 |
def transcribe_audio(audio):
|
| 9 |
# Perform transcription
|
| 10 |
+
transcription = model.transcribe([audio])[0]
|
| 11 |
+
return transcription
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Interface with microphone input and text output
|
| 14 |
inputs = gr.inputs.Microphone(label="Speak into the microphone")
|
| 15 |
outputs = gr.outputs.Textbox(label="Transcription")
|
| 16 |
+
title = "Speech-to-Text Transcription"
|
| 17 |
description = "Transcribe speech from the microphone using the NeMo Canary ASR model."
|
| 18 |
interface = gr.Interface(transcribe_audio, inputs, outputs, title=title, description=description)
|
| 19 |
|
| 20 |
+
# Launch the interface
|
| 21 |
interface.launch()
|