views:

17

answers:

1

I have the following delegate method for NSSpeechSynthesizer:

- (void) speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL) success {
    NSLog(@"Finished correctly = %d", success);
    [startButton setEnabled:YES];
    [stopButton setEnabled:NO];
}

The parameter "success" is always NO, even though I heard everything perfectly. Is there a way to get more information and find out exactly what went wrong?

+3  A: 

Using NSSpeechSynthesizer? No. Using the Speech Synthesis Manager? Sure thing!

/* Created earlier: SpeechChannel chan; */
NSDictionary *errorInfo = nil;
OSErr err = CopySpeechProperty(chan, kSpeechErrorsProperty, (CFTypeRef *)&errorInfo);
[errorInfo autorelease];

You can also set up error handlers for all kinds of errors. See the Cocoa Speech Synthesis Example for a demonstration of how to use the Speech Synthesis Manager. While it is a Carbon API, it appears that it is still available to 64-bit applications.

Jeremy W. Sherman