OpenAI 创建音频转录接口
创建音频转录
post /audio/transcriptions
将音频转录为其原始语言的文本。
返回 json、diarized_json 或 verbose_json 格式的转录对象,
或 text、srt、vtt 格式的纯文本,也可返回
转录事件流。支持的格式取决于模型。
请求体参数
内容类型为 multipart/form-data。
file: string
待转录的音频文件对象,须提供文件内容。支持 flac、mp3、mp4、mpeg、mpga、m4a、ogg、wav 或 webm。 请求须提供足够的格式元数据以识别文件,建议使用带扩展名的文件名和合适的内容类型。
model: string or AudioModel
要使用的模型 ID,可选 gpt-transcribe、gpt-4o-transcribe、gpt-4o-mini-transcribe、gpt-4o-mini-transcribe-2025-12-15、基于开源 Whisper V2 的 whisper-1,以及 gpt-4o-transcribe-diarize。
string
AudioModel = "whisper-1" or "gpt-transcribe" or "gpt-4o-transcribe" or 3 more
"whisper-1"
"gpt-transcribe"
"gpt-4o-transcribe"
"gpt-4o-mini-transcribe"
"gpt-4o-mini-transcribe-2025-12-15"
"gpt-4o-transcribe-diarize"
chunking_strategy: optional "auto" or VadConfig { type, prefix_padding_ms, silence_duration_ms, threshold } or null
控制音频分块方式。设为 "auto" 时,服务器先归一化响度,再用语音活动检测(VAD)确定边界。可提供 server_vad 对象手动调整 VAD 参数。未设置时,将整段音频作为单个块转录。使用 gpt-4o-transcribe-diarize 处理超过 30 秒的输入时,此项为必填。
"auto"
根据音频自动设置分块参数,值必须为 "auto"。
"auto"
VadConfig object { type, prefix_padding_ms, silence_duration_ms, threshold }
type: "server_vad"
须设为 server_vad 才能通过服务端 VAD 手动配置分块。
"server_vad"
prefix_padding_ms: optional integer (default: 300)
在 VAD 检测到语音之前一并保留的音频时长,单位为 毫秒。
silence_duration_ms: optional integer (default: 200)
用于判断语音结束的静音时长,单位为毫秒。 较短的时长能使模型更快响应, 但可能在用户短暂停顿时提前插入响应。
threshold: optional number (default: 0.5)
语音活动检测的敏感度阈值,范围为 0.0–1.0。 较高阈值要求更大的音量才能激活模型, 因此可能更适合嘈杂环境。
include: optional array of TranscriptionInclude
转录响应中需要包含的额外信息。
logprobs 会返回响应中各词元的对数概率,
以便了解模型对转录结果的置信程度。
logprobs 仅在 response_format 设为 json 时有效,且仅支持
gpt-4o-transcribe、gpt-4o-mini-transcribe 和 gpt-4o-mini-transcribe-2025-12-15。使用 gpt-4o-transcribe-diarize 时不支持此字段。
"logprobs"
keywords: optional array of string
用于引导输入音频转录的词语或短语,gpt-transcribe 支持。
known_speaker_names: optional array of string
可选的说话人名称列表,与 known_speaker_references[] 中的音频样本对应。每项应为简短标识,例如 customer 或 agent。最多支持 4 位说话人。
maxItems: 4
known_speaker_references: optional array of string
可选的已知说话人音频样本列表,采用 data URL 形式,与 known_speaker_names[] 对应。每个样本须为 2–10 秒,可使用 file 支持的任一输入音频格式。
maxItems: 4
language: optional string
输入音频的语言。以 ISO-639-1 格式(例如 en)提供语言,有助于改善准确率和延迟。
languages: optional array of string
输入音频可能使用的语言,采用 ISO-639-1 格式。gpt-transcribe 支持。
minItems: 1
prompt: optional string
可选文本,用于引导模型的表达风格或续接此前音频片段。提示词应与音频语言一致。使用 gpt-4o-transcribe-diarize 时不支持此字段。
response_format: optional AudioResponseFormat (default: "json")
输出格式,可选 json、text、srt、verbose_json、vtt 或 diarized_json。gpt-4o-transcribe 和 gpt-4o-mini-transcribe 仅支持 json。gpt-4o-transcribe-diarize 支持 json、text 和 diarized_json;如需说话人标注,须使用 diarized_json。
"json"
"text"
"srt"
"verbose_json"
"vtt"
"diarized_json"
stream: optional boolean or null (default: false)
设为 true 时,模型响应数据会在生成过程中通过 服务器发送事件(SSE)流式发送给客户端。 更多信息请参阅语音转文字指南的流式传输章节 中的说明。
注意:whisper-1 不支持流式传输,将忽略此参数。
temperature: optional number (default: 0)
采样温度,范围为 0–1。较高值(如 0.8)使输出更随机,较低值(如 0.2)使输出更集中、更确定。设为 0 时,模型根据对数概率自动提高温度,直到满足相应阈值。
timestamp_granularities: optional array of "word" or "segment" (default: ["segment"])
此次转录所需的时间戳粒度。使用时须将 response_format 设为 verbose_json。可选择 word、segment,也可同时选择。分段时间戳不会增加额外延迟,逐词时间戳会增加延迟。
gpt-4o-transcribe-diarize 不支持此选项。
"word"
"segment"
返回值
Transcription object { text, languages, logprobs, usage }
表示模型根据输入返回的转录响应。
text: string
转录文本。
languages: optional array of TranscriptionLanguage
音频中检测到的语言,由 gpt-transcribe 返回。空数组表示未能可靠识别语言。
code: string
音频中检测到的语言代码。
logprobs: optional array of object { token, bytes, logprob }
转录词元的对数概率。仅在将 logprobs 加入 include 数组并使用 gpt-4o-transcribe 或 gpt-4o-mini-transcribe 时返回。
token: optional string
转录中的词元。
bytes: optional array of number
词元的字节。
logprob: optional number
词元的对数概率。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
TranscriptionDiarized object { duration, segments, task, 2 more }
表示模型返回的说话人分离转录响应,包含合并文本及带有说话人标注的分段。
duration: number
输入音频时长,单位为秒。
format: double
segments: array of TranscriptionDiarizedSegment
带时间戳和说话人标签的转录分段。
id: string
分段的唯一标识。
end: number
分段结束时间戳,单位为秒。
format: double
speaker: string
分段的说话人标签。提供已知说话人时,标签与 known_speaker_names[] 对应;否则按顺序使用大写字母标记,例如 A、B 等。
start: number
分段开始时间戳,单位为秒。
format: double
text: string
此分段的转录文本。
type: "transcript.text.segment"
分段类型,固定为 transcript.text.segment。
"transcript.text.segment"
task: "transcribe"
执行的任务类型,固定为 transcribe。
"transcribe"
text: string
整段输入音频的拼接转录文本。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元或时长用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
TranscriptionVerbose object { duration, language, text, 3 more }
表示模型根据输入返回的详细 JSON 转录响应。
duration: number
输入音频的时长。
format: double
language: string
输入音频的语言。
text: string
转录文本。
segments: optional array of TranscriptionSegment
转录文本的分段及其详情。
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
usage: optional object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
words: optional array of TranscriptionWord
提取出的词语及相应时间戳。
end: number
词语结束时间,单位为秒。
format: double
start: number
词语开始时间,单位为秒。
format: double
word: string
词语的文本内容。
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F 'file=@/path/to/file' \
-F model=gpt-4o-transcribe
200 响应示例
{
"text": "text",
"languages": [
{
"code": "code"
}
],
"logprobs": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0
}
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"type": "tokens",
"input_token_details": {
"audio_tokens": 0,
"text_tokens": 0
}
}
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F model="gpt-4o-transcribe"
响应示例
{
"text": "Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that.",
"usage": {
"type": "tokens",
"input_tokens": 14,
"input_token_details": {
"text_tokens": 0,
"audio_tokens": 14
},
"output_tokens": 45,
"total_tokens": 59
}
}
说话人分离示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/meeting.wav" \
-F model="gpt-4o-transcribe-diarize" \
-F response_format="diarized_json" \
-F chunking_strategy=auto \
-F 'known_speaker_names[]=agent' \
-F 'known_speaker_references[]=data:audio/wav;base64,AAA...'
响应示例
{
"task": "transcribe",
"duration": 27.4,
"text": "Agent: Thanks for calling OpenAI support.\nA: Hi, I'm trying to enable diarization.\nAgent: Happy to walk you through the steps.",
"segments": [
{
"type": "transcript.text.segment",
"id": "seg_001",
"start": 0.0,
"end": 4.7,
"text": "Thanks for calling OpenAI support.",
"speaker": "agent"
},
{
"type": "transcript.text.segment",
"id": "seg_002",
"start": 4.7,
"end": 11.8,
"text": "Hi, I'm trying to enable diarization.",
"speaker": "A"
},
{
"type": "transcript.text.segment",
"id": "seg_003",
"start": 12.1,
"end": 18.5,
"text": "Happy to walk you through the steps.",
"speaker": "agent"
}
],
"usage": {
"type": "duration",
"seconds": 27
}
}
对数概率示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "include[]=logprobs" \
-F model="gpt-4o-transcribe" \
-F response_format="json"
响应示例
{
"text": "Hey, my knee is hurting and I want to see the doctor tomorrow ideally.",
"logprobs": [
{ "token": "Hey", "logprob": -1.0415299, "bytes": [72, 101, 121] },
{ "token": ",", "logprob": -9.805982e-5, "bytes": [44] },
{ "token": " my", "logprob": -0.00229799, "bytes": [32, 109, 121] },
{
"token": " knee",
"logprob": -4.7159858e-5,
"bytes": [32, 107, 110, 101, 101]
},
{ "token": " is", "logprob": -0.043909557, "bytes": [32, 105, 115] },
{
"token": " hurting",
"logprob": -1.1041146e-5,
"bytes": [32, 104, 117, 114, 116, 105, 110, 103]
},
{ "token": " and", "logprob": -0.011076359, "bytes": [32, 97, 110, 100] },
{ "token": " I", "logprob": -5.3193703e-6, "bytes": [32, 73] },
{
"token": " want",
"logprob": -0.0017156356,
"bytes": [32, 119, 97, 110, 116]
},
{ "token": " to", "logprob": -7.89631e-7, "bytes": [32, 116, 111] },
{ "token": " see", "logprob": -5.5122365e-7, "bytes": [32, 115, 101, 101] },
{ "token": " the", "logprob": -0.0040786397, "bytes": [32, 116, 104, 101] },
{
"token": " doctor",
"logprob": -2.3392786e-6,
"bytes": [32, 100, 111, 99, 116, 111, 114]
},
{
"token": " tomorrow",
"logprob": -7.89631e-7,
"bytes": [32, 116, 111, 109, 111, 114, 114, 111, 119]
},
{
"token": " ideally",
"logprob": -0.5800861,
"bytes": [32, 105, 100, 101, 97, 108, 108, 121]
},
{ "token": ".", "logprob": -0.00011093382, "bytes": [46] }
],
"usage": {
"type": "tokens",
"input_tokens": 14,
"input_token_details": {
"text_tokens": 0,
"audio_tokens": 14
},
"output_tokens": 45,
"total_tokens": 59
}
}
分段时间戳示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "timestamp_granularities[]=segment" \
-F model="whisper-1" \
-F response_format="verbose_json"
响应示例
{
"task": "transcribe",
"language": "english",
"duration": 3.32,
"text": "The beach was a popular spot on a hot summer day.",
"segments": [
{
"id": 0,
"seek": 0,
"start": 0.0,
"end": 3.319999933242798,
"text": " The beach was a popular spot on a hot summer day.",
"tokens": [
50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530
],
"temperature": 0.0,
"avg_logprob": -0.2860786020755768,
"compression_ratio": 1.2363636493682861,
"no_speech_prob": 0.00985979475080967
}
],
"usage": {
"type": "duration",
"seconds": 4
}
}
流式传输示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F model="gpt-4o-mini-transcribe" \
-F stream=true
响应示例
data: {"type":"transcript.text.delta","delta":"I","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]}]}
data: {"type":"transcript.text.delta","delta":" see","logprobs":[{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]}]}
data: {"type":"transcript.text.delta","delta":" skies","logprobs":[{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]}]}
data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]}]}
data: {"type":"transcript.text.delta","delta":" blue","logprobs":[{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]}]}
data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]}]}
data: {"type":"transcript.text.delta","delta":" clouds","logprobs":[{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]}]}
data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]}]}
data: {"type":"transcript.text.delta","delta":" white","logprobs":[{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0014890312,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]}]}
data: {"type":"transcript.text.delta","delta":" bright","logprobs":[{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]}]}
data: {"type":"transcript.text.delta","delta":" blessed","logprobs":[{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]}]}
data: {"type":"transcript.text.delta","delta":" days","logprobs":[{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.00001700133,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]}]}
data: {"type":"transcript.text.delta","delta":" dark","logprobs":[{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]}]}
data: {"type":"transcript.text.delta","delta":" sacred","logprobs":[{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]}]}
data: {"type":"transcript.text.delta","delta":" nights","logprobs":[{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0036910512,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]}]}
data: {"type":"transcript.text.delta","delta":" I","logprobs":[{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]}]}
data: {"type":"transcript.text.delta","delta":" think","logprobs":[{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]}]}
data: {"type":"transcript.text.delta","delta":" to","logprobs":[{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]}]}
data: {"type":"transcript.text.delta","delta":" myself","logprobs":[{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.29254505,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" what","logprobs":[{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]}]}
data: {"type":"transcript.text.delta","delta":" a","logprobs":[{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]}]}
data: {"type":"transcript.text.delta","delta":" wonderful","logprobs":[{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]}]}
data: {"type":"transcript.text.delta","delta":" world","logprobs":[{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]}]}
data: {"type":"transcript.text.delta","delta":".","logprobs":[{"token":".","logprob":-0.014231676,"bytes":[46]}]}
data: {"type":"transcript.text.done","text":"I see skies of blue and clouds of white, the bright blessed days, the dark sacred nights, and I think to myself, what a wonderful world.","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]},{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]},{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]},{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]},{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]},{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]},{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]},{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]},{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]},{"token":",","logprob":-0.0014890312,"bytes":[44]},{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]},{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]},{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]},{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]},{"token":",","logprob":-0.00001700133,"bytes":[44]},{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]},{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]},{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]},{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]},{"token":",","logprob":-0.0036910512,"bytes":[44]},{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]},{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]},{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]},{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]},{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]},{"token":",","logprob":-0.29254505,"bytes":[44]},{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]},{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]},{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]},{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]},{"token":".","logprob":-0.014231676,"bytes":[46]}],"usage":{"input_tokens":14,"input_token_details":{"text_tokens":0,"audio_tokens":14},"output_tokens":45,"total_tokens":59}}
逐词时间戳示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "timestamp_granularities[]=word" \
-F model="whisper-1" \
-F response_format="verbose_json"
响应示例
{
"task": "transcribe",
"language": "english",
"duration": 0.5,
"text": "Hello.",
"words": [
{
"word": "Hello",
"start": 0.0,
"end": 0.5
}
],
"usage": {
"type": "duration",
"seconds": 1
}
}
TRAE-AI编程


更多建议: