Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
import nemo.collections.asr as nemo_asr
|
|
|
3 |
|
4 |
# Load the pre-trained Kabyle ASR model
|
5 |
asr_model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained("nvidia/stt_kab_conformer_transducer_large")
|
6 |
|
7 |
# Function to transcribe the audio input
|
8 |
def transcribe(audio):
|
9 |
-
#
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Create the Gradio interface with audio input and text output
|
13 |
iface = gr.Interface(fn=transcribe, inputs="audio", outputs="text")
|
|
|
1 |
import gradio as gr
|
2 |
import nemo.collections.asr as nemo_asr
|
3 |
+
import numpy as np
|
4 |
|
5 |
# Load the pre-trained Kabyle ASR model
|
6 |
asr_model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained("nvidia/stt_kab_conformer_transducer_large")
|
7 |
|
8 |
# Function to transcribe the audio input
|
9 |
def transcribe(audio):
|
10 |
+
# Extract audio data and sample rate
|
11 |
+
audio_data, sample_rate = audio
|
12 |
+
|
13 |
+
# Convert audio data to numpy array if it's not already
|
14 |
+
if isinstance(audio_data, np.ndarray):
|
15 |
+
audio_data = np.array(audio_data)
|
16 |
+
|
17 |
+
# Transcribe the audio
|
18 |
+
return asr_model.transcribe([audio_data])
|
19 |
|
20 |
# Create the Gradio interface with audio input and text output
|
21 |
iface = gr.Interface(fn=transcribe, inputs="audio", outputs="text")
|