Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour of the engine when stop() was called #16

Open
LiKe85 opened this issue Oct 7, 2013 · 3 comments
Open

Strange behaviour of the engine when stop() was called #16

LiKe85 opened this issue Oct 7, 2013 · 3 comments
Milestone

Comments

@LiKe85
Copy link

LiKe85 commented Oct 7, 2013

The following test script was executed under Windows 7 and Ubuntu 12.04 and documents some strange behaviour of the onStop() function. The code was taken from the documentation example "Interrupting an utterance" and a second sentence was added to be read out.

The test script:

import os
import sys
sys.path.insert(0, os.path.join('..', '..'))
import pyttsx
import time

def onWord(name, location, length):
   print 'word', name, location, length
   if location > 10:
      engine.stop()

engine = pyttsx.init()
engine.connect('started-word', onWord)

engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

print("")
time.sleep(2)

engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

Output under Windows 7:

$ python interrupting.py
word None 0 3
word None 4 5
word None 10 5
word None 16 3
word None 20 6

word None 0 3
word None 4 5
word None 10 5
word None 16 3
word None 20 6
word None 27 4
word None 32 3
word None 36 4
word None 41 3

Output under Ubuntu:

$ python interrupting.py
word None 0 3
word None 4 5
word None 10 5
word None 16 3

word None 0 3
word None 4 5
word None 10 5
word None 16 3
word None 20 6
word None 27 4
word None 32 3
word None 36 4
word None 41 3

You can see that stopping the utterance in the example code works for the first execution of runAndWait() (more or less, since it should be stopped after the fourth word which it doesn't under Windows, but this might be some asynchronous timing issue), but not for the second.

The second utterance with the exact same engine does not stop as requested but continues to read out all the text. This happens for both operating systems.

Another thing is, that under Ubuntu the given script crashes randomly after stop() was called. Sometimes even before the second utterance is started, sometimes during the second one. However, sometimes it is executed correctly and does not crash. Since this only happens under Linux this seems to be an issue with the espeak.py driver (my espeak version is 1.46.02).

@parente
Copy link
Collaborator

parente commented Oct 29, 2013

@LiKe85, in the Ubuntu 12.04 test you ran above, was it a 32bit or 64bit install of Ubuntu?

In my initial attempt to reproduce on 12.04 32-bit with espeak 1.46.02, the first utterance stops properly, but the second utterance stops immediately after the first word without reaching the stop() in the callback.

@parente
Copy link
Collaborator

parente commented Oct 29, 2013

On 32-bit 12.04 with espeak 1.46.02, I tracked the problem to a change in espeak behavior. In past versions that I tested,, an _espeak.Cancel() call would not cause the final _espeak.EVENT_MSG_TERMINATED to fire so I had added code to trigger it manually after a Cancel(). In 1.46.02, I can see the event is fired by espeak on Cancel(). Removing the manual trigger resolves the problem I mentioned one comment up.

I'll need to go back and look at older versions of espeak to see if I can support both behaviors. Or draw a line in the sand at espeak 1.46.02.

More pressing is why is the behavior I see different from the reported bug. I'll try 64 bit desktop next.

@LiKe85
Copy link
Author

LiKe85 commented Nov 5, 2013

I used a 64bit install of Ubuntu with espeak 1.46.02.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants