File size: 649 Bytes
c3ad381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import torch
from speechbrain.pretrained import EncoderASR
import torchaudio

# Charger le modèle
asr_model = EncoderASR.from_hparams(source="speechbrain/asr-wav2vec2-dvoice-darija", savedir="tmp_model")

def transcribe(audio):
    waveform, sample_rate = torchaudio.load(audio)
    transcription = asr_model.transcribe_batch(waveform)
    return transcription[0]

# Interface Gradio
iface = gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(source="microphone", type="filepath"),
    outputs="text",
    title="Reconnaissance Vocale Darija",
    description="Parlez en Darija et obtenez la transcription."
)

iface.launch()