SaileshSivan commited on
Commit
d3b0511
·
1 Parent(s): 44b3eba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -85,13 +85,17 @@ if submit:
85
 
86
  st.write(response)
87
  # Text-to-speech
88
- audio_response = openai.Audio.create(
89
- engine="tts-1",
90
- text=response,
91
  voice="alloy",
 
92
  )
 
 
 
 
93
  # Embed audio in the webpage
94
- st.audio(audio_response["url"])
95
 
96
  else:
97
  st.subheader("Error: Unable to get response. Please try again later.")
 
85
 
86
  st.write(response)
87
  # Text-to-speech
88
+ audio_response = openai.audio.speech.create(
89
+ model="tts-1",
 
90
  voice="alloy",
91
+ input=response
92
  )
93
+
94
+ # Extract URL from binary response
95
+ audio_url = audio_response.content.decode("utf-8").splitlines()[0]
96
+
97
  # Embed audio in the webpage
98
+ st.audio(audio_url)
99
 
100
  else:
101
  st.subheader("Error: Unable to get response. Please try again later.")