我希望我的python程序在将文本转换为语音时打印出来,但在说话后需要一段时间才能接受输入……请提出任何建议(:
import pyttsx3
import math
speaker = pyttsx3.init()
speaker.say("Enter operator")
speaker.runAndWait()
print("Valid Operators:\n"
"type \"add\" for adding\n"
"type \"subtract\" for subtracting\n"
"type \"divide\" for dividing\n"
"type \"multiply\" for multiplying\n"
"type \"Square root\" for square-root\n"
"type \"Square\" for square of a number\n")
op = input("Enter your operator:\n")发布于 2021-04-05 14:26:19
import pyttsx3
import math
import threading
speaker = pyttsx3.init()
def say_thread(s):
speaker.say(s)
speaker.runAndWait()
def say(s)
x = threading.Thread(target=say_thread, args=("Enter operation",))
x.start()
say( "Enter operation" )
print("Valid Operators:\n"
"type \"add\" for adding\n"
"type \"subtract\" for subtracting\n"
"type \"divide\" for dividing\n"
"type \"multiply\" for multiplying\n"
"type \"Square root\" for square-root\n"
"type \"Square\" for square of a number\n")
op = input("Enter your operator:\n")```https://stackoverflow.com/questions/66948997
复制相似问题