跳转到主要内容
POST
/
v1
/
audio
/
transcriptions
语音转文字
curl --request POST \
  --url https://openp.ai/v1/audio/transcriptions
import requests

url = "https://openp.ai/v1/audio/transcriptions"

response = requests.post(url)

print(response.text)
const options = {method: 'POST'};

fetch('https://openp.ai/v1/audio/transcriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://openp.ai/v1/audio/transcriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://openp.ai/v1/audio/transcriptions"

req, _ := http.NewRequest("POST", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://openp.ai/v1/audio/transcriptions")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openp.ai/v1/audio/transcriptions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
把音频文件转写为文字。

请求

curl https://openp.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -F [email protected] \
  -F model=whisper-1 \
  -F language=zh \
  -F response_format=verbose_json

参数

字段类型必填说明
filefile音频文件,支持 mp3 / mp4 / mpeg / mpga / m4a / wav / webm,最大 25MB
modelstringwhisper-1 / gpt-4o-transcribe / gpt-4o-mini-transcribe
languagestringISO-639-1 语言代码,如 zh / en / ja,留空自动识别
promptstring引导词,提示模型领域 / 专有名词 / 拼写
response_formatstringjson(默认) / text / srt / verbose_json / vtt
temperaturenumber0-1
timestamp_granularities[]arrayword / segment,需 verbose_json

响应

response_format: "json":
{"text": "你好,这是一段测试音频。"}
response_format: "verbose_json":
{
  "task": "transcribe",
  "language": "zh",
  "duration": 4.2,
  "text": "你好,这是一段测试音频。",
  "segments": [
    {
      "id": 0,
      "start": 0.0,
      "end": 4.2,
      "text": "你好,这是一段测试音频。"
    }
  ]
}
srt / vtt 返回字幕文本(可直接保存为 .srt / .vtt)。

Python

from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://openp.ai/v1")

with open("audio.mp3", "rb") as f:
    resp = client.audio.transcriptions.create(
        model="whisper-1",
        file=f,
        response_format="verbose_json",
        timestamp_granularities=["segment"],
    )
print(resp.text)

长音频策略

  • Whisper 单文件 25MB 上限,长音频请提前 切片(推荐 5-10 分钟一段)。
  • 使用 prompt 传入上一段尾部文本以保持语境连贯。
  • 工具如 ffmpeg -i input.mp3 -f segment -segment_time 600 part_%03d.mp3 可快速切片。

计费

音频时长(秒) 计费,具体倍率以控制台为准。