- Third-party
- Zero data retention
OpenAI 的高清文本转语音模型,可输出更高质量的音频。
| 模型信息 | |
|---|---|
| 条款和许可证 | 链接 ↗ |
| 更多信息 | 链接 ↗ |
| 零数据保留 | 是 |
| 定价 | 在 Cloudflare 仪表板中查看定价 ↗ |
用法
const response = await env.AI.run(
'openai/tts-1-hd',
{
response_format: 'mp3',
speed: 1,
text: 'Hello! Welcome to Cloudflare AI Gateway. Let me show you what we can do.',
voice: 'alloy',
},
)
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/tts-1-hd",
"input": {
"response_format": "mp3",
"speed": 1,
"text": "Hello! Welcome to Cloudflare AI Gateway. Let me show you what we can do.",
"voice": "alloy"
}
}'{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1-hd/simple-speech.mp3"
},
"state": "Completed"
}示例
讲故事 — 使用 Fable 音色进行高清旁白
const response = await env.AI.run(
'openai/tts-1-hd',
{
response_format: 'mp3',
speed: 0.9,
text: 'Once upon a time, in a kingdom beyond the clouds, there lived a young inventor who dreamed of building machines that could think.',
voice: 'fable',
},
)
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/tts-1-hd",
"input": {
"response_format": "mp3",
"speed": 0.9,
"text": "Once upon a time, in a kingdom beyond the clouds, there lived a young inventor who dreamed of building machines that could think.",
"voice": "fable"
}
}'{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1-hd/storytelling.mp3"
},
"state": "Completed"
}播客风格 — 对话式播客旁白
const response = await env.AI.run(
'openai/tts-1-hd',
{
response_format: 'mp3',
speed: 1,
text: "So here's the thing about large language models — they're not actually thinking. They're predicting the next token based on patterns in their training data. But the results can be surprisingly coherent.",
voice: 'echo',
},
)
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/tts-1-hd",
"input": {
"response_format": "mp3",
"speed": 1,
"text": "So here'\''s the thing about large language models — they'\''re not actually thinking. They'\''re predicting the next token based on patterns in their training data. But the results can be surprisingly coherent.",
"voice": "echo"
}
}'{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1-hd/podcast-style.mp3"
},
"state": "Completed"
}Shimmer 音色 — 明亮而富有表现力的音色
const response = await env.AI.run(
'openai/tts-1-hd',
{
response_format: 'mp3',
speed: 1,
text: 'Breaking news: scientists have discovered a new species of deep-sea fish that produces its own light using bioluminescence.',
voice: 'shimmer',
},
)
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/tts-1-hd",
"input": {
"response_format": "mp3",
"speed": 1,
"text": "Breaking news: scientists have discovered a new species of deep-sea fish that produces its own light using bioluminescence.",
"voice": "shimmer"
}
}'{
"gatewayMetadata": {
"keySource": "Unified"
},
"result": {
"audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1-hd/shimmer-voice.mp3"
},
"state": "Completed"
}参数
text
stringrequiredmaxLength: 4096要生成音频的文本。最大长度为 4096 个字符。voice
stringrequireddefault: alloyenum: alloy, echo, fable, onyx, nova, shimmer生成音频时使用的音色。默认为 alloy。response_format
stringrequireddefault: mp3enum: mp3, opus, wav, aac, flac音频的输出格式。支持的格式为 mp3、opus、wav、aac 和 flac。speed
numberrequireddefault: 1minimum: 0.25maximum: 4生成音频的语速。取值范围为 0.25 到 4.0,默认为 1.0。audio
string生成音频文件的 URL