[a5e8ec]: / internal / tts / tttest.py

Download this file

18 lines (13 with data), 361 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from gtts import gTTS
import subprocess
def generate_audios(status, text):
try:
audio_file = f"assets/audios/{status}.mp3"
gTTS(text).save(audio_file)
return True
except:
return False
def play_audio(status):
audio_file = f"assets/audios/{status}.mp3"
print(audio_file)
subprocess.run(["mpv", audio_file])