Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import numpy as np
|
|
8 |
# Initialize the conversation history globally
|
9 |
conversation_history = []
|
10 |
|
11 |
-
@spaces.GPU(duration=
|
12 |
def transcribe_and_respond(audio_file, chat_history):
|
13 |
try:
|
14 |
pipe = transformers.pipeline(
|
@@ -51,23 +51,24 @@ def transcribe_and_respond(audio_file, chat_history):
|
|
51 |
return chat_history_for_display, turns # Return the formatted chat history for display and the updated history
|
52 |
|
53 |
except Exception as e:
|
54 |
-
return f"Error: {str(e)}"
|
55 |
|
56 |
# Define the Gradio interface
|
57 |
iface = gr.Interface(
|
58 |
fn=transcribe_and_respond,
|
59 |
inputs=[
|
60 |
-
gr.Audio(
|
61 |
gr.State([]) # Hidden state to maintain conversation history
|
62 |
],
|
63 |
outputs=[
|
64 |
gr.Chatbot(label="Conversation History"), # Display the conversation
|
65 |
gr.State([]) # Hidden state to keep track of the updated conversation history
|
66 |
],
|
67 |
-
title="
|
68 |
-
description="
|
69 |
-
live=True,
|
70 |
allow_flagging="auto",
|
|
|
71 |
)
|
72 |
|
73 |
if __name__ == "__main__":
|
|
|
8 |
# Initialize the conversation history globally
|
9 |
conversation_history = []
|
10 |
|
11 |
+
@spaces.GPU(duration=120)
|
12 |
def transcribe_and_respond(audio_file, chat_history):
|
13 |
try:
|
14 |
pipe = transformers.pipeline(
|
|
|
51 |
return chat_history_for_display, turns # Return the formatted chat history for display and the updated history
|
52 |
|
53 |
except Exception as e:
|
54 |
+
return f"Error: {str(e)}", chat_history # Ensure history is returned even on error
|
55 |
|
56 |
# Define the Gradio interface
|
57 |
iface = gr.Interface(
|
58 |
fn=transcribe_and_respond,
|
59 |
inputs=[
|
60 |
+
gr.Audio(source="microphone", type="filepath", label="Your Audio (Microphone)"),
|
61 |
gr.State([]) # Hidden state to maintain conversation history
|
62 |
],
|
63 |
outputs=[
|
64 |
gr.Chatbot(label="Conversation History"), # Display the conversation
|
65 |
gr.State([]) # Hidden state to keep track of the updated conversation history
|
66 |
],
|
67 |
+
title="Shuka demo",
|
68 |
+
description="shuka live demo",
|
69 |
+
live=True, # Enable live mode for real-time interaction
|
70 |
allow_flagging="auto",
|
71 |
+
# enable_queue=True
|
72 |
)
|
73 |
|
74 |
if __name__ == "__main__":
|