语音翻译采用语音听写接口,设置业务参数即可实现语音翻译功能。目前支持英文转中文,中文转英文,后续其他功能请注意浏览讯飞开放平台。

    1. //需要实现IFlyRecognizerViewDelegate或者IFlySpeechRecognizerDelegate识别协议
    2. //创建语音识别对象
    3. _iFlySpeechRecognizer = [IFlySpeechRecognizer sharedInstance];
    4. //必要参数设置
    5. //设置为听写模式
    6. [_iFlySpeechRecognizer setParameter: @"iat" forKey: [IFlySpeechConstant IFLY_DOMAIN]];
    7. [_iFlySpeechRecognizer setParameter: @"1" forKey: [IFlySpeechConstant ASR_SCH]];
    8. [_iFlySpeechRecognizer setParameter: @"translate" forKey: @”addcap”];
    9. //中文转英文
    10. [_iFlySpeechRecognizer setParameter: @"zh" forKey: @”orilang”];
    11. [_iFlySpeechRecognizer setParameter: @"en" forKey: @”translang”];
    12. //英文转中文
    13. [_iFlySpeechRecognizer setParameter: @"en" forKey: @”orilang”];
    14. [_iFlySpeechRecognizer setParameter: @"zh" forKey: @”translang”];
    15. //启动服务
    16. [_iFlySpeechRecognizer start];
    17. //SDK的回调仍然采用IFlySpeechRecognizerDelegate协议实现。
    18. //注意:当从翻译功能转换其他业务时,需要清空参数
    19. //[_iFlySpeechRecognizer setParameter: @"" forKey: @”params”];