Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,17 +18,17 @@ transcriber = pipeline("automatic-speech-recognition", model="tarteel-ai/whisper
|
|
| 18 |
# Initialisation du traducteur
|
| 19 |
translator = Translator()
|
| 20 |
|
| 21 |
-
def transcribe_and_translate(audio):
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
# # Création de l'interface Gradio
|
| 34 |
# demo = gr.Interface(
|
|
@@ -46,6 +46,21 @@ def transcribe_and_translate(audio):
|
|
| 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.Textbox(label="Texte en Arabe")
|
|
|
|
| 18 |
# Initialisation du traducteur
|
| 19 |
translator = Translator()
|
| 20 |
|
| 21 |
+
# def transcribe_and_translate(audio):
|
| 22 |
+
# sr, y = audio
|
| 23 |
+
# y = y.astype(np.float32)
|
| 24 |
+
# y /= np.max(np.abs(y))
|
| 25 |
|
| 26 |
+
# # Transcription du texte
|
| 27 |
+
# transcription = transcriber({"sampling_rate": sr, "raw": y})["text"]
|
| 28 |
+
# time.sleep(2)
|
| 29 |
+
# # Traduction du texte transcrit
|
| 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(
|
|
|
|
| 46 |
# demo.launch(show_error=True, share=True)
|
| 47 |
|
| 48 |
|
| 49 |
+
def transcribe(audio):
|
| 50 |
+
sr, y = audio
|
| 51 |
+
y = y.astype(np.float32)
|
| 52 |
+
y /= np.max(np.abs(y))
|
| 53 |
+
|
| 54 |
+
# Transcription du texte
|
| 55 |
+
transcription = transcriber({"sampling_rate": sr, "raw": y})["text"]
|
| 56 |
+
return transcription
|
| 57 |
+
|
| 58 |
+
def translate(transcription):
|
| 59 |
+
# Traduction du texte transcrit
|
| 60 |
+
translation = translator.translate(transcription, src='ar', dest='fr').text
|
| 61 |
+
return translation
|
| 62 |
+
|
| 63 |
+
|
| 64 |
# Création de l'interface Gradio
|
| 65 |
audio_input = gr.Audio(sources=["microphone"], label="Enregistrement Audio")
|
| 66 |
transcription_output = gr.Textbox(label="Texte en Arabe")
|