Documentation

Documentation

  • Conversation
  • Reader
  • Speech
  • Console
  • Languages iconEnglish
    • Tiếng Việt
    • Janpanese

›API

Overview

  • Text to Speech
  • Speech to Text

API

  • Text to Speech
  • Speech to Text

Tutorials

  • Text to Speech
  • Speech to Text

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

  • banmai (female northern)
  • lannhi (female southern)
  • leminh (male northern)
  • myan (female middle)
  • thuminh (female northern)
  • giahuy (male middle)
  • linhsan (female southern)
speed No 0

Adjust speed of the voice:

  • +3 fastest speed
  • +2
  • +1
  • 0 normal speed
  • -1
  • -2
  • -3 slowest speed
format No mp3

Identify the output format for the audio file

  • mp3
  • wav
callback_url No URL Provided by customer to receive notification that the sound content is ready and accessible via the async link.
Description:
  • Request method: POST
  • Content-Type: application/json
  • Body:
    - Success:
    { "message": << async_link >>, "success": "true" }
    - Failed:
    { "message": << error_message >>, "success": "false" }

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"
}
← Speech to TextSpeech to Text →
  • Request
    • Request Url
    • Request Headers
    • Request Body
    • Sample Request
  • Response
    • JSON
    • Sample Response: Success
Conversation
DocumentationAPI ReferenceTutorials (Video)
Reader
DocumentationAPI ReferenceTutorials
Speech
DocumentationAPI ReferenceTutorials
Copyright © 2023 FPT Corporation