curl --request POST \
--url https://api.tryhamsa.com/v3/realtime/tts \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "أهلاً، كيف بقدر أساعدك اليوم؟",
"speaker": "Amjad",
"dialect": "pls",
"emotion": "happy",
"casual": true,
"autoEmotion": false,
"generationId": "reply-7f3a2c"
}
'import requests
url = "https://api.tryhamsa.com/v3/realtime/tts"
payload = {
"text": "أهلاً، كيف بقدر أساعدك اليوم؟",
"speaker": "Amjad",
"dialect": "pls",
"emotion": "happy",
"casual": True,
"autoEmotion": False,
"generationId": "reply-7f3a2c"
}
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',
emotion: 'happy',
casual: true,
autoEmotion: false,
generationId: 'reply-7f3a2c'
})
};
fetch('https://api.tryhamsa.com/v3/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/v3/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',
'emotion' => 'happy',
'casual' => true,
'autoEmotion' => false,
'generationId' => 'reply-7f3a2c'
]),
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/v3/realtime/tts"
payload := strings.NewReader("{\n \"text\": \"أهلاً، كيف بقدر أساعدك اليوم؟\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"emotion\": \"happy\",\n \"casual\": true,\n \"autoEmotion\": false,\n \"generationId\": \"reply-7f3a2c\"\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/v3/realtime/tts")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"أهلاً، كيف بقدر أساعدك اليوم؟\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"emotion\": \"happy\",\n \"casual\": true,\n \"autoEmotion\": false,\n \"generationId\": \"reply-7f3a2c\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v3/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 \"emotion\": \"happy\",\n \"casual\": true,\n \"autoEmotion\": false,\n \"generationId\": \"reply-7f3a2c\"\n}"
response = http.request(request)
puts response.read_body"<string>"{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Generate Speech with Style (v3)
Generates a WAV file from text. Same as the v1 route, plus the style fields emotion, casual, autoEmotion, mapFillers, useNativeEnglish and generationId. There is no expressiveness, and dialect also takes eng (English).
curl --request POST \
--url https://api.tryhamsa.com/v3/realtime/tts \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "أهلاً، كيف بقدر أساعدك اليوم؟",
"speaker": "Amjad",
"dialect": "pls",
"emotion": "happy",
"casual": true,
"autoEmotion": false,
"generationId": "reply-7f3a2c"
}
'import requests
url = "https://api.tryhamsa.com/v3/realtime/tts"
payload = {
"text": "أهلاً، كيف بقدر أساعدك اليوم؟",
"speaker": "Amjad",
"dialect": "pls",
"emotion": "happy",
"casual": True,
"autoEmotion": False,
"generationId": "reply-7f3a2c"
}
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',
emotion: 'happy',
casual: true,
autoEmotion: false,
generationId: 'reply-7f3a2c'
})
};
fetch('https://api.tryhamsa.com/v3/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/v3/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',
'emotion' => 'happy',
'casual' => true,
'autoEmotion' => false,
'generationId' => 'reply-7f3a2c'
]),
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/v3/realtime/tts"
payload := strings.NewReader("{\n \"text\": \"أهلاً، كيف بقدر أساعدك اليوم؟\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"emotion\": \"happy\",\n \"casual\": true,\n \"autoEmotion\": false,\n \"generationId\": \"reply-7f3a2c\"\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/v3/realtime/tts")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"أهلاً، كيف بقدر أساعدك اليوم؟\",\n \"speaker\": \"Amjad\",\n \"dialect\": \"pls\",\n \"emotion\": \"happy\",\n \"casual\": true,\n \"autoEmotion\": false,\n \"generationId\": \"reply-7f3a2c\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v3/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 \"emotion\": \"happy\",\n \"casual\": true,\n \"autoEmotion\": false,\n \"generationId\": \"reply-7f3a2c\"\n}"
response = http.request(request)
puts response.read_body"<string>"{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Authorizations
Body
Text to speak, 1 to 2,000 characters. May contain <pause_short> and <pause_long>; a line break counts as a short pause. Numbers, dates and units are read out in words.
1 - 2000"أهلاً، كيف بقدر أساعدك اليوم؟"
The voice: a voice name, or the ID of one of your cloned voices (preload it first with the Preload Cloned Voice endpoint). An unknown voice, or a voice ID that isn't yours, gets 404.
"Amjad"
Overrides the voice's dialect. Leave it out (or send null) for the voice's own dialect. uae Emirati, ksa Saudi, kuw Kuwaiti, qat Qatari, bah Bahraini, oma Omani, egy Egyptian, jor Jordanian, pls Palestinian, leb Lebanese, syr Syrian, irq Iraqi, msa Modern Standard Arabic, eng English.
uae, ksa, kuw, qat, bah, oma, egy, jor, pls, leb, syr, irq, msa, eng "pls"
Speaking style for this request: neutral, happy, excited, calm, sympathetic, sad, frustrated, angry, surprised, hesitant, tired or whispering. Leave it out (or send null) for neutral.
neutral, happy, excited, calm, sympathetic, sad, frustrated, angry, surprised, hesitant, tired, whispering "happy"
Response
The whole WAV file.
The response is of type file.
Was this page helpful?