SiliconFlow
API REFERENCE

Upload a Voice

Upload user-provided voice style, which can be in base64 encoding or file format.

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

Set the header 'Authorization: Bearer {your API key}' for authentication

In: header

modelstringrequired

Predefined voice style model name

Example"FunAudioLLM/CosyVoice2-0.5B"
customNamestringrequired

User-defined voice style name

Example"your-voice-name"
textstringrequired

Corresponding text content for the audio

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

Audio file encoded in base64 with the header format of data:audio/mpeg;base64

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

Predefined voice style model name

Example"FunAudioLLM/CosyVoice2-0.5B"
customNamestringrequired

User-defined voice style name

Example"your-voice-name"
textstringrequired

Corresponding text content for the audio

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

File to upload

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

Response Body

Successful response

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"
Upload a Voice