[iOS]AVSpeechSynthesizer语音合成

#import <AVFoundation/AVFoundation.h>

// 初始化方法
AVSpeechSynthesizer *speech = [[AVSpeechSynthesizer alloc]init];

// 设置内容
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:
                                @"红鲤鱼与绿鲤鱼与驴"];
// 设置语音类型
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];

// 语速
utterance.rate = 0.5;

// 开始朗读
[speech speakUtterance:utterance];

 

posted @ 2017-06-19 17:24  EverNight  阅读(420)  评论(0编辑  收藏  举报