logo

Push-to-Speech API

อัพเดทล่าสุด :2024-05-08

Note: Voice broadcasts created through this API can only be accessed, modified, or deleted via the API. Note: The voice file language type currently only supports "en", "zh-Hans", "zh-Hant".

Authentication

For more details, please refer to the REST API overview section on Authentication Methods.

Create/Update Voice Broadcast

Creates a new voice broadcast if it does not exist; updates it if it does.

Endpoint

POST v4/voices
          POST v4/voices

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Request Example

Request Headers

POST /v4/voices Authorization: Basic (base64 auth string) Content-Type: multipart/form-data Accept: multipart/form-data
          POST /v4/voices
Authorization: Basic (base64 auth string)
Content-Type: multipart/form-data
Accept: multipart/form-data

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Request Data

--form 'language="en"' --form 'file="file"'
          --form 'language="en"'
--form 'file="file"'

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Request Data Description

  • language: Specifies the language of the voice broadcast file, used to select the required voice broadcast language.
  • file: The zip file needed for voice broadcast, containing all necessary mp3 files.

Response Example

Success Response

HTTP/1.1 200 OK Server: fasthttp Date: Thu, 01 Dec 2022 07:17:45 GMT Content-Type: application/json Content-Length: 85
          HTTP/1.1 200 OK
Server: fasthttp
Date: Thu, 01 Dec 2022 07:17:45 GMT
Content-Type: application/json
Content-Length: 85

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
{ "file_url": "" }
          {
    "file_url": ""
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
  • file_url: The download URL of the uploaded file on Huawei Cloud OBS.

Failure Response

HTTP/1.1 400 BAD REQUEST Content-Type: application/json; charset=utf-8
          HTTP/1.1 400 BAD REQUEST
Content-Type: application/json; charset=utf-8

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
{ "error": { "code": 28400, "message": "error message" } }
          {
    "error": {
        "code": 28400,
        "message": "error message"
    }
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Audio File Specifications

The audio files for this API should be named according to specified numbers and words, each file format being .mp3. Below are the naming details supported:

  • English (en):

    • Numbers: "0" to "20", "30", "40", "50", "60", "70", "80", "90", "100", "1000", "1000000", "1000000000"
    • Words: "point", "and"
  • Chinese (zh):

    • Numbers: "0" to "10", "100", "1000", "10000", "100000000"
    • Words: "point"

Ensure all files are MP3 format for correct system integration.

Retrieve Voice Broadcast List

Endpoint

GET v4/voices

Request Example

Request Headers

GET /v4/voices Authorization: Basic (base64 auth string)
          GET /v4/voices
Authorization: Basic (base64 auth string)

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
  • Sort order: Newest updates first.

Response Example

Successful Return

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
          HTTP/1.1 200 OK 
Content-Type: application/json; charset=utf-8

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
[ { "language":"en", "file_url":"" } ]
          [
    {
        "language":"en", 
        "file_url":""
    }
]

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
  • Returns the list of valid voice broadcasts under that application.
  • language is as requested during creation/update.
  • file_url is the Huawei Cloud OBS download URL of the uploaded file.

Retrieve Voice Broadcast Details

Endpoint

GET v4/voices/{language}

Request Example

Request Headers

GET /v4/voices/en Authorization: Basic (base64 auth string)
          GET /v4/voices/en
Authorization: Basic (base64 auth string)

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Response Example

Successful Return

HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
          HTTP/1.1 200 OK 
Content-Type: application/json; charset=utf-8

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Response Data

{ "file_url": "" }
          {
   "file_url": ""
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
  • If language does not exist, returns 404, otherwise returns the actual file_url which is the Huawei Cloud OBS download URL of the uploaded file.

Delete Voice File

Endpoint

DELETE v4/voices/{language}

Request Example

DELETE /v4/voices/en Authorization: Basic (base64 auth string)
          DELETE /v4/voices/en
Authorization: Basic (base64 auth string)

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Response Example

Successful Return

HTTP/1.0 200 Content-Type: application/json Content-Length: 0
          HTTP/1.0 200 
Content-Type: application/json
Content-Length: 0

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Failure Return

  • If language is invalid or does not exist.
HTTP/1.0 404 Not Found Content-Type: application/json
          HTTP/1.0 404 Not Found
Content-Type: application/json

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
  • If the update operation is illegal.
HTTP/1.1 400 BAD REQUEST Content-Type: application/json; charset=utf-8
          HTTP/1.1 400 BAD REQUEST
Content-Type: application/json; charset=utf-8

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
{ "error": { "code": 28400, "message": "error message" } }
          {
    "error": {
        "code": 28400,
        "message": "error message"
    }
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Error Codes

Code HTTP Status Description Error Message Detailed Explanation
28000 200 Successful response nil Success status code
28101 401 Authentication failure Basic authentication failed. Appkey and masterscrect do not match.
28200 500 Internal server error Server Internal error. An unanticipated error occurred.
28203 503 Internal server error, please try again later Execute action timeout, please try later again Communication error with schedule-server.
在文档中心打开
icon
ติดต่อฝ่ายขาย