projekt-rising-ai commited on
Commit
34e67ee
·
1 Parent(s): b27278a

Added debugging statements

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -412,9 +412,7 @@ class ChatWrapper:
412
  html_video, temp_file, html_audio, temp_aud_file = None, None, None, None
413
 
414
  if speak_text:
415
- print('speak_text branch')
416
  if talking_head:
417
- print('speak_text then talking_head branch')
418
  if len(output) <= MAX_TALKING_HEAD_TEXT_LENGTH:
419
  html_video, temp_file = do_html_video_speak(output, translate_to)
420
  else:
@@ -422,16 +420,12 @@ class ChatWrapper:
422
  html_video = create_html_video(temp_file, TALKING_HEAD_WIDTH)
423
  html_audio, temp_aud_file = do_html_audio_speak(output, translate_to)
424
  else:
425
- print('speak_text branch then no talking_head branch')
426
  html_audio, temp_aud_file = do_html_audio_speak(output, translate_to)
427
  else:
428
- print('no speak_text branch')
429
  if talking_head:
430
- print('no speak_text then talking_head branch')
431
  temp_file = LOOPING_TALKING_HEAD
432
  html_video = create_html_video(temp_file, TALKING_HEAD_WIDTH)
433
  else:
434
- print('np speak_text then no talking_head branch')
435
  # html_audio, temp_aud_file = do_html_audio_speak(output, translate_to)
436
  # html_video = create_html_video(temp_file, "128")
437
  pass
@@ -453,10 +447,11 @@ def do_html_audio_speak(words_to_speak, polly_language):
453
  aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
454
  region_name='eu-west-2'
455
  ).client('polly')
456
-
457
  # voice_id, language_code, engine = POLLY_VOICE_DATA.get_voice(polly_language, "Female")
458
  voice_id, language_code, engine = POLLY_VOICE_DATA.get_voice(polly_language, "Male")
459
  if not voice_id:
 
460
  # voice_id = "Joanna"
461
  voice_id = "Matthew"
462
  language_code = "en-US"
@@ -473,6 +468,7 @@ def do_html_audio_speak(words_to_speak, polly_language):
473
 
474
  # Save the audio stream returned by Amazon Polly on Lambda's temp directory
475
  if "AudioStream" in response:
 
476
  with closing(response["AudioStream"]) as stream:
477
  # output = os.path.join("/tmp/", "speech.mp3")
478
 
@@ -491,6 +487,7 @@ def do_html_audio_speak(words_to_speak, polly_language):
491
  print("Could not stream audio")
492
  return None, None
493
 
 
494
  return html_audio, "audios/tempfile.mp3"
495
 
496
 
 
412
  html_video, temp_file, html_audio, temp_aud_file = None, None, None, None
413
 
414
  if speak_text:
 
415
  if talking_head:
 
416
  if len(output) <= MAX_TALKING_HEAD_TEXT_LENGTH:
417
  html_video, temp_file = do_html_video_speak(output, translate_to)
418
  else:
 
420
  html_video = create_html_video(temp_file, TALKING_HEAD_WIDTH)
421
  html_audio, temp_aud_file = do_html_audio_speak(output, translate_to)
422
  else:
 
423
  html_audio, temp_aud_file = do_html_audio_speak(output, translate_to)
424
  else:
 
425
  if talking_head:
 
426
  temp_file = LOOPING_TALKING_HEAD
427
  html_video = create_html_video(temp_file, TALKING_HEAD_WIDTH)
428
  else:
 
429
  # html_audio, temp_aud_file = do_html_audio_speak(output, translate_to)
430
  # html_video = create_html_video(temp_file, "128")
431
  pass
 
447
  aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
448
  region_name='eu-west-2'
449
  ).client('polly')
450
+ print('Polly client initialised')
451
  # voice_id, language_code, engine = POLLY_VOICE_DATA.get_voice(polly_language, "Female")
452
  voice_id, language_code, engine = POLLY_VOICE_DATA.get_voice(polly_language, "Male")
453
  if not voice_id:
454
+ print('No voice data provided, using Matthew')
455
  # voice_id = "Joanna"
456
  voice_id = "Matthew"
457
  language_code = "en-US"
 
468
 
469
  # Save the audio stream returned by Amazon Polly on Lambda's temp directory
470
  if "AudioStream" in response:
471
+ print('AudioStream detected')
472
  with closing(response["AudioStream"]) as stream:
473
  # output = os.path.join("/tmp/", "speech.mp3")
474
 
 
487
  print("Could not stream audio")
488
  return None, None
489
 
490
+ print('Audio detected, exiting function')
491
  return html_audio, "audios/tempfile.mp3"
492
 
493