次のようにNSSpeechSynthesizerクラスを呼び出すViewControllerを備えたMacOSXアプリケーションがあります-
- (IBAction)speakButtonTapped:(id)sender
{
NSString *mystring = [self.textFieldTextInput stringValue];
self.speechSynth = [[NSSpeechSynthesizer alloc] initWithVoice:nil];
if ([mystring length] ==0)
{
NSLog(@"string from %@ is of zero length", self.textFieldTextInput);
}
[self.speechSynth startSpeakingString:mystring];
NSLog(@"Speech output end");
}
textFieldInputとspeakButtonTappedは、Xcode4.5.2のIBを使用して配線されています。
ただし、目的の出力(別名スピーチ)が得られません。