标签:
首先添加框架
iflyMSC.framework,
libz.dylib/libz.tbd(Xcode7.x)
AVFoundation.framework
SystemConfiguration.framework
Foundation.framework
CoreTelephoney.framework
AudioToolbox.framework
UIKit.framework
CoreLocation.framework
AddressBook.framework
QuartzCore.framework
CoreGraphics.framework
说实话,框架好多,并且大多数都是目前用不到,不过考虑到以后这篇文章还会继续增加,所以就一次贴出来吧.
//设置sdk的log等级,log保存在下面设置的工作路径中 [IFlySetting setLogFile:LVL_ALL]; //打开输出在console的log开关 [IFlySetting showLogcat:YES]; //设置sdk的工作路径 NSString *paths=NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0]; [IFlySetting setLogFilePath:paths]; //创建语音配置,appid必须要传入,仅执行一次则可 NSString *initString=[[NSString alloc]initWithFormat:@"appid=%@",APPID_VALUE]; //所有服务启动前,需要确保执行createUtility [IFlySpeechUtility createUtility:initString];
语音合成
@interface ViewController ()<IFlySpeechSynthesizerDelegate>
{
//需要实现IFlySpeechSynthesizerDelegate合成会话的服务代理
IFlySpeechSynthesizer *_iFlySpeechSynthesizer;
}
- (IBAction)read:(UIButton *)sender { //1.创建合成对象 _iFlySpeechSynthesizer=[IFlySpeechSynthesizer sharedInstance]; _iFlySpeechSynthesizer.delegate=self; //2.设置合成参数 //设置在线工作方式 [_iFlySpeechSynthesizer setParameter:[IFlySpeechConstant TYPE_CLOUD] forKey:[IFlySpeechConstant ENGINE_TYPE]]; //音量,取值范围 0~100 [_iFlySpeechSynthesizer setParameter:@"50" forKey:[IFlySpeechConstant VOLUME]]; //说话语速 [_iFlySpeechSynthesizer setParameter:@"42" forKey:[IFlySpeechConstant SPEED]]; //发音人,默认为”xiaoyan”,可以设置的参数列表可参考“合成发音人列表” [_iFlySpeechSynthesizer setParameter:@"xiaoyan" forKey:[IFlySpeechConstant VOICE_NAME]]; //保存合成文件名,如不再需要,设置设置为nil或者为空表示取消,默认目录位于 library/cache下 [_iFlySpeechSynthesizer setParameter:@"tts.pcm" forKey:[IFlySpeechConstant TTS_AUDIO_PATH]]; //3.启动合成会话 [_iFlySpeechSynthesizer startSpeaking:_world.text]; }
IFlySpeechSynthesizerDelegate协议方法
//结束代理 -(void)onCompleted:(IFlySpeechError *)error { NSLog(@"结束代理"); } //合成开始 -(void)onSpeakBegin { NSLog(@"合成开始"); } //合成缓冲进度 -(void)onBufferProgress:(int)progress message:(NSString *)msg { NSLog(@"合成缓冲进度"); } //合成播放进度 -(void)onSpeakProgress:(int)progress { NSLog(@"合成缓冲进度"); }
标签:
原文地址:http://www.cnblogs.com/fshmjl/p/4838505.html