Audio Transcriptions API
將音訊轉為文字。相容 OpenAI 的 POST /v1/audio/transcriptions,以 multipart/form-data 上傳音訊檔案。
快速開始
base_url
https://api.ofox.ai/v1介面網址
https://api.ofox.ai/v1/audio/transcriptions模型 ID
openai/gpt-transcribePython
transcribe.py
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.ofox.ai/v1", api_key=os.environ["OFOX_API_KEY"])
with open("meeting.mp3", "rb") as f:
result = client.audio.transcriptions.create(
model="openai/gpt-transcribe",
file=f,
language="zh",
prompt="以下是普通话的句子,请使用简体中文。",
)
print(result.text)請求參數
音訊檔案,如 mp3、wav。非音訊檔案會回傳 400。
模型 ID,見上表。
languagestring
音訊的語言,如 zh、en。不傳時自動辨識。
promptstring
提示文字,用於指定用字習慣或專有名詞,適用於 GPT 轉錄模型。轉錄普通話時,建議同時傳入 language: "zh" 與「以下是普通话的句子,请使用简体中文。」,否則可能輸出繁體字。
僅支援 json 與 verbose_json;text、srt、vtt 會回傳 400。verbose_json 僅適用於 ElevenLabs Scribe。
provider_optionsstring
供應商專屬參數,以 JSON 字串作為表單欄位傳入,例如 {"elevenlabs": {"diarize": true}}。見各系列頁。
回應
{
"text": "今天天气很好,我们下午三点在会议室讨论新功能。",
"usage": { "type": "duration", "seconds": 9 }
}textstring
轉錄文字。
usageobject
計費依據。type 為 duration 時依音訊秒數計費(seconds);為 tokens 時依 token 計費(input_tokens、output_tokens)。
ElevenLabs Scribe 另外回傳 words(逐字文字與起訖時間)、language、duration 等欄位,見 ElevenLabs。需要字幕檔時,可依 words 中的時間戳記自行產生。
常見錯誤
完整的錯誤碼說明見錯誤處理。
最後更新於