diff --git a/source/synthDrivers/_espeak.py b/source/synthDrivers/_espeak.py index b5ff773319b..00cfad2281f 100755 --- a/source/synthDrivers/_espeak.py +++ b/source/synthDrivers/_espeak.py @@ -119,6 +119,8 @@ def __eq__(self, other): def callback(wav,numsamples,event): try: global player, isSpeaking, lastIndex + if not isSpeaking: + return 1 for e in event: if e.type==espeakEVENT_MARK: lastIndex=int(e.id.name) @@ -128,8 +130,6 @@ def callback(wav,numsamples,event): player.idle() isSpeaking = False return 0 - if not isSpeaking: - return 1 if numsamples > 0: try: player.feed(string_at(wav, numsamples * sizeof(c_short))) @@ -179,7 +179,7 @@ def speak(text): _execWhenDone(_speak, text, mustBeAsync=True) def stop(): - global isSpeaking, bgQueue + global isSpeaking, bgQueue, lastIndex # Kill all speech from now. # We still want parameter changes to occur, so requeue them. params = [] @@ -196,6 +196,7 @@ def stop(): bgQueue.put(item) isSpeaking = False player.stop() + lastIndex=None def pause(switch): global player