Commit
·
29a572d
1
Parent(s):
5eaa5a6
Update app.py
Browse files
app.py
CHANGED
@@ -613,9 +613,11 @@ def generate_story_and_speech(input_text, chatbot_role):
|
|
613 |
synthesized_speech = generate_speech_for_sentence(history_tuples, chatbot_role, story_text)
|
614 |
if synthesized_speech:
|
615 |
# Access the BytesIO object containing the WAV file and extract bytes
|
616 |
-
|
|
|
617 |
# Convert the speech audio bytes to base64 for JSON serialization
|
618 |
-
speech_audio_base64 = base64.b64encode(
|
|
|
619 |
|
620 |
return {"text": story_text.strip(), "audio": speech_audio_base64}
|
621 |
else:
|
|
|
613 |
synthesized_speech = generate_speech_for_sentence(history_tuples, chatbot_role, story_text)
|
614 |
if synthesized_speech:
|
615 |
# Access the BytesIO object containing the WAV file and extract bytes
|
616 |
+
speech_audio_bytes = synthesized_speech[1]["value"] # Assume speech audio is always in bytearray format
|
617 |
+
|
618 |
# Convert the speech audio bytes to base64 for JSON serialization
|
619 |
+
speech_audio_base64 = base64.b64encode(speech_audio_bytes).decode('utf8')
|
620 |
+
|
621 |
|
622 |
return {"text": story_text.strip(), "audio": speech_audio_base64}
|
623 |
else:
|