Skip to main content
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>",
  "language": "en",
  "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
  }
}'
{
  "duration": 123
}
このAPIは音声を実際に生成せず、入力されたテキストを基に予想音声長(秒単位)のみを返します。
TTS呼び出し前に予想クレジット消費量を把握したり、テキスト長を調節する際に有用です。

エンドポイント

https://supertoneapi.com/v1/predict-duration/{voice_id}

リクエストパラメータ

ItemRequiredDescription
textYes解析するテキストです。最大 300 文字です。
languageYesテキストの言語です。koenja のいずれかです。
styleNo感情スタイルです。未指定の場合はデフォルトスタイルが使用されます。
modelNoデフォルトは sona_speech_1 です。現在はこのモデルのみ利用可能です。
voice_settingsNo発話速度やピッチの調整値です。結果の長さに影響する場合があります。

使用方式

  • 呼び出し方法と Request Body は text-to-speech API とほぼ同一です。
  • ただしオーディオは返されず、結果として duration のみが返ります。
  • Predict Duration API の呼び出しでは クレジットは消費されません。
  • 実際のクレジットは減りません。(音声生成が行われないため)
  • 同一テキストで実際に呼び出した場合と非常に近い結果を得られます。
  • voice_settings.speed を調整すると長さが変わるため、一定の発話速度でテストすることをおすすめします。

Authorizations

x-sup-api-key
string
header
required

Path Parameters

voice_id
string
required

Body

application/json
text
string
required

The text to convert to speech. Max length is 300 characters.

Maximum length: 300
language
enum<string>
required

Language code of the voice

Available options:
en,
ko,
ja
style
string

The style of character to use for the text-to-speech conversion

model
string
default:sona_speech_1

The model type to use for the text-to-speech conversion

output_format
enum<string>
default:wav

The desired output format of the audio file (wav, mp3). Default is wav.

Available options:
wav,
mp3
voice_settings
object

Response

Returns predicted duration of the audio in seconds

duration
number
I