license 获取失败
青x秦 发布于2016-04 浏览:4146 回复:4
0
收藏
快速回复

运行BDVRClientSample的时候,将demo中的API_KEY和SECRET_KEY,APPID

修改成为了在百度开发者平台申请的API_KEY和SECRET_KEY,APP ID,运行demo的时候,点击语音识别,在执行

- (int)loadOfflineEngine: (NSString*)appCode

                 license: (NSString*)licenseFile

                 datFile: (NSString*)datFilePath

               LMDatFile: (NSString*)LMDatFilePath

               grammSlot: (NSDictionary*)dictSlot;

方法时,总是出现4001错误,解释为获取license失败,请问如何解决,代码如下

 NSString* datFilePath = [[NSBundle mainBundle] pathForResource:@"s_1" ofType:@""];

    NSString* LMDatFilePath = nil;

    if ([[BDVRSConfig sharedInstance].recognitionProperty intValue] == EVoiceRecognitionPropertyMap) {

        LMDatFilePath = [[NSBundle mainBundle] pathForResource:@"s_2_Navi" ofType:@""];

    } else if ([[BDVRSConfig sharedInstance].recognitionProperty intValue] == EVoiceRecognitionPropertyInput) {

        LMDatFilePath = [[NSBundle mainBundle] pathForResource:@"s_2_InputMethod" ofType:@""];

    }

    

    NSString *licensePath = [[NSBundle mainBundle] pathForResource:@"Classes/Libs/License/bdasr_temp_license" ofType:@"dat"];

    NSDictionary* recogGrammSlot = @{@"$name_CORE" : @"张三\n李四\n",

                                    @"$song_CORE" : @"小苹果\n朋友\n",

                                    @"$app_CORE" : @"QQ\n百度\n微信\n百度地图\n",

                                    @"$artist_CORE" : @"刘德华\n周华健\n"};

    

    int ret = [[BDVoiceRecognitionClient sharedInstance] loadOfflineEngine:appCode

                                                                   license:licensePath

                                                                   datFile:datFilePath

                                                                 LMDatFile:LMDatFilePath

                                                                 grammSlot:recogGrammSlot];

    // 获取license失败

    if (0 != ret) {

        NSLog(@"load offline engine failed: %d", ret);

        return;

    }




收藏
点赞
0
个赞
共4条回复 最后由用户已被禁言回复于2022-04
#5fang4096回复于2017-02

可以下载临时授权文件进行授权,路径是应用管理->管理包名->下载临时授权文件。如果使用正式授权文件,移除临时授权文件,配置appid即可。

0
#4d21312008回复于2017-02

fang4096:

使用离线功能,请查阅相关离线授权文档。

回复fang4096:我在网上找半天根本就找不到什么离线授权文档,能不能把问题讲清楚,公司要接百度,免费是好的,但是作为开发者我很蛋疼啊,这么糟心的4001,你自己内部找个人接试试,你这样还不如不免费。我特伐克。

0
#3fang4096回复于2016-05

使用离线功能,请查阅相关离线授权文档。

0
#2听说123321200回复于2016-05

你需要在“申请离线识别授权”里提交了bundleID。

0
TOP
切换版块