开发者

NSSpeechSynthesizer delegate method always reports an error, but which one?

I have the following delegate method for NSSpeechSynthesizer:

- (void) speechSynthesizer:(NSSpeechSynthesizer *)sender didFi开发者_运维百科nishSpeaking:(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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜