Create tts.py
Browse files
tts.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gtts import gTTS
|
2 |
+
from tempfile import NamedTemporaryFile
|
3 |
+
|
4 |
+
def text_to_speech(text: str) -> str:
|
5 |
+
tts = gTTS(text=text)
|
6 |
+
temp_audio = NamedTemporaryFile(delete=False, suffix=".mp3")
|
7 |
+
tts.save(temp_audio.name)
|
8 |
+
return temp_audio.name
|