shukdevdatta123 commited on
Commit
eadd27b
·
verified ·
1 Parent(s): b8d2f96

Update helpers.py

Browse files
Files changed (1) hide show
  1. helpers.py +7 -9
helpers.py CHANGED
@@ -26,16 +26,14 @@ def speech_to_text(audio_data):
26
  return transcript["text"] # Extract the text from the response
27
 
28
 
 
 
29
  def text_to_speech(input_text):
30
- response = openai.Audio.speech.create(
31
- model="text-to-speech-1", # Adjust as necessary
32
- voice="nova",
33
- input=input_text
34
- )
35
- webm_file_path = "temp_audio_play.mp3"
36
- with open(webm_file_path, "wb") as f:
37
- response.stream_to_file(webm_file_path)
38
- return webm_file_path
39
 
40
 
41
  def autoplay_audio(file_path: str):
 
26
  return transcript["text"] # Extract the text from the response
27
 
28
 
29
+ from gtts import gTTS
30
+
31
  def text_to_speech(input_text):
32
+ """Generates a TTS audio file from the input text."""
33
+ tts = gTTS(text=input_text, lang="en")
34
+ audio_file_path = "temp_audio_play.mp3"
35
+ tts.save(audio_file_path)
36
+ return audio_file_path
 
 
 
 
37
 
38
 
39
  def autoplay_audio(file_path: str):