Send simple voice message
This method allows you to send a single voice message to one destination address.
Resource
https://api.infobip.com/tts/3/single
Parameters
| Property name | Type | Description |
|---|---|---|
| from | string (442032864231) | Numeric sender ID in E.164 format |
| to* | string | Destination address must be written in the international format (Example: 41793026727). |
| text | string | Message to be converted to speech and played to subscribers. Message text can be up to 1400 characters long. |
| language | string (en) | If the message is in text format, the language in which the message is written must be defined for correct pronunciation. Below, in the Languages section, you can find the list of supported languages. If not set, default language is English [en]. |
| voice | object | Used to define voice in which text would be synthesized. It has two parameters: name and gender. When only name is provided, then that exact voice with that name will be used to synthesize text. If only gender is provided, then text is synthesized with first voice in given gender. Gender can be male or female. If voice is not set, then default voice is used. |
| audioFileUrl | string | Besides the text format of the message, audio recording (format like: wav, mp3, ogg etc.) can also be delivered as a voice message to the recipient. Audio file must be uploaded online so the existing URL can be available for the file download. Size of the audio file must be below 4 MB. |
Request Example
POST /tts/3/single HTTP/1.1
Host: {base_url}
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
"from": "442032864231",
"to": "41793026727",
"text": "Test Voice message.",
"language": "en",
"voice": {
"name": "Joanna",
"gender": "female"
}
}
curl -X POST \
-H "Accept: application/json" \
-H "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"from": "442032864231",
"to": "41793026727",
"text": "Test Voice message.",
"language": "en",
"voice": {
"name": "Joanna",
"gender": "female"
}
}' "https://{base_url}/tts/3/single"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://{base_url}/tts/3/single",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"from\": \"442032864231\",\n \"to\": \"41793026727\",\n \"text\": \"Test Voice message.\",\n \"language\": \"en\",\n \"voice\": {\n \"name\": \"Joanna\",\n \"gender\": \"female\" }\n}",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
url = URI("https://{base_url}/tts/3/single")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["authorization"] = 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
request["content-type"] = 'application/json'
request["accept"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = 'feb1ddbf-7c53-9949-7e56-3091808a9e36'
request.body = "{\n \"from\": \"442032864231\",\n \"to\": \"41793026727\",\n \"text\": \"Test Voice message.\",\n \"language\": \"en\",\n \"voice\": {\n \"name\": \"Joanna\",\n \"gender\": \"female\" }\n}"
response = http.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPSConnection("{base_url}")
payload = "{\n \"from\": \"442032864231\",\n \"to\": \"41793026727\",\n \"text\": \"Test Voice message.\",\n \"language\": \"en\",\n \"voice\": {\n \"name\": \"Joanna\",\n \"gender\": \"female\" }\n}"
headers = {
'authorization': "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
'content-type': "application/json",
'accept': "application/json"
}
conn.request("POST", "/tts/3/single", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
HttpResponse<String> response = Unirest.post("https://{base_url}/tts/3/single")
.header("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.header("content-type", "application/json")
.header("accept", "application/json")
.body("{\n \"from\": \"442032864231\",\n \"to\": \"41793026727\",\n \"text\": \"Test Voice message.\",\n \"language\": \"en\",\n \"voice\": {\n \"name\": \"Joanna\",\n \"gender\": \"female\" }\n}")
.asString();
var client = new RestClient("https://{base_url}/tts/3/single");
var request = new RestRequest(Method.POST);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request.AddParameter("application/json", "{\n \"from\": \"442032864231\",\n \"to\": \"41793026727\",\n \"text\": \"Test Voice message.\",\n \"language\": \"en\",\n \"voice\": {\n \"name\": \"Joanna\",\n \"gender\": \"female\" }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var data = JSON.stringify({
"from": "442032864231",
"to": "41793026727",
"text": "Test Voice message.",
"language": "en",
"voice": {
"name": "Joanna",
"gender": "female"
}
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://{base_url}/tts/3/single");
xhr.setRequestHeader("authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("accept", "application/json");
xhr.send(data);
Response
{
"messages": [
{
"to": "41793026727",
"status": {
"groupId": 1,
"groupName": "PENDING",
"id": 7,
"name": "PENDING_ENROUTE",
"description": "Message sent to next instance"
},
"messageId":"2250be2d4219-3af1-78856-aabe-1362af1edfd2"
}
]
}
Response format
If successful, the response header HTTP status code will be 200 OK and the message will be sent.
If you try to send a message without authorization, you will receive the 401 Unauthorized error .
VoiceResponse
| Parameter | Type | Description |
|---|---|---|
| messages | VoiceResponseDetails | Array of sent message objects, one object per every message. |
VoiceResponseDetails
| Parameter | Type | Description |
|---|---|---|
| to | String | The message destination address. |
| status | Status | Indicates whether the message has been successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status. |
| messageId | String | The ID that uniquely identifies the message sent. |
Status
| Parameter | Type | Description |
|---|---|---|
| groupId | int | Status group ID. |
| groupName | String | Status group name. |
| id | int | Status ID. |
| name | String | Status name. |
| description | String | Human-readable description of the status. |
Languages
List of supported languages:
| Language | Abbreviation | Gender | Name | Default Voice |
| Arabic | ar | Female | Hoda | |
| Arabic | ar | Male | Naayf | |
| Arabic | ar | Male | Tarik | ✓ |
| Arabic | ar | Female | Zeina | |
| Bulgarian | bg | Male | Ivan | ✓ |
| Catalan | ca | Female | Conchita | |
| Catalan | ca | Female | Herena | |
| Catalan | ca | Female | Montserrat | ✓ |
| Chinese (Simplified) | zh-cn | Female | Huihui | |
| Chinese (Simplified) | zh-cn | Male | Kangkang | |
| Chinese (Simplified) | zh-cn | Female | Lily | ✓ |
| Chinese (Simplified) | zh-cn | Female | Yaoyao | |
| Chinese (Simplified) | zh-cn | Female | Zhiyu | |
| Chinese (Traditional) | zh-tw | Female | Hanhan | |
| Chinese (Traditional) | zh-tw | Female | Yating | ✓ |
| Chinese (Traditional) | zh-tw | Male | Zhiwei | |
| Croatian | hr | Male | Matej | ✓ |
| Czech | cs | Male | Jakub | ✓ |
| Danish | da | Female | Helle | |
| Danish | da | Male | Mads | |
| Danish | da | Female | Naja | ✓ |
| Dutch | nl | Female | Hanna | |
| Dutch | nl | Female | Lotte | ✓ |
| Dutch | nl | Male | Ruben | |
| English | en | Male | Benjamin | |
| English | en | Male | Guy | |
| English | en | Female | Ivy | |
| English | en | Female | Jane | |
| English | en | Female | Jessica | |
| English | en | Female | Joanna | ✓ |
| English | en | Male | Joey | |
| English | en | Male | Justin | |
| English | en | Female | Kendra | |
| English | en | Female | Kimberly | |
| English | en | Male | Matthew | |
| English | en | Female | Salli | |
| English | en | Female | Zira | |
| English (Australian) | en-au | Female | Catherine | |
| English (Australian) | en-au | Female | Hayley | |
| English (Australian) | en-au | Female | Nicole | ✓ |
| English (Australian) | en-au | Male | Russell | |
| English (British) | en-gb | Female | Amy | ✓ |
| English (British) | en-gb | Male | Brian | |
| English (British) | en-gb | Female | Emma | |
| English (British) | en-gb | Male | George | |
| English (British) | en-gb | Female | Hazel | |
| English (British) | en-gb | Female | Rosie | |
| English (Canadian) | en-ca | Female | Heather | ✓ |
| English (Indian) | en-in | Female | Aditi | |
| English (Indian) | en-in | Female | Heera | ✓ |
| English (Indian) | en-in | Female | Priya | |
| English (Indian) | en-in | Female | Raveena | |
| English (Indian) | en-in | Male | Ravi | |
| English (Irish) | en-ie | Male | Sean | ✓ |
| English (Welsh) | en-gb-wls | Male | Geraint | ✓ |
| Finnish | fi | Female | Heidi | |
| Finnish | fi | Female | Milla | ✓ |
| French | fr | Female | Celine | ✓ |
| French | fr | Female | Hortense | |
| French | fr | Female | Juliette | |
| French | fr | Female | Lea | |
| French | fr | Male | Mathieu | |
| French | fr | Male | Picart | |
| French (Canadian) | fr-ca | Female | Caroline | |
| French (Canadian) | fr-ca | Female | Chantal | ✓ |
| French (Canadian) | fr-ca | Female | Harmonie | |
| French (Swiss) | fr-ch | Male | Guillaume | ✓ |
| German | de | Male | Hans | |
| German | de | Female | Hedda | |
| German | de | Female | Marlene | ✓ |
| German | de | Male | Stefan | |
| German | de | Female | Vicki | |
| German (Austria) | de-at | Male | Michael | ✓ |
| German (Swiss) | de-ch | Male | Karsten | ✓ |
| Greek | el | Male | Stefanos | ✓ |
| Greek | el | Female | Afroditi | |
| Hebrew | he | Male | Asaf | ✓ |
| Hindi | hi | Female | Aadita | ✓ |
| Hindi | hi | Male | Hemant | |
| Hindi | hi | Female | Kalpana | |
| Hungarian | hu | Male | Szabolcs | ✓ |
| Icelandic | is | Female | Dora | ✓ |
| Icelandic | is | Male | Karl | |
| Indonesian | id | Male | Andika | ✓ |
| Italian | it | Female | Bianca | |
| Italian | it | Female | Carla | ✓ |
| Italian | it | Male | Cosimo | |
| Italian | it | Male | Giorgio | |
| Italian | it | Female | Lucia | |
| Japanese | ja | Female | Ayumi | |
| Japanese | ja | Female | Haruka | |
| Japanese | ja | Male | Ichiro | |
| Japanese | ja | Female | Mizuki | ✓ |
| Japanese | ja | Male | Takumi | |
| Korean | ko | Female | Heami | |
| Korean | ko | Female | Seoyeon | |
| Korean | ko | Female | Yumi | ✓ |
| Malay | ms | Male | Rizwan | ✓ |
| Norwegian | no | Female | Hulda | |
| Norwegian | no | Female | Liv | ✓ |
| Polish | pl | Female | Ewa | ✓ |
| Polish | pl | Male | Jacek | |
| Polish | pl | Male | Jan | |
| Polish | pl | Female | Maja | |
| Polish | pl | Female | Paulina | |
| Portuguese | pt-pt | Female | Amalia | ✓ |
| Portuguese | pt-pt | Male | Cristiano | |
| Portuguese | pt-pt | Female | Helia | |
| Portuguese | pt-pt | Female | Ines | |
| Portuguese (Brazilian) | pt-br | Female | Camila | |
| Portuguese (Brazilian) | pt-br | Male | Daniel | |
| Portuguese (Brazilian) | pt-br | Female | Heloisa | |
| Portuguese (Brazilian) | pt-br | Male | Ricardo | |
| Portuguese (Brazilian) | pt-br | Female | Vitoria | ✓ |
| Romanian | ro | Male | Andrei | |
| Romanian | ro | Female | Carmen | ✓ |
| Russian | ru | Female | Ekaterina | |
| Russian | ru | Female | Irina | |
| Russian | ru | Male | Maxim | |
| Russian | ru | Male | Pavel | |
| Russian | ru | Female | Tatyana | ✓ |
| Slovak | sk | Male | Filip | ✓ |
| Slovenian | sl | Male | Lado | ✓ |
| Spanish | es | Male | Enrique | |
| Spanish | es | Female | Juana | |
| Spanish | es | Female | Laura | |
| Spanish | es | Female | Linda | |
| Spanish | es | Male | Miguel | |
| Spanish | es | Male | Pablo | |
| Spanish | es | Female | Penelope | ✓ |
| Spanish (Argentine) | es-ar | Male | Diego | ✓ |
| Spanish (Castilian) | es-es | Female | Lola | ✓ |
| Spanish (Chilean) | es-cl | Female | Francisca | ✓ |
| Spanish (Mexican) | es-mx | Female | Hilda | |
| Spanish (Mexican) | es-mx | Female | Mia | ✓ |
| Spanish (Mexican) | es-mx | Male | Raul | |
| Swedish | sv | Female | Astrid | ✓ |
| Swedish | sv | Female | Hedvig | |
| Tamil | ta | Male | Valluvar | ✓ |
| Telugu | te | Female | Chitra | ✓ |
| Thai | th | Male | Pattara | |
| Thai | th | Female | Somsi | ✓ |
| Turkish | tr | Female | Filiz | ✓ |
| Turkish | tr | Female | Seda | |
| Vietnamese | vi | Male | An | ✓ |
| Welsh | wls | Female | Gwyneth | ✓ |