tencent cloud

Feedback

ScanVoice

Last updated: 2022-12-08 10:03:46
This document is currently invalid. Please refer to the documentation page of the product.

1. API Description

Domain name for API request: gme.tencentcloudapi.com.

This API is used to submit a voice detection task. Up to 100 tasks can be added in the detection task list. Before using this API, please activate the Voice Content Moderation Service in GME Console > Voice Content Moderation > Service Configuration.


About the trial:

  • You can try out the Voice Content Moderation Service free of charge in GME Console > Voice Content Moderation > Product Trial.

  • API feature description:

  • This API checks voice streams or files for non-compliant content.
  • The detection result can be queried by setting the callback address (`Callback`) or calling the `DescribeScanResultList` API for polling.
  • The scenario can be specified, such as abusive or pornographic.
  • Detection tasks can be submitted in batches. Up to 100 tasks can be added in the detection task list.

  • Audio file limits:

  • Audio file size limit: 100 MB
  • Audio file duration limit: 30 minutes
  • Supported audio file formats: .wav, .m4a, .amr, .mp3, .aac, .wma, .ogg

  • Voice stream limits:

  • Supported voice stream formats: .m3u8, .flv
  • Supported voice stream transfer protocols: RTMP, HTTP, HTTPS
  • Voice stream duration limit: 4 hours
  • Audio/video stream separation and audio stream analysis are supported

  • `Scenes` and `Label` parameter description:

    When submitting a voice detection task, you need to specify the `Scenes` parameter. You are currently required to set the `Scenes` parameter to `["default"]`. The detection result will contain the scenario specified at the time of request and detection result in the corresponding type.

    Scenario Description Label
    Voice detection Voice detection type

    normal: Normal

    porn: Pornographic

    abuse: Abusive

    ad: Advertising

    illegal: Illegal

    moan: Moaning

    customized: Custom dictionary


    Callback description:

  • If the callback address parameter `Callback` (i.e., the URL of an HTTP(S) API) is specified in the request parameters, then the POST method should be supported and transferred data should be encoded with UTF-8.
  • After the callback data is pushed, if the HTTP status code received is 200, the push is successful.
  • HTTP header parameter description:
  • Item Type Required Description
    Signatue string Yes Signature. For more information, please see Signature generation description.
    • Signature generation description:
      • The HMAC-SH1 algorithm should be used, and the result should be encoded with Base64;
      • The original signature string is the entire JSON content of POST and body (the length is subject to `Content-Length`);
      • The signature key is the `SecretKey` of the application, which can be viewed in the console.
  • Sample callback (for more information on the fields, please see the structure: DescribeScanResult):
  • {
        "Code": 0,
        "DataId": "1400000000_test_data_id",
        "ScanFinishTime": 1566720906,
        "HitFlag": true,
        "Live": false,
        "Msg": "",
        "ScanPiece": [{
            "DumpUrl": "",
            "HitFlag": true,
            "MainType": "abuse",
            "RoomId": "123",
            "OpenId": "xxx",
            "Info":"",
            "Offset": 0,
            "Duration": 3400,
            "PieceStartTime":1574684231,
            "ScanDetail": [{
                "EndTime": 1110,
                "KeyWord": "xxx",
                "Label": "abuse",
                "Rate": "90.00",
                "StartTime": 1110
            }, {
                "EndTime": 1380,
                "KeyWord": "xxx",
                "Label": "abuse",
                "Rate": "90.00",
                "StartTime": 930
            }, {
                "EndTime": 1560,
                "KeyWord": "xxx",
                "Label": "abuse",
                "Rate": "90.00",
                "StartTime": 930
            }, {
                "EndTime": 2820,
                "KeyWord": "xxx",
                "Label": "abuse",
                "Rate": "90.00",
                "StartTime": 2490
            }]
        }],
        "ScanStartTime": 1566720905,
        "Scenes": [
            "default"
        ],
        "Status": "Success",
        "TaskId": "xxx",
        "Url": "https://xxx/xxx.m4a"
    }
    

    A maximum of 5000 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: ScanVoice.
    Version Yes String Common Params. The value used for this API: 2018-07-11.
    Region No String Common Params. This parameter is not required for this API.
    BizId Yes Integer Application ID, which is obtained when you create an application in the GME console - Service Management.
    Scenes.N Yes Array of String Voice detection scenario. It must be default. See the Label description as the result.
    Live Yes Boolean Whether it is a live stream. Values: false (voice file), true (live stream).
    Tasks.N Yes Array of Task Voice detection task list. Up to 100 tasks can be added in the list.
  • DataId: Unique data ID
  • Url: URL-encoded data file URL, which is a pull address if the detected voice is a stream
  • Callback No String Async callback address for detection result. For more information, please see the Callback description above. (Note: If this field is empty, the detection result can only be queried by calling the DescribeScanResultList API.)
    Lang No String Language. Chinese will be used if it is left empty.

    3. Output Parameters

    Parameter Name Type Description
    Data Array of ScanVoiceResult Voice moderation result.
  • DataId: Corresponding DataId in request.
  • TaskID: Moderation task ID, which is used to poll the voice detection result.
  • RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Submitting voice file detection task-2

    This example shows you how to submit a voice detection task for a voice file where the callback address is empty and the DescribeScanResultList API needs to be called to poll the detection result.

    Input Example

    POST / HTTP/1.1
    Host: gme.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ScanVoice
    <Common request parameters>
    
    {
        "Callback": "https://0.0.0.0/user_callback",
        "Live": "false",
        "Tasks": [
            {
                "Url": "http://xxx/audio_store/xxxx.mp3",
                "DataId": "1400000000_test_data_id"
            }
        ],
        "BizId": "1400000000",
        "Scenes": [
            "default"
        ]
    }
    

    Output Example

    {
        "Response": {
            "Data": [
                {
                    "DataId": "1400000000_test_data_id",
                    "TaskId": "xxx-xxx-xxx"
                }
            ],
            "RequestId": "xxx-xxx-xxx"
        }
    }
    

    Example2 Submitting voice stream detection task

    This example shows you how to submit a voice detection task for a voice stream where the callback address is empty and the DescribeScanResultList API needs to be called to poll the detection result.

    Input Example

    POST / HTTP/1.1
    Host: gme.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ScanVoice
    <Common request parameters>
    
    {
        "Callback": "https://0.0.0.0/user_callback",
        "Live": "true",
        "Tasks": [
            {
                "Url": "https://xxxx",
                "DataId": "1400000000_test_data_id"
            }
        ],
        "BizId": "1400000000",
        "Scenes": [
            "default"
        ]
    }
    

    Output Example

    {
        "Response": {
            "Data": [
                {
                    "DataId": "1400000000_test_data_id",
                    "TaskId": "xxx-xxx-xxx"
                }
            ],
            "RequestId": "xxx-xxx-xxx"
        }
    }
    

    Example3 Submitting voice file detection task

    This example shows you how to submit a voice detection task for a voice file where the callback address (Callback) is set to query the detection result.

    Input Example

    POST / HTTP/1.1
    Host: gme.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ScanVoice
    <Common request parameters>
    
    {
        "Callback": "https://0.0.0.0/user_callback",
        "Live": "false",
        "Tasks": [
            {
                "Url": "http://xxxx/audio_store/xxxx.mp3",
                "DataId": "1400000000_test_data_id"
            }
        ],
        "BizId": "1400000000",
        "Scenes": [
            "default"
        ]
    }
    

    Output Example

    {
        "Response": {
            "Data": [
                {
                    "DataId": "1400000000_test_data_id",
                    "TaskId": "xxx-xxx-xxx"
                }
            ],
            "RequestId": "xxx-xxx-xxx"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation Operation failed.
    InternalError Internal error.
    InvalidParameter Incorrect parameter.
    InvalidParameter.CallbackAddress Incorrect callback URL.
    MissingParameter Parameter missing.
    OperationDenied Operation denied.
    ResourceNotFound The resource does not exist.
    ResourceUnavailable The resource is unavailable.
    UnauthorizedOperation Unauthorized operation.
    UnknownParameter Unknown parameter error.
    UnsupportedOperation Operation unsupported.