Text To Speech API - Developers APIs Documentation

Connect API "text-to-speech" into your application

API TTS - Text To Speech

Welcome to the API documentation for text-to-speech / text-to-MP3 conversion TTSFree.com
Convert any written text into spoken words and get a finished MP3 returned. Use any speaker as known from our main page. Use any language you want.
API access only for "Premium" paid plans. 5000000 characters per month
  • 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.


Format data request: Json (default), example:

{
    "text": "Convert text to speech with natural-sounding using an API powered by AI technologies",
    "voiceService": "servicebin",
    "voiceID": "en-US",
    "voiceSpeed": "0"
}


Description of parameters:

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 )
 
  • -3 : x3 Slow
  • -2 : x2 Slow
  • -1 : Slow
  •  0  : Normal ( default )
  • 1 : Fast
  • 2 : x2 Fast
  • 3 : x3 Fast

Success Response:

  • Code: 200
  • status: success
  • mess: success
  • audioData: inputstream ( base64 format )

Response example :

{
    "status": "success",
    "mess": "success",
    "audioData": "//PIxAAAAANIAAAAAExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVV.................."
}

CURL example: ( Try )

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 Code example:

<?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;
}

?>