这个简单的代码在我的 iPhone 上运行良好,但在我的 Pad 上却不行。无论如何,语音合成器在 iPad 上保持沉默。可能是什么问题呢?从选定的文本朗读在 iPad 上确实有效,没有错误。没有警告,没有消息,什么都没有。
我在 iOS7 上使用 Xcode 6、iPhone 5s 和 iPad 4。
#import <AVFoundation/AVFoundation.h>
AVSpeechSynthesizer *synthesizer;
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)Speak:(id)sender
{ NSString* Phrase = @"Hello world!";
synthesizer = [[AVSpeechSynthesizer alloc]init]; // init speech synth }
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:Phrase];
[synthesizer speakUtterance:utterance];
}