Skip to content

Commit

Permalink
eSpeak synth driver: reset lastIndex to None when speech is canceldd.…
Browse files Browse the repository at this point in the history
… Also move some code in the eSpeak callback so that if speech has been stopped the callback will return as soon as possible. This is partly to make sure that no last indexes accidentily get set after the last index was reset to None.
  • Loading branch information
michaelDCurran committed Jul 3, 2011
1 parent 03b0d1a commit 5e64248
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/synthDrivers/_espeak.py
Expand Up @@ -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)
Expand All @@ -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)))
Expand Down Expand Up @@ -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 = []
Expand All @@ -196,6 +196,7 @@ def stop():
bgQueue.put(item)
isSpeaking = False
player.stop()
lastIndex=None

def pause(switch):
global player
Expand Down

0 comments on commit 5e64248

Please sign in to comment.