Preview TTS voice
curl --request POST \
--url https://api.tryhamsa.com/v2/tts/voices/preview \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"audioUrl": "https://cdn.tryhamsa.com/uploads/voice.wav",
"audioTranscription": "مرحباً، هذا مثال على التسجيل الصوتي.",
"language": "ar",
"dialectId": "145a7af6-3614-4bb2-be5d-702000d459ab",
"text": "أهلاً بك، هذا مثال لنطق الصوت."
}
'import requests
url = "https://api.tryhamsa.com/v2/tts/voices/preview"
payload = {
"audioUrl": "https://cdn.tryhamsa.com/uploads/voice.wav",
"audioTranscription": "مرحباً، هذا مثال على التسجيل الصوتي.",
"language": "ar",
"dialectId": "145a7af6-3614-4bb2-be5d-702000d459ab",
"text": "أهلاً بك، هذا مثال لنطق الصوت."
}
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({
audioUrl: 'https://cdn.tryhamsa.com/uploads/voice.wav',
audioTranscription: 'مرحباً، هذا مثال على التسجيل الصوتي.',
language: 'ar',
dialectId: '145a7af6-3614-4bb2-be5d-702000d459ab',
text: 'أهلاً بك، هذا مثال لنطق الصوت.'
})
};
fetch('https://api.tryhamsa.com/v2/tts/voices/preview', 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/voices/preview",
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([
'audioUrl' => 'https://cdn.tryhamsa.com/uploads/voice.wav',
'audioTranscription' => 'مرحباً، هذا مثال على التسجيل الصوتي.',
'language' => 'ar',
'dialectId' => '145a7af6-3614-4bb2-be5d-702000d459ab',
'text' => 'أهلاً بك، هذا مثال لنطق الصوت.'
]),
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/voices/preview"
payload := strings.NewReader("{\n \"audioUrl\": \"https://cdn.tryhamsa.com/uploads/voice.wav\",\n \"audioTranscription\": \"مرحباً، هذا مثال على التسجيل الصوتي.\",\n \"language\": \"ar\",\n \"dialectId\": \"145a7af6-3614-4bb2-be5d-702000d459ab\",\n \"text\": \"أهلاً بك، هذا مثال لنطق الصوت.\"\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/voices/preview")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"audioUrl\": \"https://cdn.tryhamsa.com/uploads/voice.wav\",\n \"audioTranscription\": \"مرحباً، هذا مثال على التسجيل الصوتي.\",\n \"language\": \"ar\",\n \"dialectId\": \"145a7af6-3614-4bb2-be5d-702000d459ab\",\n \"text\": \"أهلاً بك، هذا مثال لنطق الصوت.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/tts/voices/preview")
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 \"audioUrl\": \"https://cdn.tryhamsa.com/uploads/voice.wav\",\n \"audioTranscription\": \"مرحباً، هذا مثال على التسجيل الصوتي.\",\n \"language\": \"ar\",\n \"dialectId\": \"145a7af6-3614-4bb2-be5d-702000d459ab\",\n \"text\": \"أهلاً بك، هذا مثال لنطق الصوت.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Operation completed successfully",
"messageKey": "OPERATION_SUCCESSFUL",
"data": {
"audioUrl": "https://cdn.tryhamsa.com/previews/preview.wav"
}
}{
"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"
}Voice Cloning
Preview TTS voice
Generate a short preview clip for a TTS voice.
POST
/
v2
/
tts
/
voices
/
preview
Preview TTS voice
curl --request POST \
--url https://api.tryhamsa.com/v2/tts/voices/preview \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"audioUrl": "https://cdn.tryhamsa.com/uploads/voice.wav",
"audioTranscription": "مرحباً، هذا مثال على التسجيل الصوتي.",
"language": "ar",
"dialectId": "145a7af6-3614-4bb2-be5d-702000d459ab",
"text": "أهلاً بك، هذا مثال لنطق الصوت."
}
'import requests
url = "https://api.tryhamsa.com/v2/tts/voices/preview"
payload = {
"audioUrl": "https://cdn.tryhamsa.com/uploads/voice.wav",
"audioTranscription": "مرحباً، هذا مثال على التسجيل الصوتي.",
"language": "ar",
"dialectId": "145a7af6-3614-4bb2-be5d-702000d459ab",
"text": "أهلاً بك، هذا مثال لنطق الصوت."
}
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({
audioUrl: 'https://cdn.tryhamsa.com/uploads/voice.wav',
audioTranscription: 'مرحباً، هذا مثال على التسجيل الصوتي.',
language: 'ar',
dialectId: '145a7af6-3614-4bb2-be5d-702000d459ab',
text: 'أهلاً بك، هذا مثال لنطق الصوت.'
})
};
fetch('https://api.tryhamsa.com/v2/tts/voices/preview', 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/voices/preview",
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([
'audioUrl' => 'https://cdn.tryhamsa.com/uploads/voice.wav',
'audioTranscription' => 'مرحباً، هذا مثال على التسجيل الصوتي.',
'language' => 'ar',
'dialectId' => '145a7af6-3614-4bb2-be5d-702000d459ab',
'text' => 'أهلاً بك، هذا مثال لنطق الصوت.'
]),
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/voices/preview"
payload := strings.NewReader("{\n \"audioUrl\": \"https://cdn.tryhamsa.com/uploads/voice.wav\",\n \"audioTranscription\": \"مرحباً، هذا مثال على التسجيل الصوتي.\",\n \"language\": \"ar\",\n \"dialectId\": \"145a7af6-3614-4bb2-be5d-702000d459ab\",\n \"text\": \"أهلاً بك، هذا مثال لنطق الصوت.\"\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/voices/preview")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"audioUrl\": \"https://cdn.tryhamsa.com/uploads/voice.wav\",\n \"audioTranscription\": \"مرحباً، هذا مثال على التسجيل الصوتي.\",\n \"language\": \"ar\",\n \"dialectId\": \"145a7af6-3614-4bb2-be5d-702000d459ab\",\n \"text\": \"أهلاً بك، هذا مثال لنطق الصوت.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/tts/voices/preview")
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 \"audioUrl\": \"https://cdn.tryhamsa.com/uploads/voice.wav\",\n \"audioTranscription\": \"مرحباً، هذا مثال على التسجيل الصوتي.\",\n \"language\": \"ar\",\n \"dialectId\": \"145a7af6-3614-4bb2-be5d-702000d459ab\",\n \"text\": \"أهلاً بك، هذا مثال لنطق الصوت.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Operation completed successfully",
"messageKey": "OPERATION_SUCCESSFUL",
"data": {
"audioUrl": "https://cdn.tryhamsa.com/previews/preview.wav"
}
}{
"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 '
Query Parameters
Project identifier.
Example:
"ae6d58c6-c6bd-4ae0-ad74-b8b39c29928b"
Body
application/json
URL of the uploaded voice sample
Example:
"https://cdn.tryhamsa.com/uploads/voice.wav"
Transcription of the uploaded audio sample
Required string length:
1 - 5000Example:
"مرحباً، هذا مثال على التسجيل الصوتي."
Language of the preview voice
Available options:
en, ar Example:
"ar"
Dialect identifier (required for preview)
Example:
"145a7af6-3614-4bb2-be5d-702000d459ab"
Text to be synthesized using the preview voice
Required string length:
1 - 5000Example:
"أهلاً بك، هذا مثال لنطق الصوت."
Was this page helpful?
⌘I