API DOCS V2.0
- API Platform
- API Docs
-
-
Addım 1: Abunəliyi aktivləşdirin
Plana Baxın TTSMaker Pro/Studio-ya abunə olun (Lite planı dəstəklənmir).
-
2
Addım 2: API Açarı yaradın
Açar yarat TTSMaker API-ə daxil olmaq üçün API açarı yaradın.
-
3
Addım 3: API istifadə etməyə başlayın
API-ni tətbiqlərinizə və xidmətlərinizə inteqrasiya edin.
API Summary
Here is a list of the primary APIs available for use:
- Get Voice List
- Create TTS Order
- Check Token Status
Developers can follow these steps to integrate text-to-speech conversion and playback functionalities using the provided APIs:
Subscription and API Key Creation: Subscribe to either a PRO or Studio level subscription as Lite level does not support this feature. Create your private API key on the Developer API Center page. Each account is permitted to create one API key, which can be deleted and re-created if necessary. For debugging convenience, TTSMaker provides an Online API Interactive Documentation accessible via the 'Online Debugging' button at the top right corner of the page.
Get Voice List API: This API retrieves a list of supported languages and voices, providing details such as the maximum character limits per voice and their unique IDs. For debugging purposes, the TTS conversion page’s UI allows users to explore different languages, view Voice IDs, and listen to sample Mp3 files.
Create TTS Order API: Use this API to generate a text-to-speech conversion order. Upon successful order creation, the API will return a temporary URL for the hosted audio file (instead of the audio file stream). The temporary URL will be valid for 24 hours. Each TTS task completion will also include data about your account's cycle quota. All voices are deducted in regular character mode and do not support unlimited mode; more information can be found in the FAQ.
Use of Temporary URL: The temporary URL can be used to download the audio file or to play it directly within the 24-hour validity period.
Check Token Status API: This API allows for the retrieval of detailed information regarding the token's character usage and other account-specific details.
Note: The QPS (Queries Per Second) limit for each API key is set to 1 request per second. Exceeding this limit will result in an HTTP CODE 429 error.
By adhering to these guidelines, developers can effectively utilize the provided APIs for converting text to speech and integrating the playback in their applications.
API Details
1. Get Voice List
Get a list of the available languages and voices.
URL
https://api.ttsmaker.com/v2/get-voice-list?api_key=replace_this_demo_key
Method
GET/POST
API request frequency limit (Maximum QPS)
1/second
URL Params
param:
api_key: str // required, your api_key
language: str = None // optional, support language: ["en", "zh", "es", "pt", "de", "fr", "it", "tr", "ru", "ja", "ko", "ms", "th", "vi", "id", "he", "fi", "sv", "nb", "da", "hi", "ar", "ro", "hu", "pl", "nl", "cs", "uk", "hr", "el", "sk", "bg", "sl", "ca", "ga", "lt", "mt", "et", "is", "lv", "ur", "ta", "mr", "te", "gu", "ml", "kn", "bn", "fa", "fi", "sw"]
example:
# get all voices
https://api.ttsmaker.com/v2/get-voice-list?api_key=your_api_key
# get all en voices
https://api.ttsmaker.com/v2/get-voice-list?api_key=your_api_key&language=en
bash curl code:
curl -X 'GET' \
'https://api.ttsmaker.com/v2/get-voice-list?api_key=replace_this_demo_key' \
-H 'accept: application/json'
curl -X 'GET' \
'https://api.ttsmaker.com/v2/get-voice-list?language=en&api_key=replace_this_demo_key' \
-H 'accept: application/json'
Response Example
{
"error_code": 0,
"error_summary": "",
"msg": "Query the list of voices successfully. ",
"user_email": "[email protected]",
"language": "en",
"support_language_list": [
"en",
"zh",
"es",
"ja",
...
],
"voices_id_list": [
147,
148,
663,
666,
777,
778,
779,
780,
2001,
2002,
2003,
...
],
"voices_count": 26,
"voices_detailed_list": [
{
"id": 147,
"name": "🔥Peter-🇺🇸United States Male (Hot + Unlimited)",
"language": "en",
"audio_sample_file_url": "https://s2.ttsmaker-file.com/samples/pro_147.mp3",
"text_characters_limit": 20000
},
{
"id": 148,
"name": "🔥Alayna-🇺🇸United States FeMale (Hot + Unlimited)",
"language": "en",
"audio_sample_file_url": "https://s2.ttsmaker-file.com/samples/pro_148.mp3",
"text_characters_limit": 20000
},
{
"id": 1480,
"name": "Alayna-🇺🇸United States FeMale (V2 Multi-Emotion Version)",
"language": "en",
"audio_sample_file_url": "https://s2.ttsmaker-file.com/samples/pro_1480.mp3",
"text_characters_limit": 20000,
"is_support_emotion": true,
"support_emotion_key_list": [ # This voice supports emotions. You can select an emotion key from the list. With this parameter in the TTS order API, you can return the TTS task data with emotion selection. For details, please see the subsequent description.
"assistant",
"chat",
"customerservice",
"newscast",
"angry",
"cheerful",
"sad",
"excited",
"friendly",
"terrified",
"shouting",
"unfriendly",
"whispering",
"hopeful"
]
},
...
}
Error Code:
Index | error_code | error_summary | Description |
---|---|---|---|
1 | -1 | API_KEY_VERIFICATION_ERROR | Your api-key is invalid or not activated. Please confirm whether the api-key is valid and activated, or contact technical support. |
2 | -1 | LANGUAGE_NOT_FOUND | The requested language id is not in the list. Please check the parameters. |
3 | 0 | Query the list of voices successfully. |
2. Create TTS Order
Create a TTS order. The Create TTS Order API allows you to submit a TTS order and receive a temporary URL to access the generated speech file.
Please note that the API does not return the speech file itself, but instead provides a URL to a temporary file that will be deleted after 2 hours. You can use this URL to play or download the speech file as part of your business process.
URL
https://api.ttsmaker.com/v2/create-tts-order
Method
POST
Request Format
Our API only accepts requests with the following Content-Type:
Content-Type: application/json
Please ensure that all POST requests include a JSON body.
API request frequency limit (Maximum QPS)
1/second
POST Params
{
"api_key": "replace_this_demo_key",
"text": "Please fill in the text that needs to be converted to speech.",
"voice_id": 1480,
"audio_format": "mp3",
"audio_speed": 1,
"audio_volume": 0,
"audio_pitch": 1,
"audio_high_quality": 0,
"text_paragraph_pause_time": 0,
"emotion_style_key": "",
"emotion_intensity": 1
}
Index | Parameter | Required | Optional Range and Detailed Description |
---|---|---|---|
1 | api_key | Yes | Your developer token,Replace with your own api_key |
2 | text | Yes | Text to be converted to speech. The maximum length of the text is 20,000 characters. |
3 | voice_id | Yes | Voice ID. You can refer to the voice list on the converter page of pro.ttsmaker.com, which is a number, such as `777` |
4 | audio_format | Yes | Audio format, optional values: mp3/wav/ogg/aac/opus, default mp3 |
5 | audio_speed | No | Audio speed, range 0.5-2.0, default 1.0 |
6 | audio_volume | No | Audio volume, range 0.1-2.0, default 1 |
7 | audio_pitch | No | Audio pitch, default 1, range 0.5-2.0 |
8 | audio_high_quality | No | High quality audio, default 0. There are only 0 and 1 options, 1 represents high sound quality. If you choose 1, the size of the converted audio file will usually be twice as large. |
9 | text_paragraph_pause_time | No | Pause time between paragraphs, range 0-10000 ms, default 0. The principle of the text_paragraph_pause_time parameter is to automatically replace line breaks with [[break=X]]. For example, text_paragraph_pause_time=5000 means that all line breaks in the text will be automatically replaced with [[break=5000]]. One [[break=5000]]] means inserting a 5-second pause at this position. |
10 | emotion_style_key | No | If supported, provide a valid emotion key. For example, the multi-emotion voice with voice_id 1480 supports ["assistant", "chat", "customerservice", "newscast", "angry", ...]. You can fill in `angry` as an emoiton key. |
11 | emotion_intensity | No | If supported, Emotion intensity, range 0.1-2.0, default 1. Used in combination with emotion_style_key |
Example 1: Generate an mp3 audio file at 1.5x speed
{
"api_key": "replace_this_demo_key",
"text": "Here is an example that generates an mp3 audio file.",
"voice_id": 1480,
"audio_format": "mp3",
"audio_speed": 1.5,
"audio_volume": 0.8,
"audio_pitch": 1,
"audio_high_quality": 0,
"text_paragraph_pause_time": 0,
"emotion_style_key": "",
"emotion_intensity": 1
}
CURL CODE:
curl -X 'POST' \
'https://api.ttsmaker.com/v2/create-tts-order' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "replace_this_demo_key",
"text": "Here is an example that generates an mp3 audio file.",
"voice_id": 1480,
"audio_format": "mp3",
"audio_speed": 1.5,
"audio_volume": 0.8,
"audio_pitch": 1,
"audio_high_quality": 0,
"text_paragraph_pause_time": 0,
"emotion_style_key": "",
"emotion_intensity": 1
}'
Example 1: Response body
{
"error_code": 0,
"error_summary": "",
"msg": "TTS Task Executed Successfully",
"user_email": "[email protected]",
"tts_task_characters_count": 52,
"audio_download_url": "https://s5-8.ttsmaker-vip-file.com/file/2024-08-13-224440_166679.mp3",
"audio_download_backup_url": "https://ttsmaker-file2.com/s5/file/2024-08-13-224440_166679.mp3",
"audio_file_format": "mp3",
"current_timestamp": 1723560281,
"audio_file_expiration_timestamp": 1723646681,
"is_demo_key": true,
"account_status": {
"quota_characters": 1000000,
"characters_used": 40937,
"available_quota": 959063,
"subscription_period": "month",
"subscription_next_reset_timestamp": 1725372332
}
}
Example 2: Generate a word audio with a 3s pause before each word and a 10s pause at the end
Knowledge 1: How to use the [[break=1000]] tag
- You can freely insert pauses in the text by using the [[break=1000]] tag. For example, [[break=1000]] means inserting a 1-second pause at this position.
- [[break=0]] is for special purposes. You can use [[break=0]] between paragraphs to eliminate the default silence time between two paragraphs.
- The longest time is 10 seconds. The parameter range of break is [[break=1]] -->[[break=10000]]. Multiple tags can be used continuously.
Knowledge 2: How to use the textparagraphpause_time parameter
The principle of the text_paragraph_pause_time
parameter is to automatically replace line breaks with [[break=X]], for
example, textparagraphpause_time=5000 means that all line breaks in the text are automatically replaced
with [[break=5000]], and [[break=5000]]] means inserting a 5-second pause at this position.
0 means not to enable this parameter -1 means to replace and insert [[break=-0]] 1-10000 means to control the millisecond size of the automatically inserted pause tag.
{
"api_key": "replace_this_demo_key",
"text": "Shelf\nLibrarian\nThe stacks\nReturn\nFine\nMagazine\nCopier\nOverdue\nReading room\nReference room\n [[break=10000]]",
"voice_id": 1480,
"audio_format": "mp3",
"audio_speed": 1.0,
"audio_volume": 1.5,
"audio_pitch": 1,
"audio_high_quality": 0,
"text_paragraph_pause_time": 3000,
"emotion_style_key": "",
"emotion_intensity": 1
}
BASH CURL CODE:
curl -X 'POST' \
'https://api.ttsmaker.com/v2/create-tts-order' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "replace_this_demo_key",
"text": "Shelf\nLibrarian\nThe stacks\nReturn\nFine\nMagazine\nCopier\nOverdue\nReading room\nReference room\n [[break=10000]]",
"voice_id": 1480,
"audio_format": "mp3",
"audio_speed": 1.0,
"audio_volume": 1.5,
"audio_pitch": 1,
"audio_high_quality": 0,
"text_paragraph_pause_time": 3000,
"emotion_style_key": "",
"emotion_intensity": 1
}'
Example 2: Response body
{
"error_code": 0,
"error_summary": "",
"msg": "TTS Task Executed Successfully",
"user_email": "[email protected]",
"tts_task_characters_count": 91,
"audio_download_url": "https://s5-9.ttsmaker-vip-file.com/file/2024-08-13-230733_197903.mp3",
"audio_download_backup_url": "https://ttsmaker-file2.com/s5/file/2024-08-13-230733_197903.mp3",
"audio_file_format": "mp3",
"current_timestamp": 1723561654,
"audio_file_expiration_timestamp": 1723648054,
"is_demo_key": true,
"account_status": {
"quota_characters": 1000000,
"characters_used": 41392,
"available_quota": 958608,
"subscription_period": "month",
"subscription_next_reset_timestamp": 1725372332
}
}
Example 3: Generate an audio file that supports multiple emotions
You can view emoiton sounds with the E logo on the pro.ttsmaker.com/studio page. Or use the getvoicelist API to view all voices. If the voice id is supported, the voice data contains issupportemotion and the corresponding supportemotionkey_list
For example, the multi-emotion voice with voice_id 1480
supports ["assistant", "chat", "customerservice", "newscast", "angry", ...]. You can fill in angry
as an emoiton key.
{
"api_key": "replace_this_demo_key",
"text": "I am very angry now because you lost the book.",
"voice_id": 1480,
"audio_format": "mp3",
"audio_speed": 1,
"audio_volume": 0,
"audio_pitch": 1,
"audio_high_quality": 0,
"text_paragraph_pause_time": 0,
"emotion_style_key": "angry",
"emotion_intensity": 2
}
BASH CURL CODE:
curl -X 'POST' \
'https://api.ttsmaker.com/v2/create-tts-order' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "replace_this_demo_key",
"text": "I am very angry now because you lost the book.",
"voice_id": 1480,
"audio_format": "mp3",
"audio_speed": 1,
"audio_volume": 0,
"audio_pitch": 1,
"audio_high_quality": 0,
"text_paragraph_pause_time": 0,
"emotion_style_key": "angry",
"emotion_intensity": 2
}'
Example 3: Response body
{
"error_code": 0,
"error_summary": "",
"msg": "TTS Task Executed Successfully",
"user_email": "[email protected]",
"tts_task_characters_count": 46,
"audio_download_url": "https://s2v1.ttsmaker-vip-file.com/file/2024-08-13-231356_113746.mp3",
"audio_download_backup_url": "https://ttsmaker-file2.com/s2v1/file/2024-08-13-231356_113746.mp3",
"audio_file_format": "mp3",
"current_timestamp": 1723562036,
"audio_file_expiration_timestamp": 1723648436,
"is_demo_key": true,
"account_status": {
"quota_characters": 1000000,
"characters_used": 41438,
"available_quota": 958562,
"subscription_period": "month",
"subscription_next_reset_timestamp": 1725372332
}
}
Error Code:
Index | Error_code | Error_summary | Description |
---|---|---|---|
1 | -1 | POST_FIELD_ERROR | Post data fields are incomplete. Please check post fields. |
2 | -1 | API_KEY_VERIFICATION_ERROR | Your api-key is invalid or not activated. Please confirm whether the api-key is valid and activated, or contact technical support. |
3 | -1 | VOICE_ID_ERROR | Voice id does not exist or has been disabled. Please check post fields. |
4 | -1 | TEXT_LENGTH_ERROR | The length of the input text exceeds the maximum supported character length. Please check post fields. |
5 | -1 | TEXT_LENGTH_ERROR_DEMO_API_KEY | API-KEY only supports less than 100 characters and is only used for developers to test API availability. |
6 | -1 | INSERT_PAUSE_ERROR | The inserted pause time in the text is invalid. Please use a value between 0-5 seconds. use [[break=2000]] to insert a pause of 2 seconds. |
7 | -1 | ERROR_USER_QUOTA_NOT_EXIST | No account quota information was found, please check whether you have subscribed and activated API service. |
8 | -1 | ERROR_USER_QUOTA_NOT_ENOUGH | Not enough quota/credit available, please check whether you have subscribed and activated API service. |
9 | -1 | ERROR_TTS_FAILED | The conversion failed this time, and your character quota will not be deducted. There is an error with the server, which may be undergoing maintenance or upgrade. Please try again later or contact customer service. |
10 | -2 | ERROR_TTS_SEGMENTATION_FAILURE | Unable to convert text, possible reasons include incorrect segmentation symbols used (periods, commas, spaces, etc.), preventing TTSMaker from performing conversion and synthesis. Please adjust the text and try again. |
11 | -3 | ERROR_TTS_INVALID_INPUT_TEXT | Language error, unable to convert text due to the voice not supporting the input text's language or other input text issues. Please check the text and try again. |
12 | 0 | TTS Task Executed Successfully. |
3. Check Token Status
Check the developer token's character quota, used characters, quota reset date and other information.
URL
https://api.ttsmaker.com/v2/get-token-status?api_key=replace_this_demo_key
Method
GET/POST
API request frequency limit (Maximum QPS)
1/second
URL Params
param:
api_key: str // required
example:
https://api.ttsmaker.com/v2/get-token-status?api_key=replace_this_demo_key
bash curl code:
curl -X 'GET' \
'https://api.ttsmaker.com/v2/get-token-status?api_key=replace_this_demo_key' \
-H 'accept: application/json'
Response Example
{
"error_code": 0,
"error_summary": "",
"msg": "API_Key/Account status checked",
"user_email": "[email protected]",
"current_timestamp": 1723562903,
"is_demo_key": true,
"account_status": {
"quota_characters": 1000000,
"characters_used": 41438,
"available_quota": 958562,
"subscription_period": "month",
"subscription_next_reset_timestamp": 1725372332
}
}
Error Code:
Index | error_code | error_summary | Description |
---|---|---|---|
1 | -1 | API_KEY_VERIFICATION_ERROR | Your api-key is invalid or not activated. Please confirm whether the api-key is valid and activated, or contact technical support. |
2 | 0 | API_Key/Account status checked. |