云服务器内容精选
-
SDK列表及指导文档(通用版) API Explorer 能根据需要动态生成SDK代码功能,降低您使用SDK的难度,推荐使用。 SDK中心 提供服务SDK依赖引入的方式。 表1 提供了各个云服务支持的SDK列表,您可以在GitHub仓库查看SDK更新历史、获取安装包以及查看指导文档进行配置。 表1 SDK列表 编程语言 github地址 指导文档 视频指导 JAVA huaweicloud-sdk-java-v3 Java SDK使用指导 Java SDK视频指导 PYTHON huaweicloud-sdk-python-v3 Python SDK使用指导 Python SDK视频指导 .NET huaweicloud-sdk-net-v3 .Net SDK使用指导 - GO huaweicloud-sdk-go-v3 Go SDK使用指导 - PHP huaweicloud-sdk-php-v3 PHP SDK使用指导 - Node.js huaweicloud-sdk-nodejs-v3 Node.js SDK使用指导 -
-
PHP环境SDK导入 PHP版本, 内容审核 服务推荐您使用 Composer 安装 SDK 。Composer 是 Php 的依赖管理工具,允许您在项目中声明依赖关系并安装这些依赖: // 安装 Composercurl -sS https://getcomposer.org/installer | php// 安装 PHP SDKcomposer require huaweicloud/huaweicloud-sdk-php 安装完毕后,你需要引入 Composer 的自动加载文件: require 'path/to/vendor/autoload.php'; 父主题: 使用SDK(PHP)
-
查询视频内容审核作业 本章节对查询 视频审核 AK/SK方式使用SDK进行示例说明。 示例代码中需要配置使用RunQueryVideoModerationJobRequest类的withJobId配置审核任务的id,配置完成后运行即可。 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" moderation "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/region") func main() { // 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全; // 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK。 ak := os.Getenv("HUAWEICLOUD_SDK_AK") sk := os.Getenv("HUAWEICLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := moderation.NewModerationClient( moderation.ModerationClientBuilder(). WithRegion(region.ValueOf("xxx")). //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 WithCredential(auth). Build()) request := &model.RunQueryVideoModerationJobRequest{} request.JobId = "xxxx" //此处需要输入您的jobID response, err := client.RunQueryVideoModerationJob(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) }} 控制台输出查询视频内容审核作业提交的结果,查询视频内容审核结果输出到控制台。 RunQueryVideoModerationJobResponse {"request_id":"xxxx","job_id":"xxx","status":"succeeded","request_params":{"data":{"url":"xxxx","frame_interval":5},"event_type":"default","image_categories":["porn","terrorism","image_text"],"audio_categories":["porn","ad","moan","abuse"],"callback":"xxx"},"create_time":"2022-07-30T08:57:11.011Z","update_time":"2022-07-30T08:57:14.014Z","result":{"suggestion":"block","image_detail":[{"suggestion":"block","category":"porn","ocr_text":"123","time":0,"detail":[{"confidence":0.676015138626099,"category":"porn","suggestion":"block","label":"pornography"},{"confidence":0.666015138626099,"category":"porn","suggestion":"review","label":"sexy_female"},{"confidence":0.666015138626099,"category":"xxx","suggestion":"block","label":"leader"},{"confidence":0.691423773765564,"category":"xxx","suggestion":"block","face_location":{"top_left_x":12,"top_left_y":13,"bottom_right_x":200,"bottom_right_y":240},"label":"leader"},{"confidence":0.691423773765564,"category":"porn","suggestion":"block","face_location":{"top_left_x":12,"top_left_y":13,"bottom_right_x":100,"bottom_right_y":2000},"label":"leader"},{"confidence":0.891423773765564,"category":"image_text","suggestion":"block","label":"qr_code"},{"confidence":0.891423773765564,"category":"image_text","suggestion":"block","label":"qr_code","qr_content":"xxxxxxxxx","qr_location":{"top_left_x":12,"top_left_y":13,"bottom_right_x":100,"bottom_right_y":2000}},{"confidence":0.891423773765564,"category":"image_text","suggestion":"block","label":"porn","segments":[{"segment":"xxx"},{"segment":"xx"}]}]}],"audio_detail":[{"suggestion":"block","label":"porn","audio_text":"xxxxx","end_time":10,"start_time":0,"detail":[{"confidence":0.999117187582349,"label":"porn","suggestion":"block","segments":[{"segment":"xxx"}]},{"confidence":0.885117187582349,"label":"porn","suggestion":"block"}]}]}} 父主题: 视频审核
-
查询视频内容审核作业 本章节对查询视频审核AK/SK方式使用SDK进行示例说明。 示例代码中需要配置使用RunQueryVideoModerationJobRequest类的withJobId配置审核任务的id,配置完成后运行即可。 服务所在的应用区域和终端节点,详情请查看 地区和终端节点 。 using System;using System.Collections.Generic;using HuaweiCloud.SDK.Core;using HuaweiCloud.SDK.Core.Auth;using HuaweiCloud.SDK.Moderation;using HuaweiCloud.SDK.Moderation.V3;using HuaweiCloud.SDK.Moderation.V3.Model;namespace RunQueryVideoModerationJobSolution{ class Program { static void Main(string[] args) { //认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全 //本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK string ak= Environment.GetEnvironmentVariable("HUAWEICLOUD_SDK_AK", EnvironmentVariableTarget.Machine); string sk= Environment.GetEnvironmentVariable("HUAWEICLOUD_SDK_SK", EnvironmentVariableTarget.Machine); var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk); var client = ModerationClient.NewBuilder() .WithCredential(auth) .WithRegion(ModerationRegion.ValueOf("xxx")) //把xxx替换成服务所在的区域,例如北京四:cn-north-4 .WithHttpConfig(config) .Build(); var req = new RunQueryVideoModerationJobRequest { JobId = "xxxx" //此处需要输入您的jobID }; try { var resp = client.RunQueryVideoModerationJob(req); var respStatusCode = resp.HttpStatusCode; Console.WriteLine(respStatusCode);Console.WriteLine(JsonConvert.DeserializeObject(resp.HttpBody)); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } } }} 控制台输出查询视频内容审核作业提交的结果,查询视频内容审核结果输出到控制台。 200{ "request_id":"xxxx", "job_id":"xxx", "status":"succeeded", "request_params":{ "data":{ "url":"xxxx", "frame_interval":5 }, "event_type":"default", "image_categories":[ "porn", "terrorism", "image_text" ], "audio_categories":[ "porn", "ad", "moan", "abuse" ], "callback":"xxx" }, "create_time":"2022-07-30T08:57:11.011Z", "update_time":"2022-07-30T08:57:14.014Z", "result":{ "suggestion":"block", "image_detail":[ { "suggestion":"block", "category":"porn", "ocr_text":"123", "time":0, "detail":[ { "confidence":0.676015138626099, "category":"porn", "suggestion":"block", "label":"pornography" }, { "confidence":0.666015138626099, "category":"porn", "suggestion":"review", "label":"sexy_female" }, { "confidence":0.666015138626099, "category":"xxx", "suggestion":"block", "label":"leader" }, { "confidence":0.691423773765564, "category":"xxx", "suggestion":"block", "face_location":{ "top_left_x":12, "top_left_y":13, "bottom_right_x":200, "bottom_right_y":240 }, "label":"leader" }, { "confidence":0.691423773765564, "category":"porn", "suggestion":"block", "face_location":{ "top_left_x":12, "top_left_y":13, "bottom_right_x":100, "bottom_right_y":2000 }, "label":"leader" }, { "confidence":0.891423773765564, "category":"image_text", "suggestion":"block", "label":"qr_code" }, { "confidence":0.891423773765564, "category":"image_text", "suggestion":"block", "label":"qr_code", "qr_content":"xxxxxxxxx", "qr_location":{ "top_left_x":12, "top_left_y":13, "bottom_right_x":100, "bottom_right_y":2000 } }, { "confidence":0.891423773765564, "category":"image_text", "suggestion":"block", "label":"porn", "segments":[ { "segment":"xxx" }, { "segment":"xx" } ] } ] } ], "audio_detail":[ { "suggestion":"block", "label":"porn", "audio_text":"xxxxx", "end_time":10, "start_time":0, "detail":[ { "confidence":0.999117187582349, "label":"porn", "suggestion":"block", "segments":[ { "segment":"xxx" } ] }, { "confidence":0.885117187582349, "label":"porn", "suggestion":"block" } ] } ] }} 父主题: 视频审核
-
文本内容审核 (V3) 本章节对文本内容审核AK/SK方式使用SDK进行示例说明。 示例代码中可以修改TextDetectionDataReq的Text 配置待检测的文本信息,配置完成后运行即可。 服务所在的应用区域和终端节点,详情请查看 地区和终端节点 。 1 2 3 4 5 6 7 8 91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 using System;using System.Collections.Generic;using HuaweiCloud.SDK.Core;using HuaweiCloud.SDK.Core.Auth;using HuaweiCloud.SDK.Moderation;using HuaweiCloud.SDK.Moderation.V3;using HuaweiCloud.SDK.Moderation.V3.Model; namespace RunTextModerationSolution{ class Program { static void Main(string[] args) { //认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全 //本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK string ak= Environment.GetEnvironmentVariable("HUAWEICLOUD_SDK_AK", EnvironmentVariableTarget.Machine); string sk= Environment.GetEnvironmentVariable("HUAWEICLOUD_SDK_SK", EnvironmentVariableTarget.Machine); var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk); var client = ModerationClient.NewBuilder() .WithCredential(auth) .WithRegion(ModerationRegion.ValueOf("xxx")) //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 .WithHttpConfig(config) .Build(); var req = new RunTextModerationRequest { }; TextDetectionDataReq databody = new TextDetectionDataReq() { Text = "test" }; req.Body = new TextDetectionReq() { Data = databody, EventType = "comment" }; try { var resp = client.RunTextModeration(req); var respStatusCode = resp.HttpStatusCode; Console.WriteLine(respStatusCode); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } } }} 控制台输出200即表示程序执行成功,文本内容审核结果输出到控制台。 200 { "request_id":"d81702cfd3599e103030c3d52d6f955f", "result":{ "suggestion":"pass", "label":"normal", "details":[] } } 父主题: 文本审核
-
查询音频内容审核作业 本章节对查询音频内容审核AK/SK方式使用SDK进行示例说明。 示例代码中需要配置使用RunQueryAudioModerationJobRequest类的withJobId配置审核任务的id,配置完成后运行即可。 服务所在的应用区域和终端节点,详情请查看 地区和终端节点 。 using System;using System.Collections.Generic;using HuaweiCloud.SDK.Core;using HuaweiCloud.SDK.Core.Auth;using HuaweiCloud.SDK.Moderation;using HuaweiCloud.SDK.Moderation.V3;using HuaweiCloud.SDK.Moderation.V3.Model; namespace RunQueryAudioModerationJobSolution{ class Program { static void Main(string[] args) { //认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全 //本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK string ak= Environment.GetEnvironmentVariable("HUAWEICLOUD_SDK_AK", EnvironmentVariableTarget.Machine); string sk= Environment.GetEnvironmentVariable("HUAWEICLOUD_SDK_SK", EnvironmentVariableTarget.Machine); var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk); var client = ModerationClient.NewBuilder() .WithCredential(auth) .WithRegion(ModerationRegion.ValueOf("xxx")) //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 .WithHttpConfig(config) .Build(); var req = new RunQueryAudioModerationJobRequest { JobId = "xxx" //此处需要输入您的jobID }; try { var resp = client.RunQueryAudioModerationJob(req); var respStatusCode = resp.HttpStatusCode; Console.WriteLine(respStatusCode);Console.WriteLine(JsonConvert.DeserializeObject(resp.HttpBody)); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } } }} 控制台输出200即表示程序执行成功,查询音频内容审核结果输出到控制台。 200{ "job_id":"xxx", "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"} 父主题: 音频审核
-
创建视频内容审核作业 本章节对创建视频审核AK/SK方式使用SDK进行示例说明。 示例代码中可以使用RunCreateVideoModerationJobRequest类的withUrls配置待审核的视频url(仅支持url方式),配置完成后运行即可。 服务所在的应用区域和终端节点,详情请查看 地区和终端节点 。 # 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 = RunCreateVideoModerationJobRequest() listAudioCategoriesbody = [ "porn" ] listImageCategoriesbody = [ "porn" ] databody = VideoCreateRequestData( url="http://xxx.xx.xxxx", frame_interval=5.5 ) request.body = VideoCreateRequest( callback="http://xxx.xx.xxxx", audio_categories=listAudioCategoriesbody, image_categories=listImageCategoriesbody, event_type="default", data=databody ) response = client.run_create_video_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) 控制台输出创建视频内容审核作业的结果,创建视频内容审核结果输出到控制台。 {"request_id": "dbbcb75d1a174bfa899a38be38fdd107", "job_id": "xxx"} 父主题: 视频审核
-
创建视频内容审核作业 本章节对创建视频审核AK/SK方式使用SDK进行示例说明。 示例代码中可以使用RunCreateVideoModerationJobRequest类的withUrls配置待审核的视频url(仅支持url方式),配置完成后运行即可。 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" moderation "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/region") func main() { // 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全; // 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK。 ak := os.Getenv("HUAWEICLOUD_SDK_AK") sk := os.Getenv("HUAWEICLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := moderation.NewModerationClient( moderation.ModerationClientBuilder(). WithRegion(region.ValueOf("xxx")). //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 WithCredential(auth). Build()) request := &model.RunCreateVideoModerationJobRequest{} var listAudioCategoriesbody = []model.VideoCreateRequestAudioCategories{ model.GetVideoCreateRequestAudioCategoriesEnum().PORN, } var listImageCategoriesbody = []model.VideoCreateRequestImageCategories{ model.GetVideoCreateRequestImageCategoriesEnum().PORN, } frameIntervalData:= float32(5.5) databody := &model.VideoCreateRequestData{ Url: "http://xxx.xx.xxxx", FrameInterval: &frameIntervalData, } callbackVideoCreateRequest:= "http://xxx.xx.xxxx" request.Body = &model.VideoCreateRequest{ Callback: &callbackVideoCreateRequest, AudioCategories: &listAudioCategoriesbody, ImageCategories: listImageCategoriesbody, EventType: model.GetVideoCreateRequestEventTypeEnum().DEFAULT, Data: databody, } response, err := client.RunCreateVideoModerationJob(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) }} 控制台输出创建视频内容审核作业的结果,创建视频内容审核结果输出到控制台。 RunCreateVideoModerationJobResponse{"request_id":"dbbcb75d1a174bfa899a38be38fdd107", "job_id": "xxx"} 父主题: 视频审核
-
查询音频内容审核作业 本章节对查询音频审核AK/SK方式使用SDK进行示例说明。 示例代码中需要配置使用RunQueryAudioModerationJobRequest类的withJobId配置审核任务的id,配置完成后运行即可。 服务所在的应用区域和终端节点,详情请查看 地区和终端节点 。 package com.huaweicloud.sdk.test;import com.huaweicloud.sdk.core.auth.ICredential;import com.huaweicloud.sdk.core.auth.BasicCredentials;import com.huaweicloud.sdk.core.exception.ConnectionException;import com.huaweicloud.sdk.core.exception.RequestTimeoutException;import com.huaweicloud.sdk.core.exception.ServiceResponseException;import com.huaweicloud.sdk.moderation.v3.region.ModerationRegion;import com.huaweicloud.sdk.moderation.v3.*;import com.huaweicloud.sdk.moderation.v3.model.*;public class RunQueryAudioModerationJobSolution { public static void main(String[] args) { // 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全 // 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK String ak = System.getenv("HUAWEICLOUD_SDK_AK"); String sk = System.getenv("HUAWEICLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); ModerationClient client = ModerationClient.newBuilder() .withCredential(auth) .withRegion(ModerationRegion.valueOf("xxx")) //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 .build(); RunQueryAudioModerationJobRequest request = new RunQueryAudioModerationJobRequest(); request.withJobId("xxx"); try { RunQueryAudioModerationJobResponse response = client.runQueryAudioModerationJob(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } }} 控制台输出查询音频内容审核作业的结果,查询音频内容审核结果输出到控制台。 class RunQueryAudioModerationJobResponse { jobId: 01661702400_cd06d61c16a14565995fcbfb04877bd3 status: running result: null requestParams: class AudioModerationResultRequestParams { eventType: default data: class AudioModerationResultRequestParamsData { url: https://****.wav } callback: null categories: [porn] } createTime: 2022-08-29T11:57:14.014Z updateTime: 2022-08-29T11:57:14.014Z requestId: 57ea754a1fdec2d13e4e8ffbff6a458d} 父主题: 音频审核
-
文本内容审核(V3) 本章节对文本内容审核AK/SK方式使用SDK进行示例说明。 示例代码中可以将TextDetectionDataReq的text配置待检测的文本信息,配置完成后运行即可。 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839404142 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" moderation "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/region") func main() { // 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全; // 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK。 ak := os.Getenv("HUAWEICLOUD_SDK_AK") sk := os.Getenv("HUAWEICLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := moderation.NewModerationClient( moderation.ModerationClientBuilder(). WithRegion(region.ValueOf("xxx")). //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 WithCredential(auth). Build()) request := &model.RunTextModerationRequest{} databody := &model.TextDetectionDataReq{ Text: "text", } request.Body = &model.TextDetectionReq{ Data: databody, EventType: "comment", } response, err := client.RunTextModeration(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) }} 审核结果输出到控制台表示执行成功,文本内容审核结果输出到控制台。 RunTextModerationResponse {"request_id": "d81702cfd3599e103030c3d52d6f955f", "result": {"suggestion": "pass", "label": "normal", "details": []}} 父主题: 文本审核
-
文本内容审核(v3) 本章节对文本内容审核AK/SK方式使用SDK进行示例说明。 示例代码中修改TextDetectionDataReq的text值配置待检测的文本信息,配置完成后运行即可。 服务所在的应用区域和终端节点,详情请查看 地区和终端节点 。 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637 # 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 = RunTextModerationRequest() databody = TextDetectionDataReq( text="test" ) request.body = TextDetectionReq( data=databody, event_type="comment" ) response = client.run_text_moderation(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) 控制台输出200即表示程序执行成功,文本内容审核结果输出到控制台。 {"request_id": "d81702cfd3599e103030c3d52d6f955f", "result": {"suggestion": "pass", "label": "normal", "details": []}} 父主题: 文本审核
-
文本内容审核(V3) 本章节对文本内容审核AK/SK方式使用SDK进行示例说明。 示例代码中可以使用TextDetectionDataReq类的withText方法配置待检测的文本信息,配置完成后运行即可。 服务所在的应用区域和终端节点,详情请查看 地区和终端节点 。 package com.huaweicloud.sdk.test;import com.huaweicloud.sdk.core.auth.ICredential;import com.huaweicloud.sdk.core.auth.BasicCredentials;import com.huaweicloud.sdk.core.exception.ConnectionException;import com.huaweicloud.sdk.core.exception.RequestTimeoutException;import com.huaweicloud.sdk.core.exception.ServiceResponseException;import com.huaweicloud.sdk.core.region.Region;import com.huaweicloud.sdk.moderation.v3.*;import com.huaweicloud.sdk.moderation.v3.model.*;public class RunTextModerationSolution { public static void main(String[] args) { // 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全 // 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK String ak = System.getenv("HUAWEICLOUD_SDK_AK"); String sk = System.getenv("HUAWEICLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); ModerationClient client = ModerationClient.newBuilder() .withCredential(auth) .withRegion(ModerationRegion.valueOf("xxx")) //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 .build(); RunTextModerationRequest request = new RunTextModerationRequest(); TextDetectionReq body = new TextDetectionReq(); TextDetectionDataReq databody = new TextDetectionDataReq(); databody.withText("test"); body.withData(databody); body.withEventType("comment"); request.withBody(body); try { RunTextModerationResponse response = client.runTextModeration(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } }} 控制台输出200即表示程序执行成功,文本内容审核结果输出到控制台。 class RunTextModerationResponse { requestId: 308b6ad2740e51de73597da9fdc94ee1 result: class TextDetectionResult { suggestion: pass label: normal details: [] }} 父主题: 文本审核
-
查询音频内容审核作业 本章节对查询音频审核AK/SK方式使用SDK进行示例说明。 示例代码中需要配置使用RunQueryAudioModerationJobRequest类的withJobId配置审核任务的id,配置完成后运行即可。 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" moderation "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v3/region") func main() { // 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全; // 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK。 ak := os.Getenv("HUAWEICLOUD_SDK_AK") sk := os.Getenv("HUAWEICLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := moderation.NewModerationClient( moderation.ModerationClientBuilder(). WithRegion(region.ValueOf("xxx")). //把xxx替换成服务所在的区域,例如北京四:cn-north-4。 WithCredential(auth). Build()) request := &model.RunQueryAudioModerationJobRequest{} request.JobId = "" response, err := client.RunQueryAudioModerationJob(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) }} 控制台输出查询音频内容审核的结果,查询音频内容审核结果输出到控制台。 RunQueryAudioModerationJobResponse {"job_id": "xxx", "status": "running", "request_params": {"event_type": "default", "data": {"url": "https://***.wav"}, "categories": ["porn"]}, "create_time": "2022-08-29T11:57:14.014Z", "update_time": "2022-08-29T11:57:14.014Z", "request_id": "c16c9fdeb3c1b838d9cec08ada4b6b96"} 父主题: 音频审核
-
查询音频内容审核作业 本章节对查询音频审核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) 控制台输出查询音频内容审核作业提交的结果,查询音频内容审核结果输出到控制台。 {"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"} 父主题: 音频审核
-
内容审核概述 内容审核( Content Moderation ),是基于图像、文本、音频、视频、音频流、视频流、文档的检测技术,可自动检测涉黄、广告等内容,对用户上传的图片、文字进行内容审核,帮助客户降低业务违规风险。 内容审核以开放API(Application Programming Interface,应用程序编程接口)的方式提供给用户,用户通过实时访问和调用API获取推理结果,帮助用户自动采集关键数据,打造智能化业务系统,提升业务效率。
更多精彩内容
CDN加速
GaussDB
文字转换成语音
免费的服务器
如何创建网站
域名网站购买
私有云桌面
云主机哪个好
域名怎么备案
手机云电脑
SSL证书申请
云点播服务器
免费OCR是什么
电脑云桌面
域名备案怎么弄
语音转文字
文字图片识别
云桌面是什么
网址安全检测
网站建设搭建
国外CDN加速
SSL免费证书申请
短信批量发送
图片OCR识别
云数据库MySQL
个人域名购买
录音转文字
扫描图片识别文字
OCR图片识别
行驶证识别
虚拟电话号码
电话呼叫中心软件
怎么制作一个网站
Email注册网站
华为VNC
图像文字识别
企业网站制作
个人网站搭建
华为云计算
免费租用云托管
云桌面云服务器
ocr文字识别免费版
HTTPS证书申请
图片文字识别转换
国外域名注册商
使用免费虚拟主机
云电脑主机多少钱
鲲鹏云手机
短信验证码平台
OCR图片文字识别
SSL证书是什么
申请企业邮箱步骤
免费的企业用邮箱
云免流搭建教程
域名价格