Create TTS history
curl --request POST \
--url https://api.tryhamsa.com/v2/tts/histories \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"ttsVoiceId": "633f19a6-089b-4950-bfab-55f5c750732e",
"script": "مرحباً، هذا مثال على نص التحويل إلى صوت.",
"apiKey": "9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa",
"config": {
"speed": 1,
"expressiveness": 1
},
"voiceDictionaryIds": [
"6ac0324d-bcb9-40f3-a57a-de6da7b721c8"
]
}
'import requests
url = "https://api.tryhamsa.com/v2/tts/histories"
payload = {
"ttsVoiceId": "633f19a6-089b-4950-bfab-55f5c750732e",
"script": "مرحباً، هذا مثال على نص التحويل إلى صوت.",
"apiKey": "9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa",
"config": {
"speed": 1,
"expressiveness": 1
},
"voiceDictionaryIds": ["6ac0324d-bcb9-40f3-a57a-de6da7b721c8"]
}
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({
ttsVoiceId: '633f19a6-089b-4950-bfab-55f5c750732e',
script: 'مرحباً، هذا مثال على نص التحويل إلى صوت.',
apiKey: '9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa',
config: {speed: 1, expressiveness: 1},
voiceDictionaryIds: ['6ac0324d-bcb9-40f3-a57a-de6da7b721c8']
})
};
fetch('https://api.tryhamsa.com/v2/tts/histories', 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/v2/tts/histories",
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([
'ttsVoiceId' => '633f19a6-089b-4950-bfab-55f5c750732e',
'script' => 'مرحباً، هذا مثال على نص التحويل إلى صوت.',
'apiKey' => '9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa',
'config' => [
'speed' => 1,
'expressiveness' => 1
],
'voiceDictionaryIds' => [
'6ac0324d-bcb9-40f3-a57a-de6da7b721c8'
]
]),
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/v2/tts/histories"
payload := strings.NewReader("{\n \"ttsVoiceId\": \"633f19a6-089b-4950-bfab-55f5c750732e\",\n \"script\": \"مرحباً، هذا مثال على نص التحويل إلى صوت.\",\n \"apiKey\": \"9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa\",\n \"config\": {\n \"speed\": 1,\n \"expressiveness\": 1\n },\n \"voiceDictionaryIds\": [\n \"6ac0324d-bcb9-40f3-a57a-de6da7b721c8\"\n ]\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/v2/tts/histories")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ttsVoiceId\": \"633f19a6-089b-4950-bfab-55f5c750732e\",\n \"script\": \"مرحباً، هذا مثال على نص التحويل إلى صوت.\",\n \"apiKey\": \"9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa\",\n \"config\": {\n \"speed\": 1,\n \"expressiveness\": 1\n },\n \"voiceDictionaryIds\": [\n \"6ac0324d-bcb9-40f3-a57a-de6da7b721c8\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/tts/histories")
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 \"ttsVoiceId\": \"633f19a6-089b-4950-bfab-55f5c750732e\",\n \"script\": \"مرحباً، هذا مثال على نص التحويل إلى صوت.\",\n \"apiKey\": \"9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa\",\n \"config\": {\n \"speed\": 1,\n \"expressiveness\": 1\n },\n \"voiceDictionaryIds\": [\n \"6ac0324d-bcb9-40f3-a57a-de6da7b721c8\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Operation completed successfully",
"messageKey": "OPERATION_SUCCESSFUL",
"data": []
}{
"code": 9400,
"message": "Field must be a string!",
"messageKey": "FieldMustBeString"
}{
"success": false,
"code": 404,
"message": "Resource not found"
}{
"success": false,
"code": 500,
"message": "Internal server error"
}Text to Speech Routes
Create TTS history
Create a new TTS history entry for a generated audio clip.
POST
/
v2
/
tts
/
histories
Create TTS history
curl --request POST \
--url https://api.tryhamsa.com/v2/tts/histories \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"ttsVoiceId": "633f19a6-089b-4950-bfab-55f5c750732e",
"script": "مرحباً، هذا مثال على نص التحويل إلى صوت.",
"apiKey": "9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa",
"config": {
"speed": 1,
"expressiveness": 1
},
"voiceDictionaryIds": [
"6ac0324d-bcb9-40f3-a57a-de6da7b721c8"
]
}
'import requests
url = "https://api.tryhamsa.com/v2/tts/histories"
payload = {
"ttsVoiceId": "633f19a6-089b-4950-bfab-55f5c750732e",
"script": "مرحباً، هذا مثال على نص التحويل إلى صوت.",
"apiKey": "9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa",
"config": {
"speed": 1,
"expressiveness": 1
},
"voiceDictionaryIds": ["6ac0324d-bcb9-40f3-a57a-de6da7b721c8"]
}
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({
ttsVoiceId: '633f19a6-089b-4950-bfab-55f5c750732e',
script: 'مرحباً، هذا مثال على نص التحويل إلى صوت.',
apiKey: '9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa',
config: {speed: 1, expressiveness: 1},
voiceDictionaryIds: ['6ac0324d-bcb9-40f3-a57a-de6da7b721c8']
})
};
fetch('https://api.tryhamsa.com/v2/tts/histories', 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/v2/tts/histories",
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([
'ttsVoiceId' => '633f19a6-089b-4950-bfab-55f5c750732e',
'script' => 'مرحباً، هذا مثال على نص التحويل إلى صوت.',
'apiKey' => '9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa',
'config' => [
'speed' => 1,
'expressiveness' => 1
],
'voiceDictionaryIds' => [
'6ac0324d-bcb9-40f3-a57a-de6da7b721c8'
]
]),
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/v2/tts/histories"
payload := strings.NewReader("{\n \"ttsVoiceId\": \"633f19a6-089b-4950-bfab-55f5c750732e\",\n \"script\": \"مرحباً، هذا مثال على نص التحويل إلى صوت.\",\n \"apiKey\": \"9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa\",\n \"config\": {\n \"speed\": 1,\n \"expressiveness\": 1\n },\n \"voiceDictionaryIds\": [\n \"6ac0324d-bcb9-40f3-a57a-de6da7b721c8\"\n ]\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/v2/tts/histories")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ttsVoiceId\": \"633f19a6-089b-4950-bfab-55f5c750732e\",\n \"script\": \"مرحباً، هذا مثال على نص التحويل إلى صوت.\",\n \"apiKey\": \"9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa\",\n \"config\": {\n \"speed\": 1,\n \"expressiveness\": 1\n },\n \"voiceDictionaryIds\": [\n \"6ac0324d-bcb9-40f3-a57a-de6da7b721c8\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/tts/histories")
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 \"ttsVoiceId\": \"633f19a6-089b-4950-bfab-55f5c750732e\",\n \"script\": \"مرحباً، هذا مثال على نص التحويل إلى صوت.\",\n \"apiKey\": \"9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa\",\n \"config\": {\n \"speed\": 1,\n \"expressiveness\": 1\n },\n \"voiceDictionaryIds\": [\n \"6ac0324d-bcb9-40f3-a57a-de6da7b721c8\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Operation completed successfully",
"messageKey": "OPERATION_SUCCESSFUL",
"data": []
}{
"code": 9400,
"message": "Field must be a string!",
"messageKey": "FieldMustBeString"
}{
"success": false,
"code": 404,
"message": "Resource not found"
}{
"success": false,
"code": 500,
"message": "Internal server error"
}Authorizations
Pass the API key in the Authorization header, You need to put Token keyword before the API key. e.g. 'Authorization: Token '
Body
application/json
TTS voice identifier
Example:
"633f19a6-089b-4950-bfab-55f5c750732e"
Text to be synthesized. Must contain real Arabic or English text.
Required string length:
1 - 3000Example:
"مرحباً، هذا مثال على نص التحويل إلى صوت."
API key identifier (used for API key authorization)
Example:
"9f5f1f6a-2b1d-4a33-8fd4-6f5c2b89e3aa"
Optional voice generation configuration
Show child attributes
Show child attributes
Example:
{ "speed": 1, "expressiveness": 1 }
Optional list of voice dictionary identifiers
Required array length:
1 - 10 elementsWas this page helpful?
⌘I