Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -203,15 +203,19 @@ def generate_audio_elevenlabs(text):
|
|
203 |
|
204 |
def handle_mode_selection(mode, chat_history, question):
|
205 |
if mode == "Normal Chatbot":
|
|
|
206 |
response = get_response(question)
|
207 |
chat_history.append((question, response))
|
208 |
return chat_history, "", None
|
209 |
elif mode == "Voice to Voice Conversation":
|
210 |
-
|
211 |
-
|
|
|
|
|
212 |
return chat_history, "", audio_path
|
213 |
|
214 |
|
|
|
215 |
# Function to add a user's message to the chat history and clear the input box
|
216 |
def add_message(history, message):
|
217 |
if message.strip():
|
|
|
203 |
|
204 |
def handle_mode_selection(mode, chat_history, question):
|
205 |
if mode == "Normal Chatbot":
|
206 |
+
# Normal chatbot mode: Show the response in the chatbot output
|
207 |
response = get_response(question)
|
208 |
chat_history.append((question, response))
|
209 |
return chat_history, "", None
|
210 |
elif mode == "Voice to Voice Conversation":
|
211 |
+
# Voice to Voice mode: Generate the response using Eleven Labs and return audio without showing text
|
212 |
+
response = get_response(question) # Get the response text (can be omitted if not needed for debugging)
|
213 |
+
audio_path = generate_audio_elevenlabs(response) # Convert the response to audio
|
214 |
+
chat_history.append((question, "[Voice Response]")) # Log that a voice response was generated (optional)
|
215 |
return chat_history, "", audio_path
|
216 |
|
217 |
|
218 |
+
|
219 |
# Function to add a user's message to the chat history and clear the input box
|
220 |
def add_message(history, message):
|
221 |
if message.strip():
|