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:
- English: 'english' - Genders: 'male', 'female'
- German: 'german' - Genders: 'male', 'female'
- Italian: 'italian' - Genders: 'male', 'female'
- Hindi: 'hindi' - Genders: 'male', 'female'
- Japanese: 'japanese' - Genders: 'male', 'female'
- Korean: 'korean' - Genders: 'male', 'female'
- Portuguese: 'portuguese' - Genders: 'male', 'female'
- French: 'french' - Genders: 'male', 'female'
- Russian: 'russian' - Genders: 'male', 'female'
- Turkish: 'turkish' - Genders: 'male', 'female'
- Chinese (Simplified): 'chinese-simplified' - Genders: 'male', 'female'
- Chinese (Traditional): 'chinese-traditional' - Genders: 'male', 'female'
- Dutch: 'dutch' - Genders: 'male', 'female'
- Catalan: 'catalan' - Genders: 'male', 'female'
- Arabic: 'arabic' - Genders: 'male', 'female'
- Danish: 'danish' - Genders: 'male', 'female'
- Finnish: 'finnish' - Genders: 'male', 'female'
- Norwegian: 'norwegian' - Genders: 'male', 'female'
- Swedish: 'swedish' - Genders: 'male', 'female'
- Latin: 'latin' - Genders: 'male', 'female'
- Polish: 'polish' - Genders: 'male', 'female'
- Greek: 'greek' - Genders: 'male', 'female'
- Czech: 'czech' - Genders: 'male', 'female'
- Hungarian: 'hungarian' - Genders: 'male', 'female'
- Romanian: 'romanian' - Genders: 'male', 'female'
- Serbian: 'serbian' - Genders: 'male', 'female'
- Ukrainian: 'ukrainian' - Genders: 'male', 'female'
- Bulgarian: 'bulgarian' - Genders: 'male', 'female'
- Croatian: 'croatian' - Genders: 'male', 'female'
- Slovenian: 'slovenian' - Genders: 'male', 'female'
- Slovak: 'slovak' - Genders: 'male', 'female'
- Estonian: 'estonian' - Genders: 'male', 'female'
- Latvian: 'latvian' - Genders: 'male', 'female'
- Lithuanian: 'lithuanian' - Genders: 'male', 'female'
- Persian: 'persian' - Genders: 'male', 'female'
API Response
The API response will be a JSON string that contains information about the generated audio file and the status of the request.