| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.6 and later. |
| Companion guide | |
| Declared in | NSSpeechSynthesizer.h |
The NSSpeechSynthesizerDelegate protocol defines the optional methods implemented by delegates of NSSpeechSynthesizer objects.
Sent to the delegate when a speech synthesizer encounters an error in text being synthesized.
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didEncounterErrorAtIndex:(NSUInteger)characterIndex ofString:(NSString *)string message:(NSString *)message
Speech synthesizer informing its delegate of an error.
Location in text where the receiver encountered the error.
Text the receiver was synthesizing when the error occurred.
Error message.
The synthesizer sends an error delegate message whenever it encounters a syntax error within a command embedded in the string it is processing. This can be useful during application debugging, to detect problems with commands that you have embedded in strings that your application speaks. It can also be useful if your application allows users to embed commands within strings. Your application might display an alert indicating that the synthesizer encountered a problem in processing an embedded command.
If your application needs information about errors that occurred prior to calling your error delegate method, the application (including the error delegate method) can call the sender’s objectForProperty:error: method with the NSSpeechErrorsProperty constant.
NSSpeechSynthesizer.hSent to the delegate when a speech synthesizer encounters a synchronization error.
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didEncounterSyncMessage:(NSString *)message
Speech synthesizer informing its delegate of an error.
Error message.
The synthesizer calls your synchronization delegate method whenever it encounters a synchronization command embedded in a string. You might use the synchronization delegate method to provide a callback not ordinarily provided.
For example, you might insert synchronization commands at the end of every sentence in a string, or you might enter synchronization commands after every numeric value in the text.
However, to synchronize your application with phonemes or words, it makes more sense to use the built-in phoneme and word delegate methods: speechSynthesizer:willSpeakPhoneme: and speechSynthesizer:willSpeakWord:ofString:.
NSSpeechSynthesizer.hSent when an NSSpeechSynthesizer object finishes speaking through the sound output device.
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)success
An NSSpeechSynthesizer object that has stopped speaking into the sound output device.
YES when speaking completed normally, NO if speaking is stopped prematurely for any reason.
– startSpeakingString: (NSSpeechSynthesizer)– stopSpeaking (NSSpeechSynthesizer)NSSpeechSynthesizer.hSent just before a synthesized phoneme is spoken through the sound output device.
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender willSpeakPhoneme:(short)phonemeOpcode
An NSSpeechSynthesizer object that’s synthesizing text into speech.
Phoneme that sender is about to speak into the sound output device.
One use of this method might be to animate a mouth on screen to match the generated speech.
Important: In Mac OS X v10.4 and earlier, the delegate is not sent this message when the NSSpeechSynthesizer object is synthesizing speech to a file (startSpeakingString:toURL:).
– startSpeakingString: (NSSpeechSynthesizer)NSSpeechSynthesizer.hSent just before a synthesized word is spoken through the sound output device.
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender willSpeakWord:(NSRange)wordToSpeak ofString:(NSString *)text
An NSSpeechSynthesizer object that’s synthesizing text into speech.
Word that sender is about to speak into the sound output device.
Text that is being synthesized by sender.
One use of this method might be to visually highlight the word being spoken.
Important: In Mac OS X v10.4 and earlier, the delegate is not sent this message when the NSSpeechSynthesizer object is synthesizing speech to a file (startSpeakingString:toURL:).
– startSpeakingString: (NSSpeechSynthesizer)NSSpeechSynthesizer.hLast updated: 2009-07-06