ios-语音识别
Ta的回复 :- (void)startVoiceRecognitionAction { // 启动语音识别 [[BDVoiceRecognitionClient sharedInstance] setApiKey:API_KEY withSecretKey:SECRET_KEY]; [[BDVoiceRecognitionClient sharedInstance] setNeedVadFlag:NO]; [[BDVoiceRecognitionClient sharedInstance] setResourceType:0]; [[BDVoiceRecognitionClient sharedInstance] setLanguage:0]; int startStatus = -1; startStatus = [[BDVoiceRecognitionClient sharedInstance] startVoiceRecognition:self]; if (startStatus != EVoiceRecognitionStartWorking) { // 处理启动出错 } } 这样启动之后, // 实现委托 - (void)VoiceRecognitionClientErrorStatus:(int) aStatus subStatus:(int)aSubStatus { // 处理出错 // [self stopVoiceRecognitionAction]; // [self startVoiceRecognitionAction]; } - (void)VoiceRecognitionClientWorkStatus:(int)aStatus obj:(id)aObj { //处理网络状态变化 // NSLog(@"%d",aStatus); // NSString *str ; switch (aStatus) { case EVoiceRecognitionClientWorkStatusFlushData: // 连续上屏中间结果 { // NSString *text = [aObj objectAtIndex:0]; // // if ([text length] > 0) // { // str = text; // } // break; } case EVoiceRecognitionClientWorkStatusFinish: // 识别正常完成并获得结果 { // NSString *tmpString = [[BDVRSConfig sharedInstance] composeInputModeResult:aObj]; // str = tmpString; // // break; } case 14:{ } } // NSLog(@"%@",str); // if(str.length >=3){ // for (NSString *keyword in [UserClient sharedUserClient].keywordArray) { // if([str containsString:keyword]){ // [self stopVoiceRecognitionAction]; // AudioServicesPlaySystemSound (kSystemSoundID_Vibrate); // if(SharedAppDelegate.isBackGround){ // [self.startHelppingCommand execute:nil]; // NSString * url = [NSString stringWithFormat:@"%@?start=%@", // URL_CallHelpViewController,@"isStart"]; // [self.viewController pushViewControllerWithUrl:url]; // }else{ // [self.callHelpUpInsideCommand execute:nil]; // } // } // } // } } 代码注视掉之后,1分钟左右就会进入出错的代理