geethareddy commited on
Commit
fc35d76
·
verified ·
1 Parent(s): d38a0a3

Create tts_model.py

Browse files
Files changed (1) hide show
  1. models/tts_model.py +16 -0
models/tts_model.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from gtts import gTTS
2
+
3
+ def text_to_speech(text, output_file="response.mp3"):
4
+ """
5
+ Converts text into speech and saves it as an audio file.
6
+
7
+ Args:
8
+ text (str): Text to convert to speech.
9
+ output_file (str): Path to save the audio file.
10
+
11
+ Returns:
12
+ str: Path to the generated audio file.
13
+ """
14
+ tts = gTTS(text=text, lang='en')
15
+ tts.save(output_file)
16
+ return output_file