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 です。 |
リクエストボディ
音声生成 と同じ形式で、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 を通じて長さに影響します。全項目は 音声生成 のテーブルをご参照ください。 |
リクエスト例
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
⌘I