curl --request POST \
--url https://api.tryhamsa.com/v1/realtime/tts \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "مرحباً بكم في جميعاً في همسة!",
"speaker": "Majd",
"dialect": "pls",
"mulaw": false
}
'import requests
url = "https://api.tryhamsa.com/v1/realtime/tts"
payload = {
"text": "مرحباً بكم في جميعاً في همسة!",
"speaker": "Majd",
"dialect": "pls",
"mulaw": False
}
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: 'Majd',
dialect: 'pls',
mulaw: false
})
};
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' => 'Majd',
'dialect' => 'pls',
'mulaw' => false
]),
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\": \"Majd\",\n \"dialect\": \"pls\",\n \"mulaw\": false\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\": \"Majd\",\n \"dialect\": \"pls\",\n \"mulaw\": false\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\": \"Majd\",\n \"dialect\": \"pls\",\n \"mulaw\": false\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": "Majd",
"dialect": "pls",
"mulaw": false
}
'import requests
url = "https://api.tryhamsa.com/v1/realtime/tts"
payload = {
"text": "مرحباً بكم في جميعاً في همسة!",
"speaker": "Majd",
"dialect": "pls",
"mulaw": False
}
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: 'Majd',
dialect: 'pls',
mulaw: false
})
};
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' => 'Majd',
'dialect' => 'pls',
'mulaw' => false
]),
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\": \"Majd\",\n \"dialect\": \"pls\",\n \"mulaw\": false\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\": \"Majd\",\n \"dialect\": \"pls\",\n \"mulaw\": false\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\": \"Majd\",\n \"dialect\": \"pls\",\n \"mulaw\": false\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 name, Suggestions: Amjad, Lyali, Salma, Mariam, Dalal, Lana, Jasem, Samir, Carla, Nada, or you can provide another values from the voice agents dashboard. You can also provide your own cloned voice's id here in the speaker field, but you need to preload that voice into the system first from here
"Majd"
The dialect of each country by its country code. Recommended voices per dialect are: pls (Palestinian): Amjad, Layan, Talin, Rema, Ali; leb (Lebanese): Carla, Majd; jor (Jordanian): Lana, Jasem, Nada, Sarah; syr (Syrian): Dalal, Mais; ksa (Saudi): Hiba, Khadija, Fahd, Jasem; bah (Bahraini): Mazen, Ruba; uae (Emirati): Salma, Dima; egy (Egyptian): Mariam, Samir, Nada, Ali, Ahmed; irq (Iraqi): Lyali, Fatma.
pls, egy, syr, irq, jor, leb, ksa, uae, bah, qat, msa "pls"
Whether to use 'Mu-Law' algorithm in voice signal processing or not.
false
Response
Successful response
The response is of type file.