Logo Site EngageLab Mark Colored TransparentDocument
Search

Push-to-Speech API

Note: Voice broadcasts created through this API can only be retrieved, modified, or deleted through the API.
Note: The currently supported language types for voice files are "en", "zh-Hans", and "zh-Hant" only.

Authentication

For more details, refer to the Authentication Method section in the REST API Overview.

Create/Update Voice Broadcast

If the voice broadcast does not exist, it will be created. If it already exists, it will be updated.

Endpoint

POST v4/voices
              
              POST v4/voices

            
This code block in the floating window

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

            
This code block in the floating window

Request Data

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

            
This code block in the floating window

Request Data Description

  • language: Specifies the language of the voice broadcast file and is used to select the voice broadcast language required by the user.
  • file: The ZIP file used for voice broadcast, containing all required MP3 files.

Response Example

Successful 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

            
This code block in the floating window
{ "file_url": "" }
              
              {
  "file_url": ""
}

            
This code block in the floating window
  • file_url: The download URL of the uploaded file in Huawei Cloud OBS.

Failed 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

            
This code block in the floating window
{ "error": { "code": 28400, "message": "error message" } }
              
              {
  "error": {
    "code": 28400,
    "message": "error message"
  }
}

            
This code block in the floating window

Voice File Format Description

Voice broadcast files supported by this API must be named according to the specified numbers and words, and each file must use the .mp3 format. The following naming conventions are 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"

Make sure all files are in MP3 format to ensure proper system integration.

Get 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)

            
This code block in the floating window
  • Sorting rule: Ordered by update time, with the most recent first.

Response Example

Successful Response

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

            
This code block in the floating window
[ { "language": "en", "file_url": "" } ]
              
              [
  {
    "language": "en",
    "file_url": ""
  }
]

            
This code block in the floating window
  • Returns a list of valid voice broadcasts under this application.
  • The returned language is the language requested by the client during creation or update.
  • The returned file_url is the Huawei Cloud OBS download URL corresponding to the file uploaded by the client during creation or update.

Get 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)

            
This code block in the floating window

Response Example

Successful Response

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

            
This code block in the floating window

Response Data

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

            
This code block in the floating window
  • If the language does not exist, 404 is returned. Otherwise, the actual file_url returned is the Huawei Cloud OBS download URL corresponding to 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)

            
This code block in the floating window

Response Example

Successful Response

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

            
This code block in the floating window

Failed Response

  • Invalid language, or the language does not exist.
HTTP/1.0 404 Not Found Content-Type: application/json
              
              HTTP/1.0 404 Not Found
Content-Type: application/json

            
This code block in the floating window
  • Invalid update operation.
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

            
This code block in the floating window
{ "error": { "code": 23903, "message": "voice does not exist" } }
              
              {
  "error": {
    "code": 23903,
    "message": "voice does not exist"
  }
}

            
This code block in the floating window

Error Codes

Code HTTP Description Error Message Detailed Explanation
28000 200 Correct response returned nil Success status code
28101 401 Authentication failed Basic authentication failed. appkey and mastersecret do not match.
28200 500 Internal system error Server Internal error. An unexpected error occurred.
28203 503 Internal system error; retrying later is recommended Execute action timeout, please try later again Communication error with schedule-server.
23903 404 Request parameter error voice does not exist The voice broadcast does not exist
23904 400 Request parameter error voice does not support this The voice broadcast does not support this language
Icon Solid Transparent White Qiyu
Contact Sales