简介
本文档提供关于提交语音识别任务、查询指定的语音识别任务、批量拉取语音识别任务相关的 API 概览以及 SDK 示例代码。
API | 说明 |
接口用于提交一个语音识别任务。 | |
用于查询指定的语音识别任务。 | |
用于拉取符合条件的语音识别任务。 |
SDK API 参考
提交语音识别任务
功能说明
接口用于提交一个语音识别任务。
注意
COS iOS SDK 版本需要大于等于 v6.1.3。
示例代码
Objective-C
QCloudPostAudioDiscernTaskRequest * request = [[QCloudPostAudioDiscernTaskRequest alloc]init];// 存储桶名称,格式为 BucketName-APPIDrequest.bucket = @"examplebucket-1250000000";request.regionName = @"regionName";QCloudPostAudioDiscernTaskInfo* taskInfo = [QCloudPostAudioDiscernTaskInfo new];taskInfo.Tag = @"SpeechRecognition";// 操作规则QCloudPostAudioDiscernTaskInfoInput * input = QCloudPostAudioDiscernTaskInfoInput.new;input.Object = @"test1";// 待操作的语音文件taskInfo.Input = input;QCloudPostAudioDiscernTaskInfoOperation * op = [QCloudPostAudioDiscernTaskInfoOperation new];QCloudPostAudioDiscernTaskInfoOutput * output = QCloudPostAudioDiscernTaskInfoOutput.new;output.Region = @"regionName";output.Bucket = @"examplebucket-1250000000";output.Object = @"test";// 结果输出地址op.Output = output;QCloudPostAudioDiscernTaskInfoSpeechRecognition * speechRecognition = [QCloudPostAudioDiscernTaskInfoSpeechRecognition new];speechRecognition.EngineModelType =@"16k_zh";speechRecognition.ChannelNum = 1;speechRecognition.ResTextFormat = 0;speechRecognition.ConvertNumMode = 0;// 当 Tag 为 SpeechRecognition 时有效,指定该任务的参数op.SpeechRecognition = speechRecognition;// 操作规则taskInfo.Operation = op;// 语音识别任务request.taskInfo = taskInfo;[request setFinishBlock:^(QCloudPostAudioDiscernTaskResult * _Nullable result, NSError * _Nullable error) {// outputObject 提交审核反馈信息 包含用于查询的job id,详细字段请查看api文档或者SDK源码// QCloudPostAudioDiscernTaskResult 类;}];[[QCloudCOSXMLService defaultCOSXML] PostAudioDiscernTask:request];
说明
Swift
let request = QCloudPostAudioDiscernTaskRequest.init();// 存储桶名称,格式为 BucketName-APPIDrequest.bucket = "examplebucket-1250000000";request.regionName = "regionName";let taskInfo = QCloudPostAudioDiscernTaskInfo.init();taskInfo.tag = "SpeechRecognition";// 操作规则let input = QCloudPostAudioDiscernTaskInfoInput.init();input.object = "test1";// 待操作的语音文件taskInfo.input = input;let op = QCloudPostAudioDiscernTaskInfoOperation.init();let output = QCloudPostAudioDiscernTaskInfoOutput.init();output.region = "regionName";output.bucket = "examplebucket-1250000000";output.object = "test";// 结果输出地址op.output = output;let speechRecognition = QCloudPostAudioDiscernTaskInfoSpeechRecognition.init();speechRecognition.engineModelType = "16k_zh";speechRecognition.channelNum = 1;speechRecognition.resTextFormat = 0;speechRecognition.convertNumMode = 0;// 当 Tag 为 SpeechRecognition 时有效,指定该任务的参数op.speechRecognition = speechRecognition;// 操作规则taskInfo.operation = op;// 语音识别任务request.taskInfo = taskInfo;[request .setFinish({ outputObject, error in// outputObject 提交审核反馈信息 包含用于查询的job id,详细字段请查看api文档或者SDK源码// QCloudPostAudioDiscernTaskResult 类;})];QCloudCOSXMLService.defaultCOSXML().postAudioDiscernTask(request);
说明
查询指定的语音识别任务
功能说明
用于查询指定的语音识别任务。
注意
COS iOS SDK 版本需要大于等于 v6.1.3。
示例代码
Objective-C
QCloudGetAudioDiscernTaskRequest * request = [[QCloudGetAudioDiscernTaskRequest alloc]init];// 存储桶名称,格式为 BucketName-APPIDrequest.bucket = @"examplebucket-1250000000";// QCloudPostAudioDiscernTaskRequest接口返回的jobidrequest.jobId = @"jobid";request.regionName = @"regionName";request.finishBlock = ^(QCloudGetAudioDiscernTaskResult * outputObject, NSError *error) {// outputObject 详细字段请查看api文档或者SDK源码// QCloudGetAudioDiscernTaskResult 类;};[[QCloudCOSXMLService defaultCOSXML] GetAudioDiscernTask:request];
说明
Swift
let request = QCloudGetAudioDiscernTaskRequest.init();// 存储桶名称,格式为 BucketName-APPIDrequest.bucket = "examplebucket-1250000000";// QCloudPostAudioDiscernTaskRequest接口返回的jobidrequest.jobId = "jobid";request.regionName = "regionName";request.setFinish { outputObject, error in// outputObject 详细字段请查看api文档或者SDK源码// QCloudGetAudioDiscernTaskResult 类;};QCloudCOSXMLService.defaultCOSXML().getAudioDiscernTask(request);
说明
批量拉取语音识别任务
功能说明
用于拉取符合条件的语音识别任务。
注意
COS iOS SDK 版本需要大于等于 v6.1.3。
示例代码
Objective-C
QCloudBatchGetAudioDiscernTaskRequest * request = [[QCloudBatchGetAudioDiscernTaskRequest alloc]init];// 存储桶名称,格式为 BucketName-APPIDrequest.bucket = @"examplebucket-1250000000";request.regionName = @"regionName";request.states = QCloudTaskStatesSuccess | QCloudTaskStatesCancel;// 其他更多参数请查阅sdk文档或源码注释request.finishBlock = ^(QCloudBatchGetAudioDiscernTaskResult * outputObject, NSError *error) {// outputObject 任务结果,详细字段请查看api文档或者SDK源码// QCloudBatchGetAudioDiscernTaskResult 类;};[[QCloudCOSXMLService defaultCOSXML] BatchGetAudioDiscernTask:request];
说明
Swift
let request = QCloudBatchGetAudioDiscernTaskRequest.init();// 存储桶名称,格式为 BucketName-APPIDrequest.bucket = "examplebucket-1250000000";request.regionName = "regionName";request.states = QCloudTaskStatesEnum(rawValue: QCloudTaskStatesEnum.success.rawValue | QCloudTaskStatesEnum.cancel.rawValue)!;// 其他更多参数请查阅sdk文档或源码注释request.setFinish { outputObject, error in// outputObject 任务结果,详细字段请查看api文档或者SDK源码// QCloudBatchGetAudioDiscernTaskResult 类;};QCloudCOSXMLService.defaultCOSXML().batchGetAudioDiscernTask(request);
说明