SiliconFlow
API手册

创建语音转文本请求

创建音频转录。

POST
/audio/transcriptions
AuthorizationBearer <token>required

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

In: header

filefilerequired

要转录的音频文件对象(不是文件名)。 文件上传规格限制为:时长不超过 1 小时,文件大小不超过 50MB

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

对应的模型名称。为更好地提升服务质量,我们会对本服务提供的模型进行定期变更,包括但不限于模型上下线和模型服务能力的调整。在可行的情况下,我们会通过公告或消息推送等适当方式通知您此类变更。

Value in"FunAudioLLM/SenseVoiceSmall" | "TeleAI/TeleSpeechASR"
Example"FunAudioLLM/SenseVoiceSmall"

Response Body

模型响应。响应头中包含 x-siliconcloud-trace-id 字段,作为请求的唯一追踪标识,便于日志查询和问题排查。

TypeScript Definitions

Use the response body type in TypeScript.

textstringrequired

音频转录后的文本内容。

curl --request POST \
  --url https://api.siliconflow.cn/v1/audio/transcriptions \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -F "file=@path/to/your/audio.mp3" \
  -F "model=FunAudioLLM/SenseVoiceSmall"
import requests
url = "https://api.siliconflow.cn/v1/audio/transcriptions"
file_path = "path/to/your/audio.mp3"
headers = {
    "Authorization": "Bearer <YOUR_API_KEY>"
}
with open(file_path, "rb") as audio_file:
    files = {
        "file": ("audio.mp3", audio_file),  # 根据文件类型调整 MIME 类型
        "model": (None, "FunAudioLLM/SenseVoiceSmall")
    }
    response = requests.post(url, headers=headers, files=files)
fetch('https://api.siliconflow.cn/v1/audio/transcriptions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <YOUR_API_KEY>'
  },
  body: JSON.stringify({
    model: 'FunAudioLLM/SenseVoiceSmall',
    file: 'path/to/your/audio.mp3'
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
{
  "text": "string"
}
{
  "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"