I am using a speech synthesizer using the Audio Unit, based on Core Audio examples . Everything works as expected, except that StopSpeech and StopSpeechAt do nothing.
Here are ways to talk and stop:
void
Synthesizer::speak( const string &text )
{
mIsSpeaking = true;
mLastText = text;
NSString *ns_text = [NSString stringWithCString:text.c_str()
encoding:[NSString defaultCStringEncoding]];
CFStringRef cf_text = (__bridge CFStringRef)ns_text;
CheckError( SpeakCFString( mAuChannel, cf_text, NULL ), "SpeakCFString failed" );
}
void
Synthesizer::stop()
{
if ( isSpeaking() ) {
mStopRequested = true;
CheckError( StopSpeech( mAuChannel ), "StopSpeech failed" );
}
else {
mIsSpeaking = false;
}
}
I checked that StopSpeech is called on the same thread as SpeakCFString. Oddly enough, when I try to enter the StopSpeech call using the debugger, it skips it. Really strange, a voice message callback starts when StopSpeech is called, but speech continues independently.
Any idea what might happen, or what can I do for debugging? Is there a workaround I could use to temporarily disable the Audio Unit node?
This is on MacOS 10.12.5.