Pijush2023 commited on
Commit
6ee7d54
·
verified ·
1 Parent(s): e039dfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -40
app.py CHANGED
@@ -312,57 +312,23 @@ def generate_answer(message, choice):
312
 
313
 
314
 
315
- # def bot(history, choice):
316
- # if not history:
317
- # return history
318
- # response, addresses = generate_answer(history[-1][0], choice)
319
- # history[-1][1] = ""
320
-
321
- # # Generate audio for the entire response in a separate thread
322
- # with concurrent.futures.ThreadPoolExecutor() as executor:
323
- # audio_future = executor.submit(generate_audio_elevenlabs, response)
324
-
325
- # for character in response:
326
- # history[-1][1] += character
327
- # time.sleep(0.05) # Adjust the speed of text appearance
328
- # yield history, None
329
-
330
- # audio_path = audio_future.result()
331
- # yield history, audio_path
332
-
333
  def bot(history, choice):
334
  if not history:
335
- return history, None, None
336
-
337
- message = history[-1][0]
338
- response, addresses = generate_answer(message, choice)
339
-
340
- # Update the history with the response
341
- history[-1][1] = response
342
 
343
  # Generate audio for the entire response in a separate thread
344
  with concurrent.futures.ThreadPoolExecutor() as executor:
345
  audio_future = executor.submit(generate_audio_elevenlabs, response)
346
 
347
- # Create generator for the response text
348
- response_text = ""
349
  for character in response:
350
- response_text += character
351
  time.sleep(0.05) # Adjust the speed of text appearance
352
- yield history, None, None
353
 
354
  audio_path = audio_future.result()
355
- yield history, audio_path, None
356
-
357
- # Ensure the map updates with new addresses
358
- if choice == "Conversational" and addresses:
359
- map_html = generate_map(addresses)
360
- yield history, audio_path, map_html
361
- else:
362
- yield history, audio_path, None
363
-
364
-
365
-
366
 
367
 
368
  def add_message(history, message):
 
312
 
313
 
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  def bot(history, choice):
316
  if not history:
317
+ return history
318
+ response, addresses = generate_answer(history[-1][0], choice)
319
+ history[-1][1] = ""
 
 
 
 
320
 
321
  # Generate audio for the entire response in a separate thread
322
  with concurrent.futures.ThreadPoolExecutor() as executor:
323
  audio_future = executor.submit(generate_audio_elevenlabs, response)
324
 
 
 
325
  for character in response:
326
+ history[-1][1] += character
327
  time.sleep(0.05) # Adjust the speed of text appearance
328
+ yield history, None
329
 
330
  audio_path = audio_future.result()
331
+ yield history, audio_path
 
 
 
 
 
 
 
 
 
 
332
 
333
 
334
  def add_message(history, message):