#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);
}];
}
相似问题