Do STT(Speech To Text)
POST https://api.newportai.com/api/async/do_stt
Do STT API could be used for converting audio file into a text with timeline.
- Use Do STT API to get taskId with POST method.
- Use Polling API to get result.
Request Headers
- Content-TypestringRequiredEnumapplication/json
- AuthorizationstringRequiredBearer authentication format, for example: Bearer
Request Body
- audioUrlstringRequiredaudio file url
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
Request:
zsh
curl -X POST 'https://api.newportai.com/api/async/do_stt' \
-H "Authorization: Bearer {{key}}" \
-H 'Content-Type: application/json' \
-d '{
"audioUrl": "https://newportai-api-market.s3.amazonaws.com/demo_stt/sttdemo.wav"
}'
Response:
json
{
"code": 0,
"message": "success",
"data": {
"taskId": "fd83f49bbe9832da4d099e51496d205d"
}
}
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": "fd83f49bbe9832da4d099e51496d205d"
}'
Response:
json
{
"code":0,
"message":"success",
"data":{
"task":{
"taskId":"fd83f49bbe9832da4d099e51496d205d",
"status":3,
"executionTime":9172,
"expire":1735992396660,
"taskType":"do_stt"
},
"sttResult":{
"data":[
{
"gender":"",
"bg":260,
"sex":"",
"type":"",
"spk":"",
"pinyin":"",
"emotion":"",
"text":"Today is a beautiful day. ",
"lang":"","modal":0,"ed":1520
},
{
"gender":"",
"bg":1860,
"sex":"",
"type":"",
"spk":"",
"pinyin":"",
"emotion":"",
"text":"The sun is shining, the birds are singing and there is a gentle breeze in the air. ",
"lang":"",
"modal":0,
"ed":6520
},
{
"gender":"",
"bg":7060,
"sex":"",
"type":"",
"spk":"",
"pinyin":"",
"emotion":"",
"text":"I decided to take a walk in the park. The flowers are blooming, filling the air with their sweet fragrance. ",
"lang":"",
"modal":0,
"ed":12320
},
{
"gender":"",
"bg":12700,
"sex":"",
"type":"",
"spk":"",
"pinyin":"",
"emotion":"",
"text":"People are walking their dogs and the dogs seem very happy. ",
"lang":"",
"modal":0,
"ed":15760
},
{
"gender":"",
"bg":16460,
"sex":"",
"type":"",
"spk":"",
"pinyin":"",
"emotion":"",
"text":"I sit on a bench and watch the world go by. ",
"lang":"",
"modal":0,
"ed":18920
},
{
"gender":"",
"bg":19660,
"sex":"",
"type":"",
"spk":"",
"pinyin":"",
"emotion":"",
"text":"Its a peaceful moment and I feel very relaxed",
"lang":"",
"modal":0,
"ed":22440
}
],
"tl":22575,
"type":"0"
}
}
}