camanalo1 commited on
Commit
63033c7
·
1 Parent(s): d70e1b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -1,24 +1,21 @@
1
  import gradio as gr
2
- from nemo.collections.asr.models import EncDecMultiTaskModel
3
 
4
- # Load the model
5
- canary_model = EncDecMultiTaskModel.from_pretrained('nvidia/canary-1b')
6
 
7
- # Define ASR function
8
  def transcribe_audio(audio):
9
  # Perform transcription
10
- predicted_text = canary_model.transcribe(
11
- paths2audio_files=[audio.name],
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 = "Canary ASR"
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()