Skip to content

Do TTS Common

POST https://api.newportai.com/api/async/do_tts_common

Do TTS Common API could use the common version audio voice from voice list. Choose a voiceId from the common voice list, use it as audioId, with text and lan, to create a speech.

  • Choose a voiceId from the common voice list use as audioId.
  • Use Do TTS Common API with audioId, text, lan, to get a taskId with POST method.
  • Use Polling API to get audioUrl with POST method.

Request Headers

  • Content-TypestringRequired
    Enum
    application/json
  • AuthorizationstringRequired
    Bearer authentication format, for example: Bearer

Request Body

  • audioIdstringRequired
    Visit voice list: https://api.newportai.com/playground/speech, choose from common version, copy the voiceId from the right side.
  • textstringRequired
    Text to speech.
  • lanstringRequired
    Voice language.
    Each audioId supported language is listed on the page: https://api.newportai.com/playground/speech.

Response

  • codeinteger
    0 success, or error code.
  • messagestring
    "success", or error msg.
  • dataobject
    taskIdstring
    Use the taskId to request the Polling API to retrieve the generated outputs.

Example

First, get a common version audioId from voice list: https://api.newportai.com/playground/speech.

Second, create a task with audioId, text, and lan to get a taskId.

Request:

zsh
curl -X POST 'https://api.newportai.com/api/async/do_tts_common' \
-H "Authorization: Bearer {{key}}" \
-H 'Content-Type: application/json' \
-d '{
  "audioId":"30612dc846b64713a6c6fc96f13ee5ea",
  "text":"let us see this world",
  "lan":"en"
}'

Response:

json
{
  "code": 0,
  "message": "success", 
  "data": {
      "taskId": "32da4d099e51496d20fd83f49bbe985d"
  }
}

Next Step:

Use Polling API to get the result.

Request:

zsh
curl -X POST 'https://api.newportai.com/api/getAsyncResult' \
-H "Authorization: Bearer {{key}}" \
-H 'Content-Type: application/json' \
-d '{
  "taskId":"ae88-k9it-ss13-fa41-5664dd31ho"
}'

Response:

json
{
  "code": 0,
  "message": "success", 
  "data": {
    "audios": [
      {
        "audioUrl": "https://s3.amazonaws.com/pt-tts-new/oneshot_tts_result/20241113/_/4169774.wav",
        "audioType": ".wav"
      }
    ],
    "task": {
      "taskId": "9af2a0cee7734bbdabea229265d09869",
      "status": 3,
      "taskType": "tts_common"
    }
  }
}