Ath commited on
Commit
dc524ae
·
verified ·
1 Parent(s): 4dff7ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -32,7 +32,7 @@ def chat_and_tts(user_input, history):
32
  response = chat_session.send_message(user_input)
33
  response_text = response.text
34
 
35
- print("Response from chat session:", response_text) # Add this line to check the response
36
 
37
  # Eleven Labs text-to-speech request payload
38
  payload = {
@@ -50,15 +50,17 @@ def chat_and_tts(user_input, history):
50
  # Make the request to Eleven Labs API
51
  tts_response = requests.post(eleven_labs_url, json=payload, headers=headers)
52
 
53
- print("TTS API response status code:", tts_response.status_code) # Add this line to check the status code
54
 
55
  # Check if the response is successful and save the audio content to a file
56
  if tts_response.status_code == 200:
57
  audio_path = 'response_audio.mp3'
58
  with open(audio_path, 'wb') as file:
59
  file.write(tts_response.content)
60
- print("Audio file saved successfully:", audio_path) # Add this line to check if audio file is saved
61
  else:
 
 
62
  audio_path = None
63
 
64
  # Update the chat history
 
32
  response = chat_session.send_message(user_input)
33
  response_text = response.text
34
 
35
+ print("Response from chat session:", response_text) # Debug response text
36
 
37
  # Eleven Labs text-to-speech request payload
38
  payload = {
 
50
  # Make the request to Eleven Labs API
51
  tts_response = requests.post(eleven_labs_url, json=payload, headers=headers)
52
 
53
+ print("TTS API response status code:", tts_response.status_code) # Debug status code
54
 
55
  # Check if the response is successful and save the audio content to a file
56
  if tts_response.status_code == 200:
57
  audio_path = 'response_audio.mp3'
58
  with open(audio_path, 'wb') as file:
59
  file.write(tts_response.content)
60
+ print("Audio file saved successfully:", audio_path) # Debug audio file path
61
  else:
62
+ print("Failed to generate audio. Status code:", tts_response.status_code)
63
+ print("Response:", tts_response.text)
64
  audio_path = None
65
 
66
  # Update the chat history