Skip to main content
POST
https://xcompute.us
/
v1
/
audio
/
speech
curl --request POST \
  --url https://xcompute.us/v1/audio/speech \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-4o-mini-tts",
    "input": "今天天气真好,适合出去散步。",
    "voice": "alloy",
    "response_format": "opus",
    "speed": 1.0
  }' \
  --output speech.opus
  • 文字转语音接口
  • 输出高质量音频格式
  • 最大输入文本 4096 个字符

支持模型

  • gpt-4o-mini-tts

参数字段

model
string
default:"gpt-4o-mini-tts"
required
固定填写 gpt-4o-mini-tts
input
string
required
要转换成语音的文本内容。
voice
string
required
音色名称。可选值:alloyechofableonyxnovashimmer
response_format
string
default:"wav"
输出格式。可选值:wavopusaacflacpcm
speed
number
default:"1.0"
播放速度,范围 0.25 ~ 4.0
curl --request POST \
  --url https://xcompute.us/v1/audio/speech \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-4o-mini-tts",
    "input": "今天天气真好,适合出去散步。",
    "voice": "alloy",
    "response_format": "opus",
    "speed": 1.0
  }' \
  --output speech.opus
成功时返回二进制音频数据流,可以直接保存为音频文件或播放。