File size: 1,048 Bytes
89d2839
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5faa5d1
d67a990
 
 
 
34d644e
 
9876963
 
 
34d644e
 
d67a990
89d2839
5111bf2
34d644e
 
89d2839
d67a990
89d2839
5749237
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
30
31
32
33
34
35
36
37
38
39
40
41
# from speechbrain.inference.ASR import EncoderASR
# import gradio as gr

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

# def transcribe(audio):
#   return model.transcribe_file(audio.name)


# demo = gr.Interface(fn=transcribe, inputs="file", outputs="text", 
#                    title="Transcription automatique du wolof", 
#              description="Ce modèle transcrit un fichier audio en wolof en texte en utilisant l'alphabet latin.",              
#              input_label="Audio en wolof", 
#              output_label="Transcription alphabet latin"
#                    )

# demo.launch()


from speechbrain.inference.ASR import EncoderASR
import gradio as gr

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

def transcribe(audio):
    sr, y = audio
    y = y.astype(np.float32)
    y /= np.max(np.abs(y))

    return transcriber({"sampling_rate": sr, "raw": y})["text"]


demo = gr.Interface(
    transcribe,
    gr.Audio(sources=["microphone"]),
    "text",
)

demo.launch()