内容审核 Moderation-查询音频内容审核作业

时间:2025-01-26 10:44:24

查询音频 内容审核 作业

  1. 本章节对查询音频审核AK/SK方式使用SDK进行示例说明。

    示例代码中需要配置使用RunQueryAudioModerationJobRequest类的withJobId配置审核任务的id,配置完成后运行即可。

    服务所在的应用区域和终端节点,详情请查看 地区和终端节点

    # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentialsfrom huaweicloudsdkmoderation.v3.region.moderation_region import ModerationRegionfrom huaweicloudsdkcore.exceptions import exceptionsfrom huaweicloudsdkmoderation.v3 import *import os if __name__ == "__main__":    # 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全;    # 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK。    ak = os.getenv("HUAWEICLOUD_SDK_AK")    sk = os.getenv("HUAWEICLOUD_SDK_SK")    credentials = BasicCredentials(ak, sk) \     client = ModerationClient.new_builder() \        .with_credentials(credentials) \        .with_region(ModerationRegion.value_of("xxx")) \    //把xxx替换成服务所在的区域,例如北京四:cn-north-4。        .build()     try:        request = RunQueryAudioModerationJobRequest()        request.job_id = "xxx"   //此处需要输入您的jobID        response = client.run_query_audio_moderation_job(request)        print(response)    except exceptions.ClientRequestException as e:        print(e.status_code)        print(e.request_id)        print(e.error_code)        print(e.error_msg)
  2. 控制台输出查询音频内容审核作业提交的结果,查询音频内容审核结果输出到控制台。
    {"job_id":"xxxx","status":"succeeded","result":{"suggestion":"block","details":[{"start_time":0,"suggestion":"block","end_time":10,"label":"porn","audio_text":"xxxx","segments":[{"segment":"xxx"},{"segment":"xxx"},{"segment":"xxx"}]},{"start_time":30,"suggestion":"block","end_time":40,"label":"porn","audio_text":"xxx","segments":[{"segment":"xx"}]}],"audio_text":"xxxxxx"},"request_params":{"event_type":"default","data":{"url":"https://xxxx.wav"},"callback":"http://xxx","categories":["porn","ad"]},"create_time":"2022-06-20 11:05:29","update_time":"2022-06-20 11:07:08","request_id":"2419446b1fe14203f64e4018d12db3dd"}
support.huaweicloud.com/sdkreference-moderation/moderation_04_0060.html