Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -146,6 +146,24 @@ def extract_location_from_response(response):
|
|
146 |
# return history, addresses
|
147 |
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
def bot(history, choice):
|
150 |
if not history:
|
151 |
return history
|
@@ -162,8 +180,7 @@ def bot(history, choice):
|
|
162 |
yield history, None
|
163 |
|
164 |
audio_path = audio_future.result()
|
165 |
-
yield history, audio_path
|
166 |
-
|
167 |
|
168 |
def add_message(history, message):
|
169 |
history.append((message, None))
|
@@ -502,14 +519,21 @@ def update_map_with_response(history):
|
|
502 |
def clear_textbox():
|
503 |
return ""
|
504 |
|
505 |
-
def show_map_if_details(history,choice):
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
if choice in ["Details", "Conversational"]:
|
507 |
-
|
|
|
|
|
508 |
else:
|
509 |
return gr.update(visible(False), "")
|
510 |
|
511 |
|
512 |
-
|
513 |
def generate_audio_elevenlabs(text):
|
514 |
XI_API_KEY = os.environ['ELEVENLABS_API']
|
515 |
VOICE_ID = 'SHZHI20rSPDR3iE8SvZ0' # Replace with your voice ID
|
|
|
146 |
# return history, addresses
|
147 |
|
148 |
|
149 |
+
# def bot(history, choice):
|
150 |
+
# if not history:
|
151 |
+
# return history
|
152 |
+
# response, addresses = generate_answer(history[-1][0], choice)
|
153 |
+
# history[-1][1] = ""
|
154 |
+
|
155 |
+
# # Generate audio for the entire response in a separate thread
|
156 |
+
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
157 |
+
# audio_future = executor.submit(generate_audio_elevenlabs, response)
|
158 |
+
|
159 |
+
# for character in response:
|
160 |
+
# history[-1][1] += character
|
161 |
+
# time.sleep(0.05) # Adjust the speed of text appearance
|
162 |
+
# yield history, None
|
163 |
+
|
164 |
+
# audio_path = audio_future.result()
|
165 |
+
# yield history, audio_path
|
166 |
+
|
167 |
def bot(history, choice):
|
168 |
if not history:
|
169 |
return history
|
|
|
180 |
yield history, None
|
181 |
|
182 |
audio_path = audio_future.result()
|
183 |
+
yield history, audio_path, addresses
|
|
|
184 |
|
185 |
def add_message(history, message):
|
186 |
history.append((message, None))
|
|
|
519 |
def clear_textbox():
|
520 |
return ""
|
521 |
|
522 |
+
# def show_map_if_details(history,choice):
|
523 |
+
# if choice in ["Details", "Conversational"]:
|
524 |
+
# return gr.update(visible=True), update_map_with_response(history)
|
525 |
+
# else:
|
526 |
+
# return gr.update(visible(False), "")
|
527 |
+
|
528 |
+
def show_map_if_details(history, choice):
|
529 |
if choice in ["Details", "Conversational"]:
|
530 |
+
addresses = history[-1][2] if len(history[-1]) > 2 else []
|
531 |
+
map_html = update_map_with_response(history, addresses)
|
532 |
+
return gr.update(visible=True), map_html
|
533 |
else:
|
534 |
return gr.update(visible(False), "")
|
535 |
|
536 |
|
|
|
537 |
def generate_audio_elevenlabs(text):
|
538 |
XI_API_KEY = os.environ['ELEVENLABS_API']
|
539 |
VOICE_ID = 'SHZHI20rSPDR3iE8SvZ0' # Replace with your voice ID
|