Do TTS Pro
POST https://api.newportai.com/api/async/do_tts_pro
Do TTS Pro API could use the pro version audio voice from voice list. Choose a voiceId from the pro voice list, use it as audioId, with text and lan to create a speech.
- Choose a voiceId from the pro voice list use as audioId.
- Use Do TTS Pro API with audioId, text, lan, to get a taskId with POST method.
- Use Polling API to get audioUrl with POST method.
Request Headers
- Content-TypestringRequiredEnumapplication/json
- AuthorizationstringRequiredBearer authentication format, for example: Bearer
Request Body
- audioIdstringRequiredVisit voice list: https://api.newportai.com/playground/speech, choose from pro version, copy the voiceId from the right side.
- textstringRequiredText to speech.
- lanstringRequiredVoice language.Each audioId supported language is listed on the page:https://api.newportai.com/playground/speech.
Response
- codeinteger0 success, or error code.
- messagestring"success", or error msg.
- dataobjecttaskIdstringUse the taskId to request the Polling API to retrieve the generated outputs.
Example
First, get a pro 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_pro' \
-H "Authorization: Bearer {{key}}" \
-H 'Content-Type: application/json' \
-d '{
"audioId":"b90847cb8cfe4446881c6a3e15118084",
"text":"let us see this world",
"lan":"en"
}'
Response:
json
{
"code": 0,
"message": "success",
"data": {
"taskId": "496d20fd83f49bbe985d32da4d099e51"
}
}
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": "496d20fd83f49bbe985d32da4d099e51"
}'
Response:
json
{
"code": 0,
"message": "success",
"data": {
"audios": [
{
"audioUrl": "https://s3.amazonaws.com/pt-tts-new/oneshot_tts_result/20241017/_/be1eb9dc984747ff95e58d119817cd78.wav",
"audioType": ".wav"
}
],
"task": {
"taskId": "496d20fd83f49bbe985d32da4d099e51",
"status": 3,
"taskType": "tts_pro"
}
}
}