iOS 系统自带的文本转语音
2015-10-22 10:03
579 查看
第一步:引入头文件
第二步:创建speechSynthesizer合成器实例
第三步:根据你要转换的文本,创建一个属于你的专属“代言人”
第四步:根据你对代言人的要求,可以更改代言人的voice、pitch、rate
第五步:把你的代言人 添加到你的整个流程上,之后就可以发言了。
根据API:If the synthesizer is speaking, utterances are added to a queue and spoken in the order they are received.说明你的代言人是可以有多个,并且你是以一种队列(FIFO)的方式管理他们的。
以上就已经实现了文本转语音的功能。
带有详细解释的思维导图总结
#import <AVFoundation/AVSpeechSynthesis.h>
第二步:创建speechSynthesizer合成器实例
AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc]init];
第三步:根据你要转换的文本,创建一个属于你的专属“代言人”
AVSpeechUtterance *utteranceNuoYi = [[AVSpeechUtterance alloc]initWithString:@"Attraper des étoiles "]; AVSpeechUtterance *utteranceLiuYe = [[AVSpeechUtterance alloc]initWithString:@"Noé, chéri "];
第四步:根据你对代言人的要求,可以更改代言人的voice、pitch、rate
utteranceNuoYi.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-CA"]; utteranceLiuYe.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-CA"]; //音高pitch // [0.5 - 2] Default = 1,就是声音的粗细问题。 utteranceNuoYi.pitchMultiplier = 0.7; //说话的快慢 //Values are pinned between AVSpeechUtteranceMinimumSpeechRate and AVSpeechUtteranceMaximumSpeechRate. utteranceNuoYi.rate = AVSpeechUtteranceMinimumSpeechRate; //调整音量的高低。 // [0-1] Default = 1 utteranceNuoYi.volume = 0.8;
第五步:把你的代言人 添加到你的整个流程上,之后就可以发言了。
根据API:If the synthesizer is speaking, utterances are added to a queue and spoken in the order they are received.说明你的代言人是可以有多个,并且你是以一种队列(FIFO)的方式管理他们的。
[speechSynthesizer speakUtterance:utteranceNuoYi]; [speechSynthesizer speakUtterance:utteranceLiuYe];
以上就已经实现了文本转语音的功能。
带有详细解释的思维导图总结
相关文章推荐
- ios移动开发遇到的一些小问题的解决办法
- iOS中NSUserDefaults的用法
- iOS手势识别器
- iOS实现导航栏全透明效果
- IOS编译报错 75 duplicate symbols for architecture x86_64
- iOS开发中自定义相册功能性能优化
- iOS中多个StoryBoard的跳转问题
- Xcode7企业版打包
- Quartz2D使用之基本图形绘制(一)
- View层基础动画
- Ios SVN版本管理
- socket在ios中的应用
- IOS中NSUserDefaults的用法(轻量级本地数据存储)
- IOS异步获取数据并刷新界面dispatch_async的使用方法
- IOS中定时器NSTimer的开启与关闭
- iOS block使用总结
- iOS objc_msgSend 报错解决方案
- iOS --- 音量调节视图MPVolumeView的使用
- iOS --- 使用NSAssert来调试程序
- 特性一、iOS的AutoLayout和Autoresizing