SiliconFlow

创建语音转文本请求

Creates an audio transcription.

POST
/audio/transcriptions
AuthorizationBearer <token>required

Use the following format for authentication: Bearer

In: header

filefilerequired

The audio file object (not file name) to transcribe. File upload specifications are limited to:duration not exceeding 1 hour, and file size not exceeding 50MB.

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

Corresponding Model Name. To better enhance service quality, we will make periodic changes to the models provided by this service, including but not limited to model on/offlining and adjustments to model service capabilities. We will notify you of such changes through appropriate means such as announcements or message pushes where feasible.

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

Response Body

const body = new FormData();
body.set(file, "/path/to/file/audio.mp3")
body.set(model, "FunAudioLLM/SenseVoiceSmall")

fetch("https://api.siliconflow.cn/v1/audio/transcriptions", {
  body
})
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
  "mime/multipart"
  "bytes"
)

func main() {
  url := "https://api.siliconflow.cn/v1/audio/transcriptions"
  body := new(bytes.Buffer)
  mp := multipart.NewWriter(payload)
  mp.WriteField("file", `/path/to/file/audio.mp3`)
  mp.WriteField("model", `FunAudioLLM/SenseVoiceSmall`)
  req, _ := http.NewRequest("POST", url, body)
  req.Header.Add("Content-Type", "multipart/form-data")
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.net.http.HttpRequest.BodyPublishers;

var body = BodyPublishers.ofByteArray(new byte[] { ... });
HttpClient client = HttpClient.newBuilder()
  .connectTimeout(Duration.ofSeconds(10))
  .build();

HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
  .uri(URI.create("https://api.siliconflow.cn/v1/audio/transcriptions"))
  .header("Content-Type", "multipart/form-data")
  .POST(body)
  .build();

try {
  HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());
  System.out.println("Status code: " + response.statusCode());
  System.out.println("Response body: " + response.body());
} catch (Exception e) {
  e.printStackTrace();
}
using System;
using System.Net.Http;
using System.Text;

var body = new MultipartFormDataContent();

var client = new HttpClient();
var response = await client.PostAsync("https://api.siliconflow.cn/v1/audio/transcriptions", body);
var responseBody = await response.Content.ReadAsStringAsync();
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"