AVFoundation的文本到语音-NSSpeechSynthesizer
2015-10-29 11:15
489 查看
二、IOS- AVFoundation的文本到语音
1、NSSpeechSynthesizer
NSSpeechSynthesizer实例完成了文本到语音的工作。2、NSSpeechUtterance
NSSpeechUtterance的实例是语音内容。2.1、初始化
NSSpeechUtterance *utterance = [[NSSpeechUtterance alloc] initWithString:@"语音的内容"];2.2、常用属性
2.2.1、rate(float)
语音内容播发的速率,该值介于AVSpeechUtteranceMinimumSpeechRate和AVSpeechUtteranceMaximumSpeechRate之间,及0.0到1.0之间。2.2.2、pitchMultiplier(float)
语音内容播发的音调,该值一般介于0.5(低语调)和2.0(高音调)之间。2.2.3、postUtteranceDelay(NSTimeInterval)
播放下一句语句之前的暂停时间。2.2.4、voice(AVSpeechSynthesisVoice)
语音内容播发的语言。AVSpeechSynthesisVoice的一个实例,可以通过类方法+ (nullableAVSpeechSynthesisVoice*)voiceWithLanguage:(nullableNSString *)languageCode;获取语音实例,可以通过类方法+ (NSArray<AVSpeechSynthesisVoice
*> *)speechVoices;获取所支持语言类型。
3、将NSSpeechUtterance添加到NSSpeechSynthesizer
NSSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizeralloc]init];
AVSpeechUtterance *utterance = [[AVSpeechUtterancealloc]
initWithString:self.speechStrings[i]];
utterance.voice = [AVSpeechSynthesisVoicevoiceWithLanguage:@"en-US"];
utterance.rate =0.5f;
utterance.pitchMultiplier =0.8f;
utterance.postUtteranceDelay =0.1f;
[synthesizer
speakUtterance:utterance];
相关文章推荐
- 【iOS开发】跟踪键盘的移动
- ios 自定义cell类中获取当前controller push
- iOS知识点
- IOS 003 启动画面设置,以及增加启动画面动画
- ios无法播放安卓视频的问题
- iOS cocoaPods笔记 安装 卸载 2015.10.29
- iOS开发 正确选择图片加载方式
- iOS7之定制View Controller切换效果
- iOS 系统地图 获取当前城市
- ios USURL用法注意事项
- iOS Iphone的所有机型
- IOS-系统自带社交分享
- iOS :GCD的简单实用
- iOS 之"performSelector may cause a leak because its selector is unknown"警告原因及其解决办法
- 寻找ios培训机构
- iOS开发10种数据传值方法
- iOS手势类的简单使用
- iOS 项目上架后的加急审核 2015.10.29
- 一个iOS上的秒表小应用的实现方法分享
- ios 学习笔记(二)