POST
/
v1
/
predict-duration
/
{voice_id}
curl --request POST \
  --url https://supertoneapi.com/v1/predict-duration/{voice_id} \
  --header 'Content-Type: application/json' \
  --header 'x-sup-api-key: <x-sup-api-key>' \
  --data '{
  "text": "<string>",
  "language": "en",
  "style": "<string>",
  "model": "sona_speech_1",
  "voice_settings": {
    "pitch_shift": 0,
    "pitch_variance": 1,
    "speed": 1
  }
}'
{
  "duration": 123
}

このAPIは音声を実際に生成せず
入力されたテキストを基に予想音声長(秒単位)のみを返します。 TTS呼び出し前に予想クレジット消費量を把握したり、テキスト長を調節する際に有用です。

使用方式

  • 呼び出し方式とRequest Bodyはtext-to-speech APIとほぼ同じです。
  • ただし、結果としてオーディオではなくduration値のみが返されます。
  • Predict Duration API呼び出し時にはクレジットが消費されません。

Request Body項目説明

項目必須説明
text分析対象テキスト。最大300文字
languageテキスト言語。koenjaのうち一つ
style感情スタイル。指定しない場合はdefaultスタイルが使用されます
modelデフォルト値はsona_speech_1。現在は該当モデルのみ使用可能
voice_settings発話速度やピッチ調節値。結果長に影響を与える可能性があります

使用例

POST /v1/predict-duration/{voice_id}
Content-Type: application/json
x-sup-api-key: [YOUR_API_KEY]

{
  "text": "This is a long-form sentence for duration prediction.",
  "language": "en",
  "style": "neutral"
}

レスポンス例

{
  "duration": 3.57381983
}

該当テキストを生成すると約3.57秒分のオーディオが作られるという意味です。

活用のコツ

  • クレジットは実際に差し引かれません。(音声生成が行われないため)
  • 同じテキストを実際に呼び出す時とほぼ類似した結果を得ることができます。
  • voice_settings.speedを調節すると長さが変わるため、固定された発話速度でテストすることをお勧めします。

Headers

x-sup-api-key
string
required

API key for the service

Path Parameters

voice_id
string
required

Body

application/json

Response

200
application/json

Returns predicted duration of the audio in seconds

The response is of type object.