iOS_简单语音播报

iOS 7之后,苹果新增了一个简单的 API ---- AVSpeechSynthesizer 来实现语音播报功能。

第一步:导入 AVFoundation/AVFoundation.h 系统库

#import <AVFoundation/AVFoundation.h>

第二步:设置播报参数


//初始化语音播报
AVSpeechSynthesizer * av = [[AVSpeechSynthesizer alloc]init];
//设置播报的内容
AVSpeechUtterance * utterance = [[AVSpeechUtterance alloc]initWithString:@"语音播报"];
//设置语言类别
AVSpeechSynthesisVoice * voiceType = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
utterance.voice = voiceType;
//设置播报语速
utterance.rate = 0.5;
[av speakUtterance:utterance];

参考文章:http://blog.csdn.net/m372897500/article/details/30069967

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容