Pyttsx没有发出声音



我试图在windows7上使用pyttsx进行文本到语音转换,但它不会产生任何语音。

Import pyttsx
Engine=pyttsx.init('sapi5')
Engine.say('hello')

这是我的代码,没有错误和异常,但没有文本到语音的转换

Python是一种区分大小写的语言,必须安装在您的机器上才能使用此库。如果在Windows7机器上设置了Python,请尝试以下代码:

import pyttsx
engine=pyttsx.init() # The init function doesn't take any parameters 
engine.say("hello") #I prefer double quotes, but single quotes work too

这里有一个示例列表:https://pyttsx.readthedocs.io/en/latest/engine.html#examples

您还必须将其添加到最后一行。

Engine.runAndWait()

您可以尝试以下方法:

import pyttsx
engine = pyttsx.init()
engine.say('hello')
engine.runAndWait()

最新更新