curl --request POST \
--url https://api.tryhamsa.com/v1/realtime/tts \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "مرحباً بكم في جميعاً في همسة!",
"speaker": "Amjad",
"dialect": "pls",
"mulaw": false,
"sampleRate": "16k",
"expressiveness": 1
}
'import requests
url = "https://api.tryhamsa.com/v1/realtime/tts"
payload = {
"text": "مرحباً بكم في جميعاً في همسة!",
"speaker": "Amjad",
"dialect": "pls",
"mulaw": False,
"sampleRate": "16k",
"expressiveness": 1
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'مرحباً بكم في جميعاً في همسة!',
speaker: 'Amjad',
dialect: 'pls',
mulaw: false,
sampleRate: '16k',
expressiveness: 1
})
};
fetch('https://api.tryhamsa.com/v1/realtime/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryhamsa.com/v1/realtime/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 => json_encode([
'text' => 'مرحباً بكم في جميعاً في همسة!',
'speaker' => 'Amjad',
'dialect' => 'pls',
'mulaw' => false,
'sampleRate' => '16k',
'expressiveness' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: <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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tryhamsa.com/v1/realtime/tts"
payload := strings.NewReader("{\n \"text\": \"مرحباً بكم في جميعاً في همسة!\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"mulaw\": false,\n \"sampleRate\": \"16k\",\n \"expressiveness\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tryhamsa.com/v1/realtime/tts")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"مرحباً بكم في جميعاً في همسة!\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"mulaw\": false,\n \"sampleRate\": \"16k\",\n \"expressiveness\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v1/realtime/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"مرحباً بكم في جميعاً في همسة!\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"mulaw\": false,\n \"sampleRate\": \"16k\",\n \"expressiveness\": 1\n}"
response = http.request(request)
puts response.read_body"<string>"{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Generate Text to Speech File Data
curl --request POST \
--url https://api.tryhamsa.com/v1/realtime/tts \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "مرحباً بكم في جميعاً في همسة!",
"speaker": "Amjad",
"dialect": "pls",
"mulaw": false,
"sampleRate": "16k",
"expressiveness": 1
}
'import requests
url = "https://api.tryhamsa.com/v1/realtime/tts"
payload = {
"text": "مرحباً بكم في جميعاً في همسة!",
"speaker": "Amjad",
"dialect": "pls",
"mulaw": False,
"sampleRate": "16k",
"expressiveness": 1
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'مرحباً بكم في جميعاً في همسة!',
speaker: 'Amjad',
dialect: 'pls',
mulaw: false,
sampleRate: '16k',
expressiveness: 1
})
};
fetch('https://api.tryhamsa.com/v1/realtime/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryhamsa.com/v1/realtime/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 => json_encode([
'text' => 'مرحباً بكم في جميعاً في همسة!',
'speaker' => 'Amjad',
'dialect' => 'pls',
'mulaw' => false,
'sampleRate' => '16k',
'expressiveness' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: <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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tryhamsa.com/v1/realtime/tts"
payload := strings.NewReader("{\n \"text\": \"مرحباً بكم في جميعاً في همسة!\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"mulaw\": false,\n \"sampleRate\": \"16k\",\n \"expressiveness\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tryhamsa.com/v1/realtime/tts")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"مرحباً بكم في جميعاً في همسة!\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"mulaw\": false,\n \"sampleRate\": \"16k\",\n \"expressiveness\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v1/realtime/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"مرحباً بكم في جميعاً في همسة!\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"mulaw\": false,\n \"sampleRate\": \"16k\",\n \"expressiveness\": 1\n}"
response = http.request(request)
puts response.read_body"<string>"{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Authorizations
Pass the API key in the Authorization header, You need to put Token keyword before the API key. e.g. 'Authorization: Token '
Body
The text to be generated as an aduio file.
"مرحباً بكم في جميعاً في همسة!"
The speaker (voice) name. Pick a voice that matches the chosen dialect — see the dialect field for voice examples per dialect. You can also pass the UUID of a custom cloned voice, but you must first preload it via the Preload Cloned Voice endpoint.
"Amjad"
The dialect to synthesize, identified by its country/region code. Voice examples per dialect:
pls(Palestinian) — Amjad, Layanegy(Egyptian) — Mariam, Samirsyr(Syrian) — Dalal, Maisirq(Iraqi) — Lyali, Fatmajor(Jordanian) — Lana, Jasemleb(Lebanese) — Carla, Majdksa(Saudi) — Hiba, Fahduae(Emirati) — Salma, Dimabah(Bahraini) — Mazen, Rubaqat(Qatari) — Deema, Faisalkuw(Kuwaiti) — Mai, Hatemoma(Omani) — Aisha, Jabermsa(Modern Standard Arabic / Fusha) — Salem, Tamimar-sa(Arabic – Gulf) — Khalid, Rahmaen(English) — Emma, James
pls, egy, syr, irq, jor, leb, ksa, uae, bah, qat, kuw, oma, msa, ar-sa, en "pls"
Whether to use 'Mu-Law' algorithm in voice signal processing or not.
false
Output sample rate of the PCM audio. Defaults to 16k. Only applies to PCM output — cannot be combined with mulaw (mu-law output is always 8 kHz).
8k, 16k "16k"
Controls how expressive the generated speech sounds. 0 is flat and monotone, 1 is the natural default, and 2 is highly expressive.
0 <= x <= 21
Response
Successful response
The response is of type file.
Was this page helpful?