语音翻译采用语音听写接口,设置业务参数即可实现语音翻译功能。目前支持英文转中文,中文转英文,后续其他功能请注意浏览讯飞开放平台。
//需要实现IFlyRecognizerViewDelegate或者IFlySpeechRecognizerDelegate识别协议
//创建语音识别对象
_iFlySpeechRecognizer = [IFlySpeechRecognizer sharedInstance];
//必要参数设置
//设置为听写模式
[_iFlySpeechRecognizer setParameter: @"iat" forKey: [IFlySpeechConstant IFLY_DOMAIN]];
[_iFlySpeechRecognizer setParameter: @"1" forKey: [IFlySpeechConstant ASR_SCH]];
[_iFlySpeechRecognizer setParameter: @"translate" forKey: @”addcap”];
//中文转英文
[_iFlySpeechRecognizer setParameter: @"zh" forKey: @”orilang”];
[_iFlySpeechRecognizer setParameter: @"en" forKey: @”translang”];
//英文转中文
[_iFlySpeechRecognizer setParameter: @"en" forKey: @”orilang”];
[_iFlySpeechRecognizer setParameter: @"zh" forKey: @”translang”];
//启动服务
[_iFlySpeechRecognizer start];
//SDK的回调仍然采用IFlySpeechRecognizerDelegate协议实现。
//注意:当从翻译功能转换其他业务时,需要清空参数
//[_iFlySpeechRecognizer setParameter: @"" forKey: @”params”];