- Third-party
- Zero data retention
一款语音转文本模型,使用 GPT-4o 转录音频,与原始 Whisper 模型相比,词错误率更低,语言识别能力更强。
| 模型信息 | |
|---|---|
| 条款和许可证 | 链接 ↗ |
| 更多信息 | 链接 ↗ |
| 零数据保留 | 是 |
| 定价 | 在 Cloudflare 仪表板中查看定价 ↗ |
用法
const response = await env.AI.run(
'openai/gpt-4o-transcribe',
{ file: 'data:audio/wav;base64,<...>' },
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "openai/gpt-4o-transcribe",
"input": {
"file": "data:audio/wav;base64,<...>"
}
}'Hello
{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"text": "Hello"
},
"state": "Completed"
}示例
提供语言提示 — 借助语言提示进行转录,以提高准确度
const response = await env.AI.run(
'openai/gpt-4o-transcribe',
{ file: 'data:audio/wav;base64,<...>', language: 'en' },
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "openai/gpt-4o-transcribe",
"input": {
"file": "data:audio/wav;base64,<...>",
"language": "en"
}
}'Hello
{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"text": "Hello"
},
"state": "Completed"
}引导式转录 — 使用提示词引导转录风格和上下文
const response = await env.AI.run(
'openai/gpt-4o-transcribe',
{
file: 'data:audio/wav;base64,<...>',
prompt: 'This is a technical discussion about Kubernetes and cloud-native architecture.',
language: 'en',
},
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "openai/gpt-4o-transcribe",
"input": {
"file": "data:audio/wav;base64,<...>",
"prompt": "This is a technical discussion about Kubernetes and cloud-native architecture.",
"language": "en"
}
}'This is a technical discussion about Kubernetes and cloud-native architecture.
{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"text": "This is a technical discussion about Kubernetes and cloud-native architecture."
},
"state": "Completed"
}高温度 — 使用较高的温度,使转录结果更多样
const response = await env.AI.run(
'openai/gpt-4o-transcribe',
{ file: 'data:audio/wav;base64,<...>', temperature: 0.5 },
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "openai/gpt-4o-transcribe",
"input": {
"file": "data:audio/wav;base64,<...>",
"temperature": 0.5
}
}'Hello, world!
{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"text": "Hello, world!"
},
"state": "Completed"
}参数
file
stringrequired音频文件,可以是 data URI(data:audio/...;base64,...)或 HTTPS URL。支持的格式:flac、mp3、mp4、mpeg、mpga、m4a、ogg、wav、webm。language
string输入音频的语言。以 ISO-639-1 格式提供输入语言可提高准确度并降低延迟。prompt
string可选文本,用于引导模型的风格或接续上一段音频。提示词应与音频语言一致。temperature
numberminimum: 0maximum: 1采样温度,取值介于 0 到 1 之间。较高的值(如 0.8)会使输出更随机,较低的值(如 0.2)会使输出更集中、更确定。省略时默认为 0。text
string转录后的文本。