跳到主要内容

文本转语音

将文本转换为音频。

Try It

POST/v1/audio/speechhttps://api-platform.ope.ai

认证

使用 Bearer Token 认证。

  • Header:Authorization: Bearer <token>
  • 示例:Authorization: Bearer sk-xxxxxx

请求体(application/json)

字段类型必填说明默认值 / 范围
modelstring模型 ID-
textstring要转换的文本长度 <= 4096
voicestring发音人每个模型支持的发音人不同,请查看具体模型文档
response_formatstring音频格式默认 "mp3""mp3" | "opus" | "aac" | "flac" | "wav" | "pcm"
speednumber语速默认 1;范围 0.1~4

请求示例

下方域名为示例:https://api-platform.ope.ai

curl -X POST "https://api-platform.ope.ai/v1/audio/speech" \
-H "Authorization: Bearer $OPEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "AudioLLM/Voice1.0",
"text": "支持多场景定制,可满足广告配音、教程解说等需求",
"voice": "James"
}' --output speech.mp3

响应示例

  • 200audio/mpeg(二进制音频数据,示例里保存为 speech.mp3