Models
Generate Speech
Generates speech using the voice identified by voice_id and returns a URL for one completed mono PCM16 WAV file at 44.1 kHz. The request remains open until synthesis and output assembly finish. The voice must be an ACTIVE professional voice. Rate limit: 30 requests per minute per workspace member.
POST
/
v3
/
models
/
audio
/
tts
Generate Speech
curl --request POST \
--url https://api.heygen.com/v3/models/audio/tts \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"voice_id": "<string>",
"text": "<string>",
"language": "<string>",
"seed": 2147483647
}
'import requests
url = "https://api.heygen.com/v3/models/audio/tts"
payload = {
"voice_id": "<string>",
"text": "<string>",
"language": "<string>",
"seed": 2147483647
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({voice_id: '<string>', text: '<string>', language: '<string>', seed: 2147483647})
};
fetch('https://api.heygen.com/v3/models/audio/tts', 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.heygen.com/v3/models/audio/tts",
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([
'voice_id' => '<string>',
'text' => '<string>',
'language' => '<string>',
'seed' => 2147483647
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.heygen.com/v3/models/audio/tts"
payload := strings.NewReader("{\n \"voice_id\": \"<string>\",\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"seed\": 2147483647\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.heygen.com/v3/models/audio/tts")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"voice_id\": \"<string>\",\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"seed\": 2147483647\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.heygen.com/v3/models/audio/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voice_id\": \"<string>\",\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"seed\": 2147483647\n}"
response = http.request(request)
puts response.read_body{
"data": {
"audio_url": "<string>",
"duration": 1
}
}Authorizations
ApiKeyAuthBearerAuth
HeyGen API key. Obtain from your HeyGen dashboard.
Body
application/json
Identifier of the voice used for speech synthesis.
Minimum string length:
1Plain text to synthesize. SSML and break tags are not supported.
Required string length:
1 - 5000Language code used for speech synthesis, such as en.
Minimum string length:
1Optional best-effort deterministic generation seed.
Required range:
0 <= x <= 4294967295Response
Successful response
Show child attributes
Show child attributes
⌘I
Generate Speech
curl --request POST \
--url https://api.heygen.com/v3/models/audio/tts \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"voice_id": "<string>",
"text": "<string>",
"language": "<string>",
"seed": 2147483647
}
'import requests
url = "https://api.heygen.com/v3/models/audio/tts"
payload = {
"voice_id": "<string>",
"text": "<string>",
"language": "<string>",
"seed": 2147483647
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({voice_id: '<string>', text: '<string>', language: '<string>', seed: 2147483647})
};
fetch('https://api.heygen.com/v3/models/audio/tts', 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.heygen.com/v3/models/audio/tts",
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([
'voice_id' => '<string>',
'text' => '<string>',
'language' => '<string>',
'seed' => 2147483647
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.heygen.com/v3/models/audio/tts"
payload := strings.NewReader("{\n \"voice_id\": \"<string>\",\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"seed\": 2147483647\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.heygen.com/v3/models/audio/tts")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"voice_id\": \"<string>\",\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"seed\": 2147483647\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.heygen.com/v3/models/audio/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voice_id\": \"<string>\",\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"seed\": 2147483647\n}"
response = http.request(request)
puts response.read_body{
"data": {
"audio_url": "<string>",
"duration": 1
}
}
