On Tue, Sep 29, 2009 at 8:34 PM, Peter Parente <parente@...> wrote:
>> Peter Parente schrieb:
>>> I'm trying to use the SAPI5 SPVoice interface through comtypes, but I
>>> don't seem to be getting any events.
>>> I instantiate the interface like so and call ShowEvents
>>> import comtypes.client
>>> tts = comtypes.client.CreateObject('SAPI.SPVoice')
>>> advise = comtypes.client.ShowEvents(tts)
>>> The ShowEvents call gives me the following list:
>>> # event found: _ISpeechVoiceEvents_StartStream
>>> # event found: _ISpeechVoiceEvents_EndStream
>>> # event found: _ISpeechVoiceEvents_VoiceChange
>>> # event found: _ISpeechVoiceEvents_Bookmark
>>> # event found: _ISpeechVoiceEvents_Word
>>> # event found: _ISpeechVoiceEvents_Sentence
>>> # event found: _ISpeechVoiceEvents_Phoneme
>>> # event found: _ISpeechVoiceEvents_Viseme
>>> # event found: _ISpeechVoiceEvents_AudioLevel
>>> # event found: _ISpeechVoiceEvents_EnginePrivate
>>> When I invoke the speak() method on the tts object, I believe I should
>>> see some of these events (word, sentence, etc.) once I enter a message
>>> loop. However, I see nothing printed:
>>> tts.speak('The quick brown fox jumps over the lazy dog.')
>>> I also tried passing my own class with callback methods named
>>> _ISpeechVoiceEvents_StartStream and so forth to GetEvents, but still,
>>> none of the callbacks get invoked.
>> Has this worked in other versions of comtypes, or did you try for the first time?
> This is my first attempt. If older versions are available, I can try
> them to see if any work.
I tried with comtypes-0.6.1 and 0.5.3 on both Python 2.5.2 and 2.6.2.
I get no output about events from ShowEvents in either case while in
the PumpEvents loop.
To make sure SAPI is set to fire events (which MSDN says it is by
default, but you never know), I also tried setting property
tts.EventInterests to SVEAllEvents. Still, no luck.
As a side note, I do get events when accessing SAPI5 using the
win32com package. Wrapping the SAPI.SpVoice instance with WithEvents
works as expected.