Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from googletrans import Translator
|
| 3 |
from transformers import pipeline
|
| 4 |
import tempfile
|
| 5 |
import edge_tts
|
| 6 |
import inflect
|
| 7 |
|
| 8 |
-
translator = Translator()
|
| 9 |
number_to_word = inflect.engine()
|
| 10 |
|
| 11 |
# Modèle de langue français
|
|
@@ -19,12 +17,8 @@ async def transcribe(audio):
|
|
| 19 |
|
| 20 |
async def respond(audio):
|
| 21 |
user = await transcribe(audio)
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
reply = model(user_fr, max_length=50, num_return_sequences=1)[0]['generated_text']
|
| 25 |
-
# Traduire la réponse en anglais
|
| 26 |
-
reply_en = translator.translate(reply, src='fr', dest='en').text
|
| 27 |
-
communicate = edge_tts.Communicate(reply_en)
|
| 28 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 29 |
tmp_path = tmp_file.name
|
| 30 |
await communicate.save(tmp_path)
|
|
@@ -84,7 +78,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 84 |
outputs=output_audio, api_name=False)
|
| 85 |
gr.Markdown(FAST)
|
| 86 |
with gr.Row():
|
| 87 |
-
user_input = gr.Textbox(label="Prompt", value="
|
| 88 |
input_text = gr.Textbox(label="Input Text", elem_id="important")
|
| 89 |
output_audio = gr.Audio(label="JARVIS", type="filepath",
|
| 90 |
interactive=False,
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
import tempfile
|
| 4 |
import edge_tts
|
| 5 |
import inflect
|
| 6 |
|
|
|
|
| 7 |
number_to_word = inflect.engine()
|
| 8 |
|
| 9 |
# Modèle de langue français
|
|
|
|
| 17 |
|
| 18 |
async def respond(audio):
|
| 19 |
user = await transcribe(audio)
|
| 20 |
+
reply = model(user, max_length=50, num_return_sequences=1)[0]['generated_text']
|
| 21 |
+
communicate = edge_tts.Communicate(reply)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 23 |
tmp_path = tmp_file.name
|
| 24 |
await communicate.save(tmp_path)
|
|
|
|
| 78 |
outputs=output_audio, api_name=False)
|
| 79 |
gr.Markdown(FAST)
|
| 80 |
with gr.Row():
|
| 81 |
+
user_input = gr.Textbox(label="Prompt", value="Qu'est-ce que Wikipedia")
|
| 82 |
input_text = gr.Textbox(label="Input Text", elem_id="important")
|
| 83 |
output_audio = gr.Audio(label="JARVIS", type="filepath",
|
| 84 |
interactive=False,
|