小さなPythonアプリケーションがありますが、Pyttsxを使ってテキストを音声に変換します。eclipse以外で実行したときにプログラムが完全に動作しない
どのように動作しますか: クリップボードには何もありません。
プログラムはeclipseの中で期待通りに動作します。しかし、cmd.exeで実行すると、クリップボード上のテキストが大きすぎる(わずかなパラ)場合にのみ部分的に機能します。どうして ?
CMDから実行したとき、それは文を出力しますが、実際にはクリップボードのテキストがここ
大きすぎる場合(動作しない「話」は、実際に話をするプログラム部品のですができるように見て「会話」部分は、スレッド内で処理されることが
def saythread(queue , text , pauselocation, startingPoint):
saythread.pauselocation = pauselocation
saythread.pause = 0
saythread.engine = pyttsx.init()
saythread.pausequeue1 = False
def onWord(name, location, length):
saythread.pausequeue1 = queue.get(False)
saythread.pause = location
saythread.pauselocation.append(location)
if saythread.pausequeue1 == True :
saythread.engine.stop()
def onFinishUtterance(name, completed):
if completed == True:
os._exit(0)
def engineRun():
if len(saythread.pauselocation) == 1:
rate = saythread.engine.getProperty('rate')
print rate
saythread.engine.setProperty('rate', rate-30)
textMod = text[startingPoint:]
saythread.engine.say(text[startingPoint:])
token = saythread.engine.connect("started-word" , onWord)
saythread.engine.connect("finished-utterance" , onFinishUtterance)
saythread.engine.startLoop(True)
engineRun()
if saythread.pausequeue1 == False:
os._exit(1)
def runNewThread(wordsToSay, startingPoint):
global queue, pauselocation
e1 = (queue, wordsToSay, pauselocation, startingPoint)
t1 = threading.Thread(target=saythread,args=e1)
t1.start()
#wordsToSay = CLIPBOARD CONTENTS
runNewThread(wordsToSay,0)
おかげ
を編集:私は同じ2.7で使用PythonのバージョンよりもチェックしてCMDでプログラムを実行するために使用するコマンドを。: python d:\python\play\speech\speechplay.py
「ランニングパーティー」とはどういう意味ですか?処理されたクリップボードからのテキストの一部に過ぎないのでしょうか? –
それはSTDOUTにテキストを出力しますが、何も言わない ' –