首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >iOS端 为什么TAIOralEvaluationDelegate的代理方法没有调用?

iOS端 为什么TAIOralEvaluationDelegate的代理方法没有调用?

提问于 2019-04-19 14:55:43
回答 1关注 0查看 472
代码语言:objectivec
复制
#pragma mark - oral evaluation delegate
- (void)oralEvaluation:(TAIOralEvaluation *)oralEvaluation onEvaluateData:(TAIOralEvaluationData *)data result:(TAIOralEvaluationRet *)result error:(TAIError *)error
{
    if(error.code != TAIErrCode_Succ){
       [SilenceHUDUtil showError:@"录制失败!"];
        self.isRecording = NO;
    }
    
//    NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath:self.filePath];
//    [handle seekToEndOfFile];
//    [handle writeData:data.audio];
    NSLog(@"%s",__func__);
    NSLog(@"oralEvaluation:datasize:%lu seq:%ld, end:%ld, error:%@, ret:%@",(unsigned long)data.audio.length,(long)data.seqId, (long)data.bEnd, error, result);
    if(data.bEnd){
        NSLog(@"结果%@",result);
    }
}

-(void)beginRecordWithFileName:(NSString *)fileName andTestString:(NSString *)testString{
    self.fileName = fileName;
   TAIOralEvaluationParam* param = [[TAIOralEvaluationParam alloc] init];
    param.sessionId = @((int)[[NSDate date] timeIntervalSince1970]).stringValue;
    param.appId = [PrivateInfo shareInstance].appId;
    param.soeAppId = [PrivateInfo shareInstance].soeAppId;
    param.secretId = [PrivateInfo shareInstance].secretId;
    param.secretKey = [PrivateInfo shareInstance].secretKey;
    param.workMode = TAIOralEvaluationWorkMode_Stream;
    param.evalMode = TAIOralEvaluationEvalMode_Paragraph;
    param.serverType = TAIOralEvaluationServerType_English;
    param.scoreCoeff = 3;
    param.fileType = TAIOralEvaluationFileType_Mp3;
    param.storageMode = TAIOralEvaluationStorageMode_Enable;
    param.textMode = TAIOralEvaluationTextMode_Noraml;
    param.retryTimes = 5;
    param.refText = @"hello hello hello hello hello hello hello hello hello hello";
    param.timeout = 30;
    
    NSLog(@"测试文本:%@",testString);
    NSString *path = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
    path = [path stringByAppendingPathComponent:@"TencentSeo"];
    self.filePath = [path stringByAppendingPathComponent:self.fileName];
    if([[NSFileManager defaultManager] fileExistsAtPath:path] == false){
        [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    }else if([[NSFileManager defaultManager] fileExistsAtPath:self.filePath] == false){
      BOOL isCreatFileOK = [[NSFileManager defaultManager] createFileAtPath:self.filePath contents:nil attributes:nil];
        NSLog(@"创建文件%@",isCreatFileOK?@"成功":@"失败");
    }
    
    [self.oralEvaluation setFragSize:1024.0];
    [self.oralEvaluation startRecordAndEvaluation:self.param callback:^(TAIError *error) {
        if(error.code == TAIErrCode_Succ){
            self.isRecording = YES;
        }
//        [ws setResponse:[NSString stringWithFormat:@"startRecordAndEvaluation:%@", error]];
        NSLog(@"startRecordAndEvaluation:%@",error);
    }];
}
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档