Spaces:
Sleeping
Sleeping
Commit
Β·
27afca3
1
Parent(s):
38fd5f7
add clear history button
Browse files
app.py
CHANGED
|
@@ -80,6 +80,12 @@ def transcribe(audio, past_history):
|
|
| 80 |
# Return the full conversation history
|
| 81 |
return "response.mp3", formatted_history
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
with gr.Blocks() as demo:
|
| 84 |
gr.HTML("<center><h1>Friday: AI Virtual Assistant π€</h1><center>")
|
| 85 |
|
|
@@ -87,12 +93,15 @@ with gr.Blocks() as demo:
|
|
| 87 |
audio_input = gr.Audio(label="Human", sources="microphone")
|
| 88 |
output_audio = gr.Audio(label="Friday", type="filepath", interactive=False, autoplay=True, elem_classes="audio")
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
|
| 92 |
# Textbox to display the full conversation history
|
| 93 |
transcription_box = gr.Textbox(label="Transcription", lines=10, placeholder="Conversation History...")
|
| 94 |
|
| 95 |
-
|
|
|
|
| 96 |
|
| 97 |
if __name__ == "__main__":
|
| 98 |
demo.queue()
|
|
|
|
| 80 |
# Return the full conversation history
|
| 81 |
return "response.mp3", formatted_history
|
| 82 |
|
| 83 |
+
def clear_history(formatted_history):
|
| 84 |
+
instruct_history = ""
|
| 85 |
+
instruct_history += system_prompt
|
| 86 |
+
formatted_history = ""
|
| 87 |
+
return formatted_history
|
| 88 |
+
|
| 89 |
with gr.Blocks() as demo:
|
| 90 |
gr.HTML("<center><h1>Friday: AI Virtual Assistant π€</h1><center>")
|
| 91 |
|
|
|
|
| 93 |
audio_input = gr.Audio(label="Human", sources="microphone")
|
| 94 |
output_audio = gr.Audio(label="Friday", type="filepath", interactive=False, autoplay=True, elem_classes="audio")
|
| 95 |
|
| 96 |
+
with gr.Row():
|
| 97 |
+
send_btn = gr.Button("π Send")
|
| 98 |
+
clear_btn = gr.Button("ποΈ Clear")
|
| 99 |
|
| 100 |
# Textbox to display the full conversation history
|
| 101 |
transcription_box = gr.Textbox(label="Transcription", lines=10, placeholder="Conversation History...")
|
| 102 |
|
| 103 |
+
send_btn.click(fn=transcribe, inputs=[audio_input, transcription_box], outputs=[output_audio, transcription_box])
|
| 104 |
+
clear_btn.click(fn=clear_history, inputs=[transcription_box], outputs=[transcription_box])
|
| 105 |
|
| 106 |
if __name__ == "__main__":
|
| 107 |
demo.queue()
|