Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ setattr(httpcore, 'SyncHTTPTransport', object)
|
|
10 |
|
11 |
# Initialisation du modèle de transcription
|
12 |
#transcriber = pipeline("automatic-speech-recognition", model="jonatasgrosman/wav2vec2-large-xlsr-53-arabic")
|
13 |
-
|
14 |
-
|
15 |
|
16 |
|
17 |
|
@@ -30,17 +30,47 @@ def transcribe_and_translate(audio):
|
|
30 |
translation = translator.translate(transcription, src='ar', dest='fr').text
|
31 |
return transcription, translation
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# Création de l'interface Gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
demo = gr.Interface(
|
35 |
-
fn=
|
36 |
-
inputs=
|
37 |
-
outputs=[
|
38 |
-
|
39 |
-
|
40 |
-
],
|
41 |
-
title="Transcription automatiques de l'Arabe et traduction en Français by PSW",
|
42 |
-
description="Utilisez le microphone pour parler en arabe, puis appuyez sur le bouton stop et Submit pour voir la transcription et la traduction."
|
43 |
)
|
44 |
|
45 |
# Lancement de l'application Gradio
|
46 |
-
demo.launch(show_error=True, share=True)
|
|
|
10 |
|
11 |
# Initialisation du modèle de transcription
|
12 |
#transcriber = pipeline("automatic-speech-recognition", model="jonatasgrosman/wav2vec2-large-xlsr-53-arabic")
|
13 |
+
transcriber = pipeline("automatic-speech-recognition", model="tarteel-ai/whisper-base-ar-quran")
|
14 |
+
|
15 |
|
16 |
|
17 |
|
|
|
30 |
translation = translator.translate(transcription, src='ar', dest='fr').text
|
31 |
return transcription, translation
|
32 |
|
33 |
+
# # Création de l'interface Gradio
|
34 |
+
# demo = gr.Interface(
|
35 |
+
# fn=transcribe_and_translate,
|
36 |
+
# inputs=gr.Audio(sources=["microphone"], label="Enregistrement Audio"),
|
37 |
+
# outputs=[
|
38 |
+
# gr.Textbox(label="Texte en Arabe"),
|
39 |
+
# gr.Textbox(label="Traduction en Français")
|
40 |
+
# ],
|
41 |
+
# title="Transcription automatiques de l'Arabe et traduction en Français by PSW",
|
42 |
+
# description="Utilisez le microphone pour parler en arabe, puis appuyez sur le bouton stop et Submit pour voir la transcription et la traduction."
|
43 |
+
# )
|
44 |
+
|
45 |
+
# # Lancement de l'application Gradio
|
46 |
+
# demo.launch(show_error=True, share=True)
|
47 |
+
|
48 |
+
|
49 |
# Création de l'interface Gradio
|
50 |
+
audio_input = gr.Audio(sources=["microphone"], label="Enregistrement Audio")
|
51 |
+
transcription_output = gr.Output(label="Texte en Arabe")
|
52 |
+
translation_output = gr.Output(label="Traduction en Français")
|
53 |
+
|
54 |
+
def process_audio(audio):
|
55 |
+
# Transcription
|
56 |
+
transcription = transcribe(audio)
|
57 |
+
# Afficher la transcription
|
58 |
+
with transcription_output:
|
59 |
+
print("Transcription:", transcription)
|
60 |
+
# Traduction après la transcription
|
61 |
+
translation = translate(transcription)
|
62 |
+
# Afficher la traduction
|
63 |
+
with translation_output:
|
64 |
+
print("Traduction:", translation)
|
65 |
+
|
66 |
+
# Interface Gradio
|
67 |
demo = gr.Interface(
|
68 |
+
fn=process_audio,
|
69 |
+
inputs=audio_input,
|
70 |
+
outputs=[transcription_output, translation_output],
|
71 |
+
title="Transcription et Traduction Automatiques de l'Arabe en Français",
|
72 |
+
description="Utilisez le microphone pour parler en arabe, puis appuyez sur le bouton pour voir la transcription et la traduction."
|
|
|
|
|
|
|
73 |
)
|
74 |
|
75 |
# Lancement de l'application Gradio
|
76 |
+
demo.launch(show_error=True, share=True)
|