diff --git a/addon/synthDrivers/_ibmeci.py b/addon/synthDrivers/_ibmeci.py index b0f3403..09adbb0 100644 --- a/addon/synthDrivers/_ibmeci.py +++ b/addon/synthDrivers/_ibmeci.py @@ -242,32 +242,37 @@ def bgPlay(stri): tries += 1 log.error("Eloq speech failed to feed one buffer.") -curindex=None +indexes = [] +def sendIndexes(): + global indexes + for i in indexes: _callbackExec(setLast, i) + indexes = [] + +def playStream(): + global audioStream + _callbackExec(bgPlay, audioStream.getvalue()) + audioStream.truncate(0) + audioStream.seek(0) + sendIndexes() + +endStringReached = False Callback = WINFUNCTYPE(c_int, c_int, c_int, c_int, c_void_p) @Callback def callback (h, ms, lp, dt): - global audioStream, curindex, speaking, END_STRING_MARK, endMarkersCount + global audioStream, speaking, END_STRING_MARK, endMarkersCount, indexes, endStringReached if speaking and ms == ECIMessage.eciWaveformBuffer: audioStream.write(string_at(buffer, lp*2)) - if audioStream.tell() >= samples*2: - _callbackExec(bgPlay, audioStream.getvalue()) - if curindex is not None: - _callbackExec(setLast, curindex) - curindex=None - audioStream.truncate(0) - audioStream.seek(0) + if audioStream.tell() >= samples*2: playStream() + endStringReached = False elif ms==ECIMessage.eciIndexReply: - if lp != END_STRING_MARK: # not end of string - curindex = lp - else: #We reached the end of string - if audioStream.tell() > 0: - _callbackExec(bgPlay, audioStream.getvalue()) - audioStream.seek(0) - audioStream.truncate(0) - if curindex is not None: - _callbackExec(setLast, curindex) - curindex=None + if lp == END_STRING_MARK: + if audioStream.tell() > 0: playStream() + sendIndexes() _callbackExec(endStringEvent) + endStringReached = True + else: + if endStringReached: _callbackExec(setLast, lp) + else: indexes.append(lp) return ECICallbackReturn.eciDataProcessed class CallbackThread(threading.Thread): @@ -390,10 +395,11 @@ def endStringEvent(): endMarkersCount -=1 if endMarkersCount == 0: speaking = False - onDoneSpeaking() idleTimer = threading.Timer(0.3, idlePlayer) idleTimer.start() def idlePlayer(): global player, speaking - if not speaking: player.idle() + if not speaking: + player.idle() + onDoneSpeaking() \ No newline at end of file diff --git a/buildVars.py b/buildVars.py index eaf2521..4fc5762 100644 --- a/buildVars.py +++ b/buildVars.py @@ -19,7 +19,7 @@ # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description" : _("""This is the IBMTTS synthesizer driver for NVDA."""), # version - "addon_version" : "19.8B3", + "addon_version" : "19.8B4", # Author(s) "addon_author" : u"David CM and others", # URL for the add-on documentation support