curl --request POST \
--url https://api.tryhamsa.com/v3/realtime/connector/tts-stream \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "مرحبا، كيف يمكنني مساعدتك اليوم؟",
"voiceId": "078338c4-7788-4371-95d4-1bbe45021113",
"sampleRate": "8k",
"emotion": "calm",
"autoEmotion": false
}
'import requests
url = "https://api.tryhamsa.com/v3/realtime/connector/tts-stream"
payload = {
"text": "مرحبا، كيف يمكنني مساعدتك اليوم؟",
"voiceId": "078338c4-7788-4371-95d4-1bbe45021113",
"sampleRate": "8k",
"emotion": "calm",
"autoEmotion": 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: 'مرحبا، كيف يمكنني مساعدتك اليوم؟',
voiceId: '078338c4-7788-4371-95d4-1bbe45021113',
sampleRate: '8k',
emotion: 'calm',
autoEmotion: false
})
};
fetch('https://api.tryhamsa.com/v3/realtime/connector/tts-stream', 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/connector/tts-stream",
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' => 'مرحبا، كيف يمكنني مساعدتك اليوم؟',
'voiceId' => '078338c4-7788-4371-95d4-1bbe45021113',
'sampleRate' => '8k',
'emotion' => 'calm',
'autoEmotion' => 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/v3/realtime/connector/tts-stream"
payload := strings.NewReader("{\n \"text\": \"مرحبا، كيف يمكنني مساعدتك اليوم؟\",\n \"voiceId\": \"078338c4-7788-4371-95d4-1bbe45021113\",\n \"sampleRate\": \"8k\",\n \"emotion\": \"calm\",\n \"autoEmotion\": 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/v3/realtime/connector/tts-stream")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"مرحبا، كيف يمكنني مساعدتك اليوم؟\",\n \"voiceId\": \"078338c4-7788-4371-95d4-1bbe45021113\",\n \"sampleRate\": \"8k\",\n \"emotion\": \"calm\",\n \"autoEmotion\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v3/realtime/connector/tts-stream")
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 \"voiceId\": \"078338c4-7788-4371-95d4-1bbe45021113\",\n \"sampleRate\": \"8k\",\n \"emotion\": \"calm\",\n \"autoEmotion\": false\n}"
response = http.request(request)
puts response.read_body"<string>"<string><string><string><string><string><string><string><string>Connector TTS Stream with Style (v3)
Streams speech for text in a voice picked by ID, as a WAV stream (header, then 16-bit PCM mono). Built for TTS connectors such as Genesys: the speaker and language come from the voice. Same as the v1 connector route, plus dialect and the style fields emotion, casual, autoEmotion, mapFillers, useNativeEnglish and generationId; there is no expressiveness.
curl --request POST \
--url https://api.tryhamsa.com/v3/realtime/connector/tts-stream \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "مرحبا، كيف يمكنني مساعدتك اليوم؟",
"voiceId": "078338c4-7788-4371-95d4-1bbe45021113",
"sampleRate": "8k",
"emotion": "calm",
"autoEmotion": false
}
'import requests
url = "https://api.tryhamsa.com/v3/realtime/connector/tts-stream"
payload = {
"text": "مرحبا، كيف يمكنني مساعدتك اليوم؟",
"voiceId": "078338c4-7788-4371-95d4-1bbe45021113",
"sampleRate": "8k",
"emotion": "calm",
"autoEmotion": 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: 'مرحبا، كيف يمكنني مساعدتك اليوم؟',
voiceId: '078338c4-7788-4371-95d4-1bbe45021113',
sampleRate: '8k',
emotion: 'calm',
autoEmotion: false
})
};
fetch('https://api.tryhamsa.com/v3/realtime/connector/tts-stream', 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/connector/tts-stream",
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' => 'مرحبا، كيف يمكنني مساعدتك اليوم؟',
'voiceId' => '078338c4-7788-4371-95d4-1bbe45021113',
'sampleRate' => '8k',
'emotion' => 'calm',
'autoEmotion' => 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/v3/realtime/connector/tts-stream"
payload := strings.NewReader("{\n \"text\": \"مرحبا، كيف يمكنني مساعدتك اليوم؟\",\n \"voiceId\": \"078338c4-7788-4371-95d4-1bbe45021113\",\n \"sampleRate\": \"8k\",\n \"emotion\": \"calm\",\n \"autoEmotion\": 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/v3/realtime/connector/tts-stream")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"مرحبا، كيف يمكنني مساعدتك اليوم؟\",\n \"voiceId\": \"078338c4-7788-4371-95d4-1bbe45021113\",\n \"sampleRate\": \"8k\",\n \"emotion\": \"calm\",\n \"autoEmotion\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v3/realtime/connector/tts-stream")
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 \"voiceId\": \"078338c4-7788-4371-95d4-1bbe45021113\",\n \"sampleRate\": \"8k\",\n \"emotion\": \"calm\",\n \"autoEmotion\": false\n}"
response = http.request(request)
puts response.read_body"<string>"<string><string><string><string><string><string><string><string>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"أهلاً، كيف بقدر أساعدك اليوم؟"
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
WAV audio stream (chunked).
The response is of type file.
Was this page helpful?