Spaces:
Runtime error
Runtime error
Update app.py
Browse fileschange language to chinese
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from utils import (TextGenerationPipeline, from_en_translation,
|
|
| 7 |
tts_to_bytesio)
|
| 8 |
|
| 9 |
max_answer_length = 100
|
| 10 |
-
desired_language = "
|
| 11 |
response_generator_pipe = TextGenerationPipeline(max_length=max_answer_length)
|
| 12 |
|
| 13 |
|
|
@@ -24,18 +24,18 @@ def main(audio: object) -> Tuple[str, str, str, object]:
|
|
| 24 |
tuple containing
|
| 25 |
|
| 26 |
- user_speech_text (str) : recognized speech
|
| 27 |
-
-
|
| 28 |
- bot_response_en (str) : bot's original answer
|
| 29 |
- html (object) : autoplayer for bot's speech
|
| 30 |
"""
|
| 31 |
user_speech_text = stt(audio, desired_language)
|
| 32 |
tranlated_text = to_en_translation(user_speech_text, desired_language)
|
| 33 |
bot_response_en = response_generator_pipe(tranlated_text)
|
| 34 |
-
|
| 35 |
bot_voice = tts(bot_response_de, desired_language)
|
| 36 |
bot_voice_bytes = tts_to_bytesio(bot_voice)
|
| 37 |
html = html_audio_autoplay(bot_voice_bytes)
|
| 38 |
-
return user_speech_text,
|
| 39 |
|
| 40 |
|
| 41 |
Interface(
|
|
@@ -47,7 +47,7 @@ Interface(
|
|
| 47 |
),
|
| 48 |
],
|
| 49 |
outputs=[
|
| 50 |
-
Textbox(label="You said: "),
|
| 51 |
Textbox(label="AI said: "),
|
| 52 |
Textbox(label="AI said (English): "),
|
| 53 |
"html",
|
|
|
|
| 7 |
tts_to_bytesio)
|
| 8 |
|
| 9 |
max_answer_length = 100
|
| 10 |
+
desired_language = "cn"
|
| 11 |
response_generator_pipe = TextGenerationPipeline(max_length=max_answer_length)
|
| 12 |
|
| 13 |
|
|
|
|
| 24 |
tuple containing
|
| 25 |
|
| 26 |
- user_speech_text (str) : recognized speech
|
| 27 |
+
- bot_response_cn (str) : translated answer of bot
|
| 28 |
- bot_response_en (str) : bot's original answer
|
| 29 |
- html (object) : autoplayer for bot's speech
|
| 30 |
"""
|
| 31 |
user_speech_text = stt(audio, desired_language)
|
| 32 |
tranlated_text = to_en_translation(user_speech_text, desired_language)
|
| 33 |
bot_response_en = response_generator_pipe(tranlated_text)
|
| 34 |
+
bot_response_cn = from_en_translation(bot_response_en, desired_language)
|
| 35 |
bot_voice = tts(bot_response_de, desired_language)
|
| 36 |
bot_voice_bytes = tts_to_bytesio(bot_voice)
|
| 37 |
html = html_audio_autoplay(bot_voice_bytes)
|
| 38 |
+
return user_speech_text, bot_response_cn, bot_response_en, html
|
| 39 |
|
| 40 |
|
| 41 |
Interface(
|
|
|
|
| 47 |
),
|
| 48 |
],
|
| 49 |
outputs=[
|
| 50 |
+
Textbox(label="You said(中文): "),
|
| 51 |
Textbox(label="AI said: "),
|
| 52 |
Textbox(label="AI said (English): "),
|
| 53 |
"html",
|