Update app.py
Browse files
app.py
CHANGED
|
@@ -166,19 +166,19 @@ def translate_speech(audio_file, target_language):
|
|
| 166 |
def clear_history():
|
| 167 |
global conversation_history
|
| 168 |
conversation_history = []
|
| 169 |
-
return None, None
|
| 170 |
|
| 171 |
-
def
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
|
| 177 |
with gr.Blocks(css="style.css") as demo:
|
| 178 |
description = gr.Markdown("# <center><b>Hello, I am Optimus Prime your personal AI voice assistant</b></center>")
|
| 179 |
|
| 180 |
with gr.Tabs() as tabs:
|
| 181 |
-
with gr.TabItem("Voice Assistant"):
|
| 182 |
select = gr.Dropdown([
|
| 183 |
'Llama 3B Service',
|
| 184 |
'Mixtral 8x7B',
|
|
@@ -210,7 +210,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 210 |
live=True
|
| 211 |
)
|
| 212 |
|
| 213 |
-
with gr.TabItem("Speech Translation"):
|
| 214 |
input_audio = gr.Audio(label="User", sources="microphone", type="filepath", waveform_options=False)
|
| 215 |
target_lang = gr.Dropdown(
|
| 216 |
choices=list(LANGUAGE_CODES.keys()),
|
|
@@ -233,11 +233,12 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 233 |
clear_button.click(
|
| 234 |
fn=clear_history,
|
| 235 |
inputs=[],
|
| 236 |
-
outputs=[input, output],
|
| 237 |
api_name="clear"
|
| 238 |
)
|
| 239 |
|
| 240 |
-
|
|
|
|
| 241 |
|
| 242 |
if __name__ == "__main__":
|
| 243 |
demo.queue(max_size=200).launch()
|
|
|
|
| 166 |
def clear_history():
|
| 167 |
global conversation_history
|
| 168 |
conversation_history = []
|
| 169 |
+
return None, None, None, None
|
| 170 |
|
| 171 |
+
def voice_assistant_tab():
|
| 172 |
+
return "# <center><b>Hello, I am Optimus Prime your personal AI voice assistant</b></center>"
|
| 173 |
+
|
| 174 |
+
def speech_translation_tab():
|
| 175 |
+
return "# <center><b>Hear how you sound in another language</b></center>"
|
| 176 |
|
| 177 |
with gr.Blocks(css="style.css") as demo:
|
| 178 |
description = gr.Markdown("# <center><b>Hello, I am Optimus Prime your personal AI voice assistant</b></center>")
|
| 179 |
|
| 180 |
with gr.Tabs() as tabs:
|
| 181 |
+
with gr.TabItem("Voice Assistant") as voice_assistant:
|
| 182 |
select = gr.Dropdown([
|
| 183 |
'Llama 3B Service',
|
| 184 |
'Mixtral 8x7B',
|
|
|
|
| 210 |
live=True
|
| 211 |
)
|
| 212 |
|
| 213 |
+
with gr.TabItem("Speech Translation") as speech_translation:
|
| 214 |
input_audio = gr.Audio(label="User", sources="microphone", type="filepath", waveform_options=False)
|
| 215 |
target_lang = gr.Dropdown(
|
| 216 |
choices=list(LANGUAGE_CODES.keys()),
|
|
|
|
| 233 |
clear_button.click(
|
| 234 |
fn=clear_history,
|
| 235 |
inputs=[],
|
| 236 |
+
outputs=[input, output, input_audio, output_audio],
|
| 237 |
api_name="clear"
|
| 238 |
)
|
| 239 |
|
| 240 |
+
voice_assistant.select(fn=voice_assistant_tab, inputs=None, outputs=description)
|
| 241 |
+
speech_translation.select(fn=speech_translation_tab, inputs=None, outputs=description)
|
| 242 |
|
| 243 |
if __name__ == "__main__":
|
| 244 |
demo.queue(max_size=200).launch()
|