我试图让一个python文本到语音程序无限运行,直到用户决定退出,任何帮助将不胜感激
这是我的代码:
# IMPORT
import gtts as gTTS
import os
# TTS
myText = input("Enter your text: ")
language = 'en'
output = gTTS.gTTS(text=myText,, slow=False,)
output.save("output.mp3")
os.system("start output.mp3")
# Restart
def get_answer(prompt):
answer = input(prompt)
# 1 while not (answer == "yes" or answer == "no"
# 2 while answer not in ("yes", "no"):
# 3 while answer not in ["yes", "no"]:
while answer not in ("yes", "no"):
answer = input(prompt)
return answer
print(get_answer("yes or no? "))
繁花不似锦
相关分类