# GPT 转录 API:gpt-transcribe 与 gpt-4o-mini-transcribe 语音转文字 Source: https://ofox.ai/zh/docs/develop/models/gpt-transcribe OpenAI 的语音转录模型,通过 `POST /v1/audio/transcriptions` 上传音频,返回文字。 **模型 ID(调用时原样复制)** - GPT Transcribe: `openai/gpt-transcribe` — 按音频秒数计费 - GPT-4o mini Transcribe: `openai/gpt-4o-mini-transcribe` — 按 token 计费 接口的通用参数见 [Audio Transcriptions API](https://ofox.ai/zh/docs/api/openai/audio-transcriptions)。实时价格请参阅[模型页](https://ofox.ai/zh/models/openai/gpt-transcribe)。需要逐词时间戳或说话人分离时,请使用 [ElevenLabs Scribe v2](https://ofox.ai/zh/docs/develop/models/elevenlabs#scribe)。 ## 调用示例 **Python** ```python filename="gpt_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) print(result.usage) ``` **cURL** ```bash filename="Terminal" curl https://api.ofox.ai/v1/audio/transcriptions \ -H "Authorization: Bearer $OFOX_API_KEY" \ -F model=openai/gpt-transcribe \ -F language=zh \ -F prompt="以下是普通话的句子,请使用简体中文。" \ -F file=@meeting.mp3 ``` ## 参数与计费 **要点**:转录普通话时,请同时传入 language 与 prompt,指定使用简体中文,否则可能输出繁体字。 | 项目 | 说明 | |---|---| | `language` 与 `prompt` | 实测 `gpt-transcribe` 只传 `language: "zh"` 时,4 次中仍有 1 次输出繁体;同时传入 `prompt: "以下是普通话的句子,请使用简体中文。"` 后,4 次均为简体 | | `response_format` | 仅支持 `json`(默认)。`verbose_json`、`text`、`srt`、`vtt` 均返回 400 | | 返回内容 | `text` 与 `usage`,不含逐词时间戳 | | 计费 | `gpt-transcribe` 按音频秒数,`usage` 为 `{"type": "duration", "seconds": ...}`;`gpt-4o-mini-transcribe` 按 token,`usage` 中含 `input_tokens`、`output_tokens` | 实测约 9 秒的中文对话,转录约 2 至 3 秒返回。 ## 常见报错 | HTTP | 报错原文 | 原因 | 处理方法 | |---|---|---|---| | 400 | `response_format 'verbose_json' is not compatible with model 'gpt-transcribe'.` | GPT 转录模型不支持 `verbose_json` | 改用 `json` | | 400 | `Unsupported response_format 'srt'. Only 'json' and 'verbose_json' are supported on this gateway` | 使用了 `text`、`srt`、`vtt` | 改用 `json` | | 400 | `Unsupported file format txt` | 上传的不是音频文件 | 上传 `mp3`、`wav` 等音频 | 更多报错见 [Audio Transcriptions API](https://ofox.ai/zh/docs/api/openai/audio-transcriptions#errors)。 ## 官方文档 - [OpenAI · 语音转文字](https://platform.openai.com/docs/guides/speech-to-text) ## 常见问题 **GPT 转录中文输出了繁体字?** 同时传入 language: "zh" 与 prompt: "以下是普通话的句子,请使用简体中文。"。实测只传 language 时仍偶尔输出繁体,加上 prompt 后稳定输出简体。 **GPT 转录能输出 srt 字幕吗?** 不能,仅支持 json。需要时间戳生成字幕时,请使用 ElevenLabs Scribe v2,它返回逐词的起止时间。 **gpt-transcribe 和 gpt-4o-mini-transcribe 怎么计费?** gpt-transcribe 按音频秒数计费;gpt-4o-mini-transcribe 按 token 计费,用量见响应的 usage。单价见模型页。