Fish Audio Text-to-Speech
提交同步Text to Speech请求,并在同一响应中接收结果。
概览
提交Text to Speech请求,并直接使用同一响应返回的结果。
快速开始
- 创建 API Key,并将其设置为 RUNAPI_API_KEY。
- 发送与请求 Schema 匹配的 POST 请求。
- 从成功响应正文中读取结果。
端点
- 基础 URL
https://runapi.ai- API 版本
v1- 身份验证
Authorization: Bearer YOUR_API_TOKEN
支持的模型
打开模型页可查看当前价格、限流和商业使用详情。
请求 Schema
只发送此端点声明的字段。
s19 个字段
bitrate_kbpsintegerMP3 bitrate. Not accepted for WAV output.
可选值:64, 128, 192
默认值: 128
modelstringModel slug.
output_formatstringOutput audio format.
可选值:mp3, wav
默认值: mp3
referencesarrayInline reference audio samples for this request.
references[].audiostringBase64-encoded raw audio bytes.
references[].textstringExact transcript of the reference audio.
sample_rate_hzintegerOutput sample rate. MP3 supports 32000 and 44100 Hz; WAV supports every listed value.
可选值:8000, 16000, 24000, 32000, 44100
默认值: 44100
textstringvoice_idstrings2-pro9 个字段
bitrate_kbpsintegerMP3 bitrate. Not accepted for WAV output.
可选值:64, 128, 192
默认值: 128
modelstringModel slug.
output_formatstringOutput audio format.
可选值:mp3, wav
默认值: mp3
referencesarrayInline reference audio samples for this request.
references[].audiostringBase64-encoded raw audio bytes.
references[].textstringExact transcript of the reference audio.
sample_rate_hzintegerOutput sample rate. MP3 supports 32000 and 44100 Hz; WAV supports every listed value.
可选值:8000, 16000, 24000, 32000, 44100
默认值: 44100
textstringvoice_idstrings2.1-pro9 个字段
bitrate_kbpsintegerMP3 bitrate. Not accepted for WAV output.
可选值:64, 128, 192
默认值: 128
modelstringModel slug.
output_formatstringOutput audio format.
可选值:mp3, wav
默认值: mp3
referencesarrayInline reference audio samples for this request.
references[].audiostringBase64-encoded raw audio bytes.
references[].textstringExact transcript of the reference audio.
sample_rate_hzintegerOutput sample rate. MP3 supports 32000 and 44100 Hz; WAV supports every listed value.
可选值: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
响应 Schema
{
"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
响应 Schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
{
"error": "Authentication required"
}
错误
POST /api/v1/fish_audio/text_to_speech
响应 Schema
{
"oneOf": [
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "Human-readable validation summary.",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
"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
响应 Schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
{
"error": "Insufficient balance"
}
错误
POST /api/v1/fish_audio/text_to_speech
响应 Schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
{
"error": "API key credit limit exceeded"
}
错误
POST /api/v1/fish_audio/text_to_speech
响应 Schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"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
响应 Schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
{
"error": "Rate limit reached. Please retry later."
}
错误
POST /api/v1/fish_audio/text_to_speech
响应 Schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
{
"error": "Service under maintenance, please try again later"
}
错误
POST /api/v1/fish_audio/text_to_speech
响应 Schema
{
"properties": {
"error": {
"description": "Human-readable error message.",
"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."
)