PhilSpiel commited on
Commit
70f9fdc
·
1 Parent(s): 698100a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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
- message_parts = completion.choices[0].message.content.split("\n")
37
- assistant_message = message_parts[-1].strip() # Get the last line which is the assistant's response
 
 
 
 
38
 
39
  # Append assistant's message to history
40
- history_openai_format.append({"role": "assistant", "content": assistant_message})
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"