Fish Audio テキスト読み上げ
テキストから音声へのエンドポイントを使用して、同じレスポンスで結果を受け取ります。
概要
テキストから音声へのエンドポイントを使用し、同じレスポンスから結果を読み取ります。
クイックスタート
- APIキーを作成し、RUNAPI_API_KEYとして設定します。
- 本文がリクエストスキーマと一致するPOSTリクエストを送信します。
- 成功レスポンスのボディから結果を読み取る。
エンドポイント
- ベースURL
https://runapi.ai- API バージョン
v1- 認証
Authorization: Bearer YOUR_API_TOKEN
サポートされているモデル
現在の料金、レート制限、商用利用の詳細については、モデルページを開いてください。
リクエストスキーマ
このエンドポイントで宣言されたフィールドのみを送信してください。
s1フィールド9件
bitrate_kbpsintegerMP3ビットレート。WAV出力では使用できません。
許可される値:64, 128, 192
デフォルト: 128
modelstringモデルスラッグ。
output_formatstring出力オーディオフォーマット。
許可される値:mp3, wav
デフォルト: mp3
referencesarrayこのリクエスト用のインライン参照音声サンプル。
references[].audiostringBase64エンコードされた生のオーディオバイト。
references[].textstring参照オーディオの正確なトランスクリプト。
sample_rate_hzinteger出力サンプルレート。MP3 は 32000 Hz および 44100 Hz をサポート。WAV はリストされた全値をサポート。
許可される値:8000, 16000, 24000, 32000, 44100
デフォルト: 44100
textstringvoice_idstrings2-proフィールド9件
bitrate_kbpsintegerMP3ビットレート。WAV出力では使用できません。
許可される値:64, 128, 192
デフォルト: 128
modelstringモデルスラッグ。
output_formatstring出力オーディオフォーマット。
許可される値:mp3, wav
デフォルト: mp3
referencesarrayこのリクエスト用のインライン参照音声サンプル。
references[].audiostringBase64エンコードされた生のオーディオバイト。
references[].textstring参照オーディオの正確なトランスクリプト。
sample_rate_hzinteger出力サンプルレート。MP3 は 32000 Hz および 44100 Hz をサポート。WAV はリストされた全値をサポート。
許可される値:8000, 16000, 24000, 32000, 44100
デフォルト: 44100
textstringvoice_idstrings2.1-proフィールド9件
bitrate_kbpsintegerMP3ビットレート。WAV出力では使用できません。
許可される値:64, 128, 192
デフォルト: 128
modelstringモデルスラッグ。
output_formatstring出力オーディオフォーマット。
許可される値:mp3, wav
デフォルト: mp3
referencesarrayこのリクエスト用のインライン参照音声サンプル。
references[].audiostringBase64エンコードされた生のオーディオバイト。
references[].textstring参照オーディオの正確なトランスクリプト。
sample_rate_hzinteger出力サンプルレート。MP3 は 32000 Hz および 44100 Hz をサポート。WAV はリストされた全値をサポート。
許可される値:8000, 16000, 24000, 32000, 44100
デフォルト: 44100
textstringvoice_idstring条件付きルール
これらの要件は、列挙されたすべての条件が一致する場合に適用されます。
-
条件
output_format = wav- 必須
- 使用不可
bitrate_kbps
-
条件
output_format = mp3- 必須
- 使用不可
-
条件
output_format = {"present" => false}- 必須
- 使用不可
成功レスポンス
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"audios": {
"items": {
"properties": {
"format": {
"type": "string"
},
"mime_type": {
"type": "string"
},
"size_bytes": {
"type": "integer"
},
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url",
"format",
"mime_type",
"size_bytes"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
},
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"id": {
"type": "string"
},
"status": {
"enum": [
"completed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"audios",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"audios": [
{
"format": "mp3",
"mime_type": "audio/mpeg",
"size_bytes": 128,
"url": "https://file.runapi.ai/reference-audio.mp3"
}
],
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "completed"
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"error": "Authentication required"
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"oneOf": [
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "人間が読める形式のバリデーションサマリー。",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "公開リクエストフィールドをキーとするバリデーションメッセージ。各フィールドに対して人間が読める文字列の配列が含まれます。",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
レスポンス例
{
"error": "model must be one of: s1, s2-pro, s2.1-pro"
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"error": "Insufficient balance"
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"error": "API key credit limit exceeded"
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"error": "The request uses features that are not supported for the selected model"
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"error": "Rate limit reached. Please retry later."
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"error": "Service under maintenance, please try again later"
}
エラー
POST /api/v1/fish_audio/text_to_speech
レスポンススキーマ
{
"properties": {
"error": {
"description": "人が読めるエラーメッセージ。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
レスポンス例
{
"error": "The request timed out"
}
生成されたコードサンプル
cURLを直接使用するか、お使いの言語向けのSDKをインストールしてください。各サンプルは、このリファレンスに示されたバリデーション済みリクエストを送信します。
インストール
pip install runapi-fish-audio
import os
from runapi.fish_audio import FishAudioClient
client = FishAudioClient(api_key=os.environ["RUNAPI_API_KEY"])
result = client.text_to_speech.run(
model="s1",
text="Welcome to RunAPI."
)