papasega commited on
Commit
1041e83
1 Parent(s): fe9b085

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -40
app.py CHANGED
@@ -1,50 +1,17 @@
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
  def transcribe(audio):
37
  return model.transcribe_file(audio.name)
38
 
39
 
40
- # Créer l'interface Gradio avec le microphone et le téléchargement de fichier comme options d'entrée
41
- asrdemo = gr.Interface(
42
- title="Transcription audio en wolof latin by Papa Sega",
43
- fn=transcribe,
44
- inputs=gr.Audio(sources=["microphone", "upload"]),
45
- outputs="text",
46
- )
47
-
48
- # Lancer l'application Gradio
49
- asrdemo.launch()
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()