美文网首页
系统自带的语音合成

系统自带的语音合成

作者: 九天环佩 | 来源:发表于2016-07-14 15:33 被阅读22次

为备忘,直接上代码

    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 框架。

相关文章

网友评论

      本文标题:系统自带的语音合成

      本文链接:https://www.haomeiwen.com/subject/twiejttx.html