Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -100,7 +100,20 @@ def response(state: AppState):
|
|
100 |
)
|
101 |
segment.export(audio_buffer, format="wav")
|
102 |
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
def set_api_key(api_key, state):
|
106 |
if not api_key:
|
|
|
100 |
)
|
101 |
segment.export(audio_buffer, format="wav")
|
102 |
|
103 |
+
generator = generate_response_and_audio(audio_buffer.getvalue(), state)
|
104 |
+
|
105 |
+
# Process the generator to get the final results
|
106 |
+
final_text = ""
|
107 |
+
final_audio = None
|
108 |
+
for text, audio, updated_state in generator:
|
109 |
+
final_text = text if text else final_text
|
110 |
+
final_audio = audio if audio else final_audio
|
111 |
+
state = updated_state
|
112 |
+
|
113 |
+
# Update the chatbot with the final conversation
|
114 |
+
chatbot_output = state.conversation[-2:] # Get the last two messages (user input and AI response)
|
115 |
+
|
116 |
+
return chatbot_output, final_audio, state
|
117 |
|
118 |
def set_api_key(api_key, state):
|
119 |
if not api_key:
|