SiliconFlow
API手册

上传参考音频

上传用户提供的音色风格,支持 base64 编码或文件格式。

POST
/uploads/audio/voice
AuthorizationBearer <token>required

添加 Header 'Authorization: Bearer {账户 API Key}' 进行鉴权

In: header

Header Parameters

X-Trace-Idstring

请求追踪 ID。可自定义传入用于标记本次请求;若不传入,平台将自动生成。排查问题时,提供该值或响应头中的 x-siliconcloud-trace-id 均可。

traceparentstring

W3C Trace Context 标准追踪头。传入时,平台取其中的 trace-id 作为本次请求的追踪标识。

modelstringrequired

预定义音色风格模型名称

Example"FunAudioLLM/CosyVoice2-0.5B"
customNamestringrequired

用户自定义音色风格名称

Example"your-voice-name"
textstringrequired

音频对应的文本内容

Example"在一无所知中, 梦里的一天结束了,一个新的轮回便会开始"
audiostring

以 base64 编码的音频文件,头部格式为 data:audio/mpeg;base64

Example"data:audio/mpeg;base64,aGVsbG93b3JsZA=="
modelstringrequired

预定义音色风格模型名称

Example"FunAudioLLM/CosyVoice2-0.5B"
customNamestringrequired

用户自定义音色风格名称

Example"your-voice-name"
textstringrequired

音频对应的文本内容

Example"在一无所知中, 梦里的一天结束了,一个新的轮回便会开始"
filefile

要上传的文件

Formatbinary
Example"/path/to/audio.mp3"

Response Body

成功响应。响应头中包含 x-siliconcloud-trace-id 字段,作为请求的唯一追踪标识;用户自定义传入的 X-Trace-Id 请求头(如有)也会以该字段原样返回。排查问题时,提供任一 trace ID 即可。

TypeScript Definitions

Use the response body type in TypeScript.

uristring
Example"speech:your-voice-name:xxx:xxx"

curl -X POST "https://api.siliconflow.cn/v1/uploads/audio/voice" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@test.mp3" \
  -F "model=IndexTeam/IndexTTS-2" \
  -F "customName=your-voice-name" \
  -F "text=慢工出细活,再给我两分钟,你马上就能见识到超梦分析的厉害了"
import requests

url = "https://api.siliconflow.cn/v1/uploads/audio/voice"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}
files = {
    "file": open("test.mp3", "rb")
}
data = {
    "model": "IndexTeam/IndexTTS-2",
    "customName": "your-voice-name",
    "text": "慢工出细活,再给我两分钟,你马上就能见识到超梦分析的厉害了"
}

response = requests.post(url, headers=headers, files=files, data=data)
print(response.text)
{
  "uri": "speech:your-voice-name:xxx:xxx"
}
{
  "code": 20012,
  "message": "string",
  "data": "string"
}
"Invalid token"
"Forbidden"
"404 page not found"
{
  "message": "Request was rejected due to rate limiting. If you want more, please contact contact@siliconflow.cn. Details:TPM limit reached.",
  "data": "string"
}
{
  "code": 50505,
  "message": "Model service overloaded. Please try again later.",
  "data": "string"
}
"string"
上传参考音频