curl --request POST \
--url http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize \
--header 'Content-Type: application/json' \
--data '
{
"text": "Hello, how are you today?",
"model": "melo-tts-en",
"language": "en",
"voice": "default",
"sample_rate": 44100,
"output_speaker": false
}
'import requests
url = "http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize"
payload = {
"text": "Hello, how are you today?",
"model": "melo-tts-en",
"language": "en",
"voice": "default",
"sample_rate": 44100,
"output_speaker": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'Hello, how are you today?',
model: 'melo-tts-en',
language: 'en',
voice: 'default',
sample_rate: 44100,
output_speaker: false
})
};
fetch('http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "62437",
CURLOPT_URL => "http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize",
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' => 'Hello, how are you today?',
'model' => 'melo-tts-en',
'language' => 'en',
'voice' => 'default',
'sample_rate' => 44100,
'output_speaker' => false
]),
CURLOPT_HTTPHEADER => [
"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 := "http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize"
payload := strings.NewReader("{\n \"text\": \"Hello, how are you today?\",\n \"model\": \"melo-tts-en\",\n \"language\": \"en\",\n \"voice\": \"default\",\n \"sample_rate\": 44100,\n \"output_speaker\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Hello, how are you today?\",\n \"model\": \"melo-tts-en\",\n \"language\": \"en\",\n \"voice\": \"default\",\n \"sample_rate\": 44100,\n \"output_speaker\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Hello, how are you today?\",\n \"model\": \"melo-tts-en\",\n \"language\": \"en\",\n \"voice\": \"default\",\n \"sample_rate\": 44100,\n \"output_speaker\": false\n}"
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"message": "Invalid request, missing 'file' parameter",
"type": "invalid_request_error",
"param": "file",
"code": null
}
}{
"error": {
"message": "Invalid request, missing 'file' parameter",
"type": "invalid_request_error",
"param": "file",
"code": null
}
}Synthesize speech from text
Converts text into spoken audio using text-to-speech synthesis.
Features
- Multiple voices and languages
- Configurable sample rate (44100, 22050, 16000 Hz)
- Automatic resampling
- Streaming audio output (chunked transfer encoding)
Sample Rate
The TTS engine outputs audio at 44100 Hz by default. If you specify a different
sample_rate, the audio will be automatically resampled to match your request.
Example Request
{
"text": "Hello, how are you today?",
"model": "melo-tts-en",
"language": "en",
"voice": "default",
"sample_rate": 44100
}
Response
The response is binary PCM audio data (raw audio, not WAV format) streamed using HTTP chunked
transfer encoding. To play the audio, you’ll need to convert it to WAV format using the
provided pcm_to_wav.py script:
python pcm_to_wav.py speech.pcm speech.wav --rate 44100 --channels 1 --bits 16
Supported Parameters
Check model capabilities via /tts/models to see which parameters are supported:
gender: Voice gender (if supported)style: Speaking style (if supported)sample_rate: Output sample rate (if supported)parameters: Additional fine-tuning options
curl --request POST \
--url http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize \
--header 'Content-Type: application/json' \
--data '
{
"text": "Hello, how are you today?",
"model": "melo-tts-en",
"language": "en",
"voice": "default",
"sample_rate": 44100,
"output_speaker": false
}
'import requests
url = "http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize"
payload = {
"text": "Hello, how are you today?",
"model": "melo-tts-en",
"language": "en",
"voice": "default",
"sample_rate": 44100,
"output_speaker": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'Hello, how are you today?',
model: 'melo-tts-en',
language: 'en',
voice: 'default',
sample_rate: 44100,
output_speaker: false
})
};
fetch('http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "62437",
CURLOPT_URL => "http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize",
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' => 'Hello, how are you today?',
'model' => 'melo-tts-en',
'language' => 'en',
'voice' => 'default',
'sample_rate' => 44100,
'output_speaker' => false
]),
CURLOPT_HTTPHEADER => [
"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 := "http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize"
payload := strings.NewReader("{\n \"text\": \"Hello, how are you today?\",\n \"model\": \"melo-tts-en\",\n \"language\": \"en\",\n \"voice\": \"default\",\n \"sample_rate\": 44100,\n \"output_speaker\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Hello, how are you today?\",\n \"model\": \"melo-tts-en\",\n \"language\": \"en\",\n \"voice\": \"default\",\n \"sample_rate\": 44100,\n \"output_speaker\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://{device-ip}:{device-port}/audio-analytics/v1/api/tts/synthesize")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Hello, how are you today?\",\n \"model\": \"melo-tts-en\",\n \"language\": \"en\",\n \"voice\": \"default\",\n \"sample_rate\": 44100,\n \"output_speaker\": false\n}"
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"message": "Invalid request, missing 'file' parameter",
"type": "invalid_request_error",
"param": "file",
"code": null
}
}{
"error": {
"message": "Invalid request, missing 'file' parameter",
"type": "invalid_request_error",
"param": "file",
"code": null
}
}Body
Text-to-speech synthesis request
Text to synthesize into speech
"Hello, how are you today?"
TTS model ID
"melo-tts-en"
ISO 639-1 language code
"en"
Voice identifier (if model supports multiple voices)
"default"
Voice gender preference (if supported by model)
male, female, neutral "neutral"
Speaking style (if supported by model)
"neutral"
Output sample rate in Hz (if supported by model). Audio will be resampled if different from native rate.
44100
Additional synthesis parameters (e.g., speaking_rate, pitch, gain)
Show child attributes
Show child attributes
{
"speaking_rate": "1.0",
"pitch": "1.0",
"gain": "0.0"
}
Output audio data results to speaker
false
Response
Speech synthesized successfully
Raw PCM audio data (16-bit little-endian). Not WAV — convert before playback.
Was this page helpful?

