URL
https://ttsfree.com/api/v1/tts
Method
http POST
Header Parameters
1. header "Content-Type: application/json"
2. header "apikey: YOUR-API-KEY"
To get "YOUR-API-KEY", you create apikey in your Profile.
{
"text": "Convert text to speech with natural-sounding using an API powered by AI technologies",
"voiceService": "servicebin",
"voiceID": "en-US",
"voiceSpeed": "0"
}
property name | Value | Description |
---|---|---|
text | String | text or SSML ( maximum 500 characters ) |
voiceService | String | servicebin or servicegoo |
voiceID | String | You can see the list of voiceID here: https://ttsfree.com/api/v1/voice |
voiceSpeed | String | ( Only accept: -3, -2, -1, 0, 1, 2, 3 )
|
{
"status": "success",
"mess": "success",
"audioData": "//PIxAAAAANIAAAAAExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVV.................."
}
curl --request POST \ --url https://ttsfree.com/api/v1/tts \ --header "apikey: YOUR-API-KEY" \ --header "Content-Type: application/json" \ --data "{\"voiceService\": \"servicebin\", \"voiceID\": \"en-US3\", \"voiceSpeed\": \"0\", \"text\": \"Test APIs, websites and web services online\"}"
<?php $input_text = "Hello. Welcome to text to speech free API service"; $text = addslashes($input_text); $post_data = '{"voiceService": "servicebin", "voiceID": "en-US3", "voiceSpeed": "0", "text": "'.$text.'"}'; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://ttsfree.com/api/v1/tts", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $post_data, CURLOPT_HTTPHEADER => array( "apikey: YOUR-API-KEY", "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { // echo $response; $data = json_decode($response,true); $wave_mp3 = base64_decode($data['audioData']); echo $wave_mp3; } ?>