开发者

Pyttsx not saying all text when using non default voice

I created a small module to speak the text that is sent to it. It works fine if I don't use engine.setProperty to set the voice, but if I set the voice it will only play the first command.

import pyttsx

def speak( text ):
    if text != "":
        engine = pyttsx.init()
        engine.setProperty('voice', "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\VW Kate") #if I don't do this line then it says开发者_JS百科 both the commands
        engine.say( text )
        engine.runAndWait()

    else:
        print "you didnt enter anything"

    if __name__ == "__main__":
        speak("Hello")
        speak("This one won't play unless I use the default voice")


I think you should try the following code snippet :

import pyttsx
engine = pyttsx.init()
engine.say('Sally sells seashells by the seashore.')
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

which is originally from this page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜