Praxis_Bot/tts.py
Alex Orid 994981cfdb First Push
Im so sorry for the bad code T_T

(Also note to self, I deleted the old code)
2020-09-19 23:38:49 -04:00

40 lines
872 B
Python

from gtts import gTTS
import os
import datetime
from playsound import playsound
def tts(inputText:str, *args):
destPath = os.getcwd() + "\\tts\\"
time = datetime.datetime.now()
fileName:str = time.strftime("%m-%d-%Y_%H-%M-%S") + "_tts.mp3"
if len(args) == 1:
fileName = args[0] + "_tts.mp3"
tts = gTTS(text=inputText, lang='en')
tts.save(destPath + fileName)
playsound(destPath + fileName)
#os.system(filename)
def play_speech(fileName):
destPath = os.getcwd() + "\\tts\\"
playsound(destPath + fileName)
if __name__ == "__main__":
print("Enter Text: ")
textInput = str(input())
print("Custom FileName? y/n: ")
bool_string = str(input())
if bool_string == "y":
print("Enter FileName: ")
fileName = str(input())
tts(textInput, fileName)
else:
tts(textInput)