如何在ios(Cocos2d)中将字符串转换为音频(声音)文件?
有没有办法将字符串(字符)转换为iOS中的音频文件? 我的问题是我有一个字符串和我要转换成声音文件的字符串,是否可以不使用任何第三方API ?
提前致谢…..
AVSpeechSynthesizer教程 – 让你的应用程序像Siri一样说话
avspeechsynthesizer-IOS-文本-语音- IOS-7
但这只适用于iOS 7
示例应用
是的,对于iOS 7 , AVSpeechSynthesizer类在iOS设备上从文本生成合成语音,并提供控制或监视正在进行的语音进度的方法。
编辑:只需在项目中添加AVFoundation
框架,添加import语句#import
并执行以下代码:
AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc]init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Really, its very easy."]; [utterance setRate:0.5f]; [speechSynthesizer speakUtterance:utterance];
在之前版本的IOS 7中使用长笛库http://artofsystems.blogspot.in/2009/02/speech-synthesis-on-iphone-with-flite.html
对于IOS 7,内置的文本到语音转换functionavspeechsynthesizer-ios-text-speech-ios-7