API | 操作描述 |
用于提交一个音频审核任务 | |
用于查询指定的音频审核任务 |
using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitAudioCensorJobModel {private CosXml cosXml;SubmitAudioCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // 设置默认的地域, COS 地域的简称请参照 https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1.Build();string secretId = "SECRET_ID"; // 云 API 密钥 SecretId, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capistring secretKey = "SECRET_KEY"; // 云 API 密钥 SecretKey, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capilong durationSecond = 600; //每次请求签名有效时长,单位为秒QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}// 提交音频审核任务public string SubmitAudioCensorJob(){// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000"; // 注意:此操作需要 bucket 开通内容审核相关功能SubmitAudioCensorJobRequest request = new SubmitAudioCensorJobRequest(bucket);request.SetCensorObject("audio.mp3"); // 媒体文件的对象键,需要替换成桶内存在的媒体文件的对象键// 审核的场景类型,有效值:Porn(涉黄)、Ads(广告),可以传入多种类型,不同类型以逗号分隔,例如:Porn,Adsrequest.SetDetectType("Porn,Ads");// 执行请求SubmitCensorJobResult result = cosXml.SubmitAudioCensorJob(request);Console.WriteLine(result.GetResultInfo());Console.WriteLine(result.censorJobsResponse.JobsDetail.JobId);Console.WriteLine(result.censorJobsResponse.JobsDetail.State);Console.WriteLine(result.censorJobsResponse.JobsDetail.CreationTime);return result.censorJobsResponse.JobsDetail.JobId;}static void Main(string[] args){SubmitAudioCensorJobModel m = new SubmitAudioCensorJobModel();// 提交审核任务string JobId = m.SubmitAudioCensorJob();// 打印唯一标识此次审核任务的 JobIdConsole.WriteLine("JobId : " + JobId);}}}
using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitAudioCensorJobModel {private CosXml cosXml;SubmitAudioCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // 设置默认的地域, COS 地域的简称请参照 https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1.Build();string secretId = "SECRET_ID"; // 云 API 密钥 SecretId, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capistring secretKey = "SECRET_KEY"; // 云 API 密钥 SecretKey, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capilong durationSecond = 600; //每次请求签名有效时长,单位为秒QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}// 查询音频审核任务结果public void GetAudioCensorJobResult(string JobId){// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000"; // 注意:此操作需要 bucket 开通内容审核相关功能GetAudioCensorJobRequest request = new GetAudioCensorJobRequest(bucket, JobId);// 执行请求GetAudioCensorJobResult result = cosXml.GetAudioCensorJob(request);Console.WriteLine(result.GetResultInfo());// 读取审核结果Console.WriteLine(result.resultStruct.JobsDetail.JobId);Console.WriteLine(result.resultStruct.JobsDetail.State);Console.WriteLine(result.resultStruct.JobsDetail.CreationTime);Console.WriteLine(result.resultStruct.JobsDetail.Object);Console.WriteLine(result.resultStruct.JobsDetail.Result);Console.WriteLine(result.resultStruct.JobsDetail.AudioText);Console.WriteLine(result.resultStruct.JobsDetail.PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.PornInfo.Score);Console.WriteLine(result.resultStruct.JobsDetail.PornInfo.Label);Console.WriteLine(result.resultStruct.JobsDetail.AdsInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.AdsInfo.Score);Console.WriteLine(result.resultStruct.JobsDetail.AdsInfo.Label);// 音频节选Section信息for(int i = 0; i < result.resultStruct.JobsDetail.Section.Count; i++){Console.WriteLine(result.resultStruct.JobsDetail.Section[i].Url);Console.WriteLine(result.resultStruct.JobsDetail.Section[i].OffsetTime);Console.WriteLine(result.resultStruct.JobsDetail.Section[i].Duration);Console.WriteLine(result.resultStruct.JobsDetail.Section[i].Text);Console.WriteLine(result.resultStruct.JobsDetail.Section[i].PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.Section[i].PornInfo.Score);Console.WriteLine(result.resultStruct.JobsDetail.Section[i].AdsInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.Section[i].AdsInfo.Score);}}static void Main(string[] args){SubmitAudioCensorJobModel m = new SubmitAudioCensorJobModel();// 输入提交审核任务时获取的 JobIdstring JobId = "xxx";// 查询审核任务结果m.GetAudioCensorJobResult(JobId);}}}
本页内容是否解决了您的问题?