curl --request POST \
--url https://api.withhopper.com/tts/bytes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_id": "<string>",
"transcript": "<string>",
"voice": {
"mode": "id",
"id": "<string>"
},
"output_format": {
"encoding": "pcm_s16le",
"bit_rate": 128000
},
"language": "<string>",
"generation_config": {
"speed": 1.05,
"volume": 1.25
},
"pronunciation_dict_id": "<string>",
"stream": false
}
'import requests
url = "https://api.withhopper.com/tts/bytes"
payload = {
"model_id": "<string>",
"transcript": "<string>",
"voice": {
"mode": "id",
"id": "<string>"
},
"output_format": {
"encoding": "pcm_s16le",
"bit_rate": 128000
},
"language": "<string>",
"generation_config": {
"speed": 1.05,
"volume": 1.25
},
"pronunciation_dict_id": "<string>",
"stream": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_id: '<string>',
transcript: '<string>',
voice: {mode: 'id', id: '<string>'},
output_format: {encoding: 'pcm_s16le', bit_rate: 128000},
language: '<string>',
generation_config: {speed: 1.05, volume: 1.25},
pronunciation_dict_id: '<string>',
stream: false
})
};
fetch('https://api.withhopper.com/tts/bytes', 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.withhopper.com/tts/bytes",
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([
'model_id' => '<string>',
'transcript' => '<string>',
'voice' => [
'mode' => 'id',
'id' => '<string>'
],
'output_format' => [
'encoding' => 'pcm_s16le',
'bit_rate' => 128000
],
'language' => '<string>',
'generation_config' => [
'speed' => 1.05,
'volume' => 1.25
],
'pronunciation_dict_id' => '<string>',
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.withhopper.com/tts/bytes"
payload := strings.NewReader("{\n \"model_id\": \"<string>\",\n \"transcript\": \"<string>\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"<string>\"\n },\n \"output_format\": {\n \"encoding\": \"pcm_s16le\",\n \"bit_rate\": 128000\n },\n \"language\": \"<string>\",\n \"generation_config\": {\n \"speed\": 1.05,\n \"volume\": 1.25\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"stream\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.withhopper.com/tts/bytes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_id\": \"<string>\",\n \"transcript\": \"<string>\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"<string>\"\n },\n \"output_format\": {\n \"encoding\": \"pcm_s16le\",\n \"bit_rate\": 128000\n },\n \"language\": \"<string>\",\n \"generation_config\": {\n \"speed\": 1.05,\n \"volume\": 1.25\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withhopper.com/tts/bytes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_id\": \"<string>\",\n \"transcript\": \"<string>\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"<string>\"\n },\n \"output_format\": {\n \"encoding\": \"pcm_s16le\",\n \"bit_rate\": 128000\n },\n \"language\": \"<string>\",\n \"generation_config\": {\n \"speed\": 1.05,\n \"volume\": 1.25\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"message": "Streaming TTS does not support mp3; use wav or pcm/raw.",
"type": "invalid_request_error",
"code": "invalid_output_format",
"param": null
}
}{
"error": {
"message": "Incorrect API key provided. Check your key at https://withhopper.com/dashboard.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "You have run out of credits. Contact us to add more.",
"type": "insufficient_quota",
"code": "insufficient_quota",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "Voice 'X' is not prepared for model 'Y'.",
"type": "invalid_request_error",
"code": "voice_profile_missing",
"param": null
}
}{
"error": {
"message": "Rate limit reached: 600 requests per minute per key. Retry after 21s.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Generate speech
Native speech synthesis with full control of container, sample rate, and encoding. Returns raw audio bytes; set stream true for progressive relay of WAV/PCM bytes.
curl --request POST \
--url https://api.withhopper.com/tts/bytes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_id": "<string>",
"transcript": "<string>",
"voice": {
"mode": "id",
"id": "<string>"
},
"output_format": {
"encoding": "pcm_s16le",
"bit_rate": 128000
},
"language": "<string>",
"generation_config": {
"speed": 1.05,
"volume": 1.25
},
"pronunciation_dict_id": "<string>",
"stream": false
}
'import requests
url = "https://api.withhopper.com/tts/bytes"
payload = {
"model_id": "<string>",
"transcript": "<string>",
"voice": {
"mode": "id",
"id": "<string>"
},
"output_format": {
"encoding": "pcm_s16le",
"bit_rate": 128000
},
"language": "<string>",
"generation_config": {
"speed": 1.05,
"volume": 1.25
},
"pronunciation_dict_id": "<string>",
"stream": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_id: '<string>',
transcript: '<string>',
voice: {mode: 'id', id: '<string>'},
output_format: {encoding: 'pcm_s16le', bit_rate: 128000},
language: '<string>',
generation_config: {speed: 1.05, volume: 1.25},
pronunciation_dict_id: '<string>',
stream: false
})
};
fetch('https://api.withhopper.com/tts/bytes', 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.withhopper.com/tts/bytes",
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([
'model_id' => '<string>',
'transcript' => '<string>',
'voice' => [
'mode' => 'id',
'id' => '<string>'
],
'output_format' => [
'encoding' => 'pcm_s16le',
'bit_rate' => 128000
],
'language' => '<string>',
'generation_config' => [
'speed' => 1.05,
'volume' => 1.25
],
'pronunciation_dict_id' => '<string>',
'stream' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.withhopper.com/tts/bytes"
payload := strings.NewReader("{\n \"model_id\": \"<string>\",\n \"transcript\": \"<string>\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"<string>\"\n },\n \"output_format\": {\n \"encoding\": \"pcm_s16le\",\n \"bit_rate\": 128000\n },\n \"language\": \"<string>\",\n \"generation_config\": {\n \"speed\": 1.05,\n \"volume\": 1.25\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"stream\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.withhopper.com/tts/bytes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_id\": \"<string>\",\n \"transcript\": \"<string>\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"<string>\"\n },\n \"output_format\": {\n \"encoding\": \"pcm_s16le\",\n \"bit_rate\": 128000\n },\n \"language\": \"<string>\",\n \"generation_config\": {\n \"speed\": 1.05,\n \"volume\": 1.25\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withhopper.com/tts/bytes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_id\": \"<string>\",\n \"transcript\": \"<string>\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"<string>\"\n },\n \"output_format\": {\n \"encoding\": \"pcm_s16le\",\n \"bit_rate\": 128000\n },\n \"language\": \"<string>\",\n \"generation_config\": {\n \"speed\": 1.05,\n \"volume\": 1.25\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"message": "Streaming TTS does not support mp3; use wav or pcm/raw.",
"type": "invalid_request_error",
"code": "invalid_output_format",
"param": null
}
}{
"error": {
"message": "Incorrect API key provided. Check your key at https://withhopper.com/dashboard.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}{
"error": {
"message": "You have run out of credits. Contact us to add more.",
"type": "insufficient_quota",
"code": "insufficient_quota",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "Voice 'X' is not prepared for model 'Y'.",
"type": "invalid_request_error",
"code": "voice_profile_missing",
"param": null
}
}{
"error": {
"message": "Rate limit reached: 600 requests per minute per key. Retry after 21s.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Authorizations
API key in the Authorization header: Bearer sk_hopper_... Keys are minted in the dashboard at withhopper.com/console/keys and shown once at creation. WebSocket connections also accept ?api_key=.
Body
TTS model id, e.g. omnivoice.
Text to synthesize, 1-5000 characters. Billed per character of the submitted transcript, before dictionary expansion.
1 - 5000Show child attributes
Show child attributes
Show child attributes
Show child attributes
ISO language code.
^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})?$Show child attributes
Show child attributes
Dictionary applied before synthesis; 404 dict_not_found if unknown.
On /tts/bytes: relay raw WAV/PCM bytes progressively as they are generated. Ignored on /tts/sse, which always streams.
Response
Audio bytes. Content-Type follows output_format.container.
The response is of type file.