系统自带的语音合成

为备忘,直接上代码

    AVSpeechUtterance *utt = [AVSpeechUtterance speechUtteranceWithString:@"明天晚上吃啥"];
    
    NSArray *voices = [AVSpeechSynthesisVoice speechVoices];
    NSLog(@"%@", voices);   //打印所有语言
    
    AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-HK"];    //粤语测试
    utt.voice = voice;
    
    AVSpeechSynthesizer *speech = [[AVSpeechSynthesizer alloc] init];
    
    [speech speakUtterance:utt];
    

类需要引用 AVFoundation 框架。

posted @ 2016-05-23 22:53  沈红榜  阅读(216)  评论(0编辑  收藏  举报