Predict text-to-speech duration
curl --request POST \
--url https://supertoneapi.com/v1/predict-duration/{voice_id} \
--header 'Content-Type: application/json' \
--header 'x-sup-api-key: <api-key>' \
--data '
{
"text": "<string>",
"style": "<string>",
"model": "sona_speech_1",
"output_format": "wav",
"voice_settings": {
"pitch_shift": 0,
"pitch_variance": 1,
"speed": 1,
"duration": 0,
"similarity": 3,
"text_guidance": 1,
"subharmonic_amplitude_control": 1
}
}
'import requests
url = "https://supertoneapi.com/v1/predict-duration/{voice_id}"
payload = {
"text": "<string>",
"style": "<string>",
"model": "sona_speech_1",
"output_format": "wav",
"voice_settings": {
"pitch_shift": 0,
"pitch_variance": 1,
"speed": 1,
"duration": 0,
"similarity": 3,
"text_guidance": 1,
"subharmonic_amplitude_control": 1
}
}
headers = {
"x-sup-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-sup-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
style: '<string>',
model: 'sona_speech_1',
output_format: 'wav',
voice_settings: {
pitch_shift: 0,
pitch_variance: 1,
speed: 1,
duration: 0,
similarity: 3,
text_guidance: 1,
subharmonic_amplitude_control: 1
}
})
};
fetch('https://supertoneapi.com/v1/predict-duration/{voice_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://supertoneapi.com/v1/predict-duration/{voice_id}"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"style\": \"<string>\",\n \"model\": \"sona_speech_1\",\n \"output_format\": \"wav\",\n \"voice_settings\": {\n \"pitch_shift\": 0,\n \"pitch_variance\": 1,\n \"speed\": 1,\n \"duration\": 0,\n \"similarity\": 3,\n \"text_guidance\": 1,\n \"subharmonic_amplitude_control\": 1\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-sup-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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://supertoneapi.com/v1/predict-duration/{voice_id}",
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' => '<string>',
'style' => '<string>',
'model' => 'sona_speech_1',
'output_format' => 'wav',
'voice_settings' => [
'pitch_shift' => 0,
'pitch_variance' => 1,
'speed' => 1,
'duration' => 0,
'similarity' => 3,
'text_guidance' => 1,
'subharmonic_amplitude_control' => 1
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-sup-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://supertoneapi.com/v1/predict-duration/{voice_id}")
.header("x-sup-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"style\": \"<string>\",\n \"model\": \"sona_speech_1\",\n \"output_format\": \"wav\",\n \"voice_settings\": {\n \"pitch_shift\": 0,\n \"pitch_variance\": 1,\n \"speed\": 1,\n \"duration\": 0,\n \"similarity\": 3,\n \"text_guidance\": 1,\n \"subharmonic_amplitude_control\": 1\n }\n}")
.asString();{
"duration": 123
}{
"status": "error",
"message": "Invalid request data"
}{
"status": "error",
"message": {
"message": "Invalid API Key",
"error": "Unauthorized"
}
}{
"status": "error",
"message": {
"message": "Not enough credits",
"error": "Payment Required"
}
}{
"status": "error",
"message": {
"message": "Permission denied",
"error": "Forbidden"
}
}{
"status": "error",
"message": {
"message": "Voice not found",
"error": "Not Found"
}
}{
"status": "error",
"message": {
"message": "Request timed out",
"error": "Request Timeout"
}
}{
"status": "error",
"message": {
"message": "rate limit exceeded",
"error": "Too Many Requests"
}
}{
"status": "error",
"message": {
"message": "Failed to convert text to speech",
"error": "Internal Server Error"
}
}Text to speech
Predict duration
주어진 텍스트로 생성될 음성의 길이를 추정합니다 — 오디오를 생성하거나 크레딧을 소비하지 않습니다.
POST
/
v1
/
predict-duration
/
{voice_id}
Predict text-to-speech duration
curl --request POST \
--url https://supertoneapi.com/v1/predict-duration/{voice_id} \
--header 'Content-Type: application/json' \
--header 'x-sup-api-key: <api-key>' \
--data '
{
"text": "<string>",
"style": "<string>",
"model": "sona_speech_1",
"output_format": "wav",
"voice_settings": {
"pitch_shift": 0,
"pitch_variance": 1,
"speed": 1,
"duration": 0,
"similarity": 3,
"text_guidance": 1,
"subharmonic_amplitude_control": 1
}
}
'import requests
url = "https://supertoneapi.com/v1/predict-duration/{voice_id}"
payload = {
"text": "<string>",
"style": "<string>",
"model": "sona_speech_1",
"output_format": "wav",
"voice_settings": {
"pitch_shift": 0,
"pitch_variance": 1,
"speed": 1,
"duration": 0,
"similarity": 3,
"text_guidance": 1,
"subharmonic_amplitude_control": 1
}
}
headers = {
"x-sup-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-sup-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
style: '<string>',
model: 'sona_speech_1',
output_format: 'wav',
voice_settings: {
pitch_shift: 0,
pitch_variance: 1,
speed: 1,
duration: 0,
similarity: 3,
text_guidance: 1,
subharmonic_amplitude_control: 1
}
})
};
fetch('https://supertoneapi.com/v1/predict-duration/{voice_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://supertoneapi.com/v1/predict-duration/{voice_id}"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"style\": \"<string>\",\n \"model\": \"sona_speech_1\",\n \"output_format\": \"wav\",\n \"voice_settings\": {\n \"pitch_shift\": 0,\n \"pitch_variance\": 1,\n \"speed\": 1,\n \"duration\": 0,\n \"similarity\": 3,\n \"text_guidance\": 1,\n \"subharmonic_amplitude_control\": 1\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-sup-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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://supertoneapi.com/v1/predict-duration/{voice_id}",
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' => '<string>',
'style' => '<string>',
'model' => 'sona_speech_1',
'output_format' => 'wav',
'voice_settings' => [
'pitch_shift' => 0,
'pitch_variance' => 1,
'speed' => 1,
'duration' => 0,
'similarity' => 3,
'text_guidance' => 1,
'subharmonic_amplitude_control' => 1
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-sup-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://supertoneapi.com/v1/predict-duration/{voice_id}")
.header("x-sup-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"style\": \"<string>\",\n \"model\": \"sona_speech_1\",\n \"output_format\": \"wav\",\n \"voice_settings\": {\n \"pitch_shift\": 0,\n \"pitch_variance\": 1,\n \"speed\": 1,\n \"duration\": 0,\n \"similarity\": 3,\n \"text_guidance\": 1,\n \"subharmonic_amplitude_control\": 1\n }\n}")
.asString();{
"duration": 123
}{
"status": "error",
"message": "Invalid request data"
}{
"status": "error",
"message": {
"message": "Invalid API Key",
"error": "Unauthorized"
}
}{
"status": "error",
"message": {
"message": "Not enough credits",
"error": "Payment Required"
}
}{
"status": "error",
"message": {
"message": "Permission denied",
"error": "Forbidden"
}
}{
"status": "error",
"message": {
"message": "Voice not found",
"error": "Not Found"
}
}{
"status": "error",
"message": {
"message": "Request timed out",
"error": "Request Timeout"
}
}{
"status": "error",
"message": {
"message": "rate limit exceeded",
"error": "Too Many Requests"
}
}{
"status": "error",
"message": {
"message": "Failed to convert text to speech",
"error": "Internal Server Error"
}
}이 문서는 영어 원문을 기반으로 자동 번역되었습니다. 표현이 어색하거나 모호한 부분이 있을 수 있으니, 정확한 내용은 영어 원문을 함께 확인해 주세요.
이 엔드포인트는 크레딧을 소비하지 않습니다. 동일한 300자 제한이 적용되며, 자동 청크 분할은 수행하지 않습니다.
엔드포인트
POST https://supertoneapi.com/v1/predict-duration/{voice_id}
경로 파라미터
| Name | Required | Description |
|---|---|---|
voice_id | ✅ | 대상 보이스의 ID입니다. |
요청 본문
Create speech와 동일한 구조입니다 —text, language, style, model, voice_settings — 단, 길이에 영향을 주지 않는 output_format, include_phonemes, normalized_text는 제외됩니다.
| Name | Required | Description |
|---|---|---|
text | ✅ | 분석할 텍스트입니다. 최대 300자. |
language | ✅ | 언어 코드입니다. 보이스와 모델이 모두 지원해야 합니다. |
style | — | 감정 스타일입니다. 기본값은 보이스의 첫 번째 스타일입니다. |
model | — | TTS 모델입니다. 기본값은 sona_speech_1. |
voice_settings | — | speed와 duration을 통해 길이에 영향을 미칩니다. 전체 표는 Create speech를 참고해 주십시오. |
요청 예시
POST /v1/predict-duration/20160a4c5ba38967330c84
x-sup-api-key: $SUPERTONE_API_KEY
Content-Type: application/json
{
"text": "This is a long-form sentence for duration prediction.",
"language": "en",
"style": "neutral"
}
응답
{
"duration": 3.57
}
참고사항
- 예측 시점과 실제
create_speech호출 시점에 동일한model과speed를 사용해 주십시오 — 두 값 모두 결과에 영향을 미칩니다. 서로 다른 속도로 예측하고 생성하면 길이가 일치하지 않습니다. - 크레딧은 차감되지 않습니다. UI 힌트나 예산 사전 점검 용도로 안전하게 사용할 수 있습니다.
함께 보기
Docs: Cost and usage
예측과 예산 책정에 predict_duration을 활용하는 방법입니다.
Create speech
추정치를 검증한 뒤 실제로 오디오를 생성합니다.
Authorizations
Path Parameters
Body
application/json
The text to convert to speech. Max length is 300 characters.
Maximum string length:
300Language code of the voice
Available options:
en, ko, ja, bg, cs, da, el, es, et, fi, hu, it, nl, pl, pt, ro, ar, de, fr, hi, id, ru, vi, hr, lt, lv, sk, sl, sv, tr, uk The style of character to use for the text-to-speech conversion
The model type to use for the text-to-speech conversion
Available options:
sona_speech_1, sona_speech_2, sona_speech_2_flash, supertonic_api_1, supertonic_api_3 The desired output format of the audio file (wav, mp3). Default is wav.
Available options:
wav, mp3 Show child attributes
Show child attributes
Response
Returns predicted duration of the audio in seconds