API Documentation for Text-to-Speech Conversion

This documentation explains how to use the Text-to-Speech Conversion API.

Sending a Request

To send a request to the API, you need to send an HTTP POST request to the specified URL:

$url = 'https://api.talkbaba.com/v1/media/text-to-speech/REQ';

Headers

You must set the Authorization header with your Bearer token:

$headers = [ 
    'Authorization: Bearer YOUR_ACCESS_TOKEN' 
];

POST Data

You need to send the following data as part of the POST request body:

$data = [ 
    'text' => 'Your Text Here...', 
    'gender' => 'male', // or 'female' 
    'lang' => 'persian' // language code 
];

Sending the Request

To send the request, you can use cURL in PHP:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$response = curl_exec($ch); 
if(curl_errno($ch)){ 
    echo 'error CURL: ' . curl_error($ch); 
} 
curl_close($ch);

Example:

Here is an example request. Just replace YOUR_API_KEY with your actual API key.

 
 
$headers = [ 
    'Authorization: Bearer sk-s68980b7df06c90b558092fawebff9as' 
]; 
$data = [ 
    'text' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', 
    'gender' => 'male', 
    'lang' => 'english' 
]; 
$url = 'https://api.talkbaba.com/v1/media/text-to-speech/REQ'; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
echo $response = curl_exec($ch); 
if(curl_errno($ch)){ 
    echo 'error CURL: ' . curl_error($ch); 
} 
curl_close($ch); 
 
    

List of Languages and Genders

To specify the language and gender of the output voice, you need to put appropriate values in the 'lang' and 'gender' fields. Below is a list of available languages and genders:

API Response

The API response will be a JSON string that contains information about the generated audio file and the status of the request.