papasega commited on
Commit
b691b31
1 Parent(s): 3febd1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -19
app.py CHANGED
@@ -1,41 +1,46 @@
1
- # from speechbrain.inference.ASR import EncoderASR
2
- # import gradio as gr
3
 
4
- # model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
5
 
6
- # def transcribe(audio):
7
- # return model.transcribe_file(audio.name)
8
 
9
 
10
- # demo = gr.Interface(fn=transcribe, inputs="file", outputs="text",
11
- # title="Transcription automatique du wolof",
12
- # description="Ce modèle transcrit un fichier audio en wolof en texte en utilisant l'alphabet latin.",
13
- # input_label="Audio en wolof",
14
- # output_label="Transcription alphabet latin"
15
- # )
16
 
17
- # demo.launch()
18
 
19
 
20
  from speechbrain.inference.ASR import EncoderASR
21
  import gradio as gr
22
  import numpy as np
23
 
 
24
  model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
25
 
 
26
  def transcribe(audio):
27
  sr, y = audio
28
  y = y.astype(np.float32)
29
  y /= np.max(np.abs(y))
30
 
31
- return transcriber({"sampling_rate": sr, "raw": y})["text"]
 
32
 
33
-
34
- demo = gr.Interface(
35
- transcribe,
36
- gr.Audio(sources=["microphone"]),
37
- "text",
 
38
  )
39
 
40
- demo.launch()
 
41
 
 
1
+ # # from speechbrain.inference.ASR import EncoderASR
2
+ # # import gradio as gr
3
 
4
+ # # model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
5
 
6
+ # # def transcribe(audio):
7
+ # # return model.transcribe_file(audio.name)
8
 
9
 
10
+ # # demo = gr.Interface(fn=transcribe, inputs="file", outputs="text",
11
+ # # title="Transcription automatique du wolof",
12
+ # # description="Ce modèle transcrit un fichier audio en wolof en texte en utilisant l'alphabet latin.",
13
+ # # input_label="Audio en wolof",
14
+ # # output_label="Transcription alphabet latin"
15
+ # # )
16
 
17
+ # # demo.launch()
18
 
19
 
20
  from speechbrain.inference.ASR import EncoderASR
21
  import gradio as gr
22
  import numpy as np
23
 
24
+ # Charger le modèle pré-entraîné
25
  model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
26
 
27
+ # Définir la fonction de transcription
28
  def transcribe(audio):
29
  sr, y = audio
30
  y = y.astype(np.float32)
31
  y /= np.max(np.abs(y))
32
 
33
+ # Utiliser le modèle pour transcrire l'audio
34
+ return model.transcribe({"sampling_rate": sr, "raw": y})["text"]
35
 
36
+ # Créer l'interface Gradio avec le microphone et le téléchargement de fichier comme options d'entrée
37
+ asrdemo = gr.Interface(
38
+ title="Transcription audio en wolof latin by Papa Sega",
39
+ fn=transcribe,
40
+ inputs=gr.Audio(sources=["microphone", "upload"]),
41
+ outputs="text",
42
  )
43
 
44
+ # Lancer l'application Gradio
45
+ asrdemo.launch()
46