File size: 1,022 Bytes
5faa5d1
d67a990
bfc54a8
e7baf67
d67a990
 
 
34d644e
0819861
 
 
 
 
 
 
 
 
 
99753a5
45f3f4a
 
44bb1f7
45f3f4a
 
 
 
5749237
1041e83
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
27
28
29
from speechbrain.inference.ASR import EncoderASR
import gradio as gr
import numpy as np
import soundfile as sf

model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")

def transcribe(audio):
    if isinstance(audio, str):  # Si audio est un chemin de fichier
        return model.transcribe_file(audio)
    else:  # Si audio est un tuple (cas du microphone)
        sr, y = audio
        y = y.astype(np.float32)
        y /= np.max(np.abs(y))
        # Enregistrer temporairement l'audio pour utiliser la méthode transcribe_file
        temp_file = 'temp.wav'
        sf.write(temp_file, y, sr)
        return model.transcribe_file(temp_file)

demo = gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(sources=["microphone", "upload"], label="Audio en wolof"),
    outputs=gr.Textbox(label="Transcription alphabet latin"),
    title="Transcription audio en wolof latin by PSW",
    description="Ce modèle transcrit un fichier audio en wolof en texte en utilisant l'alphabet latin."
)

demo.launch()