Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from speechbrain.pretrained import EncoderASR
|
| 4 |
+
import torchaudio
|
| 5 |
+
|
| 6 |
+
# Charger le modèle
|
| 7 |
+
asr_model = EncoderASR.from_hparams(source="speechbrain/asr-wav2vec2-dvoice-darija", savedir="tmp_model")
|
| 8 |
+
|
| 9 |
+
def transcribe(audio):
|
| 10 |
+
waveform, sample_rate = torchaudio.load(audio)
|
| 11 |
+
transcription = asr_model.transcribe_batch(waveform)
|
| 12 |
+
return transcription[0]
|
| 13 |
+
|
| 14 |
+
# Interface Gradio
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=transcribe,
|
| 17 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="Reconnaissance Vocale Darija",
|
| 20 |
+
description="Parlez en Darija et obtenez la transcription."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
iface.launch()
|