Update app.py
Browse files
app.py
CHANGED
|
@@ -33,11 +33,15 @@ def generate_speech(name, input_text):
|
|
| 33 |
)
|
| 34 |
|
| 35 |
# Extract generated text (response by the assistant) from completion
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
# Append assistant's message to history
|
| 40 |
-
history_openai_format.append({"role": "assistant", "content":
|
| 41 |
|
| 42 |
# Use ElevenLabs TTS API settings and request for the latest assistant response
|
| 43 |
url = "https://api.elevenlabs.io/v1/text-to-speech/eIH76iW9yjOWnOKIkd6y/stream"
|
|
|
|
| 33 |
)
|
| 34 |
|
| 35 |
# Extract generated text (response by the assistant) from completion
|
| 36 |
+
message_content = completion.choices[0].message.content.strip()
|
| 37 |
+
|
| 38 |
+
# Remove "Johnny" from the beginning of the assistant's message if present
|
| 39 |
+
if message_content.lower().startswith("johnny"):
|
| 40 |
+
# Strip the leading "Johnny" from the message content
|
| 41 |
+
message_content = message_content[6:].strip()
|
| 42 |
|
| 43 |
# Append assistant's message to history
|
| 44 |
+
history_openai_format.append({"role": "assistant", "content": message_content})
|
| 45 |
|
| 46 |
# Use ElevenLabs TTS API settings and request for the latest assistant response
|
| 47 |
url = "https://api.elevenlabs.io/v1/text-to-speech/eIH76iW9yjOWnOKIkd6y/stream"
|