API
FPT.AI Speech - Text to Speech
To use API, you need to have create an account on Console FPT.AI. The API is built based on the HTTP POST Request with the URL of API version 5 with high quality voice as follows: https://api.fpt.ai/hmi/tts/v5
Request
Request Url
POST https://api.fpt.ai/hmi/tts/v5
Request Headers
Parameter | Required | Default | Description |
---|---|---|---|
api_key | Yes | Your api key ( get from console.fpt.ai ) | |
voice | No | female |
Identify the voice
|
speed | No | 0 |
Adjust speed of the voice:
|
format | No | mp3 |
Identify the output format for the audio file
|
callback_url | No |
URL Provided by customer to receive notification that the sound content is ready and accessible via the async link.
Description:
|
Request Body
Contain text that need to be converted.
Note:
- Limit per request: 5.000 characters
- Body must have at least 3 characters
Sample Request
curl -X POST \
-H "api_key: xxxxxxxxxxxxx" \
-H "voice: banmai" \
-H "callback_url: your_callback_url" \
-H "Cache-Control: no-cache" \
-d 'Bạn thấy dịch vụ TTS của FPT có tốt không?' \
"https://api.fpt.ai/hmi/tts/v5"
Response
JSON contains link of audio file.
Note:
Since the system needs time to process a document, this file may not exist right at the time of response. Waiting time will be from 5 seconds to 2 minutes, depends on the length of the text.
User can use "callback_url" parameter in order to receive the json file after the audio file is converted successfully.
JSON
Parameter | Description |
---|---|
error | Error code, a value of 0 is successful, a value other than 0 is a failure (an error has occurred) |
async | Link to mp3 file synthesized if error code = 0 error. |
request_id | |
message | Detail message |
Sample Response: Success
{
"async": "https://s3-ap-southeast-1.amazonaws.com/text2speech-v4/male.0.pro.4b5b15285847e83acbb3beb945434453.mp3",
"error": 0,
"message": "The content will be returned after a few seconds under the async link.",
"request_id": "4b5b15285847e83acbb3beb945434453"
}