Python pyttsx-loop使runAndWait()被切断

Python pyttsx-loop使runAndWait()被切断,python,ubuntu,pyttsx,Python,Ubuntu,Pyttsx,我想写一个脚本,在打印到屏幕上时读取单词列表 import pyttsx engine = pyttsx.init() words = ["here","are","some","test","words"] for i in words: engine.say(i) print i engine.runAndWait() 然而,在运行上述命令时,除“here”之外的所有单词都被缩短。我听到类似“这里[暂停]阿苏特沃——” 如果我取消输入engine.runAndW

我想写一个脚本,在打印到屏幕上时读取单词列表

import pyttsx

engine = pyttsx.init()
words = ["here","are","some","test","words"]

for i in words:
    engine.say(i)
    print i
    engine.runAndWait()
然而,在运行上述命令时,除“here”之外的所有单词都被缩短。我听到类似“这里[暂停]阿苏特沃——”

如果我取消输入
engine.runAndWait()
,则循环完成后会说出这些单词。当我这样做的时候,它们不会被切断,但是,当然,它们不会在打印的同时被说出来


我正在运行Ubuntu14.04.2

您想要的是打印word,使用回调如何


这已经晚了几年,但是使用
engine.startoop(False)
engine.iterate()
遵循中的“外部事件循环”示例为我完成了这项工作

import pyttsx
import time

engine = pyttsx.init()
words = ["here","are","some","test","words"]

engine.startLoop(False)
for i in words:
    engine.say(i)
    engine.iterate()
    print i
    while engine.isBusy(): # wait until finished talking
        time.sleep(0.1)

engine.endLoop()
import pyttsx
import time

engine = pyttsx.init()
words = ["here","are","some","test","words"]

engine.startLoop(False)
for i in words:
    engine.say(i)
    engine.iterate()
    print i
    while engine.isBusy(): # wait until finished talking
        time.sleep(0.1)

engine.endLoop()