File size: 825 Bytes
547a76d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
import nemo.collections.asr as nemo_asr

# Load the pretrained model
conformer_large = nemo_asr.models.ASRModel.from_pretrained("nguyenanh2803/stt_conformer_large_na")

# Define the transcription function
def transcribe_audio(audio):
    # audio is a tuple of (sample_rate, audio_data)
    sample_rate, audio_data = audio
    # Transcribe the audio file
    transcription = conformer_large.transcribe([audio_data])
    return transcription[0]

# Create the Gradio interface
interface = gr.Interface(
    fn=transcribe_audio, 
    inputs=gr.inputs.Audio(source="microphone", type="numpy", label="Speak or Upload an Audio File"), 
    outputs="text",
    title="Conformer Large ASR",
    description="Transcribe audio using NVIDIA NeMo's Conformer Large model."
)

# Launch the interface
interface.launch()