Mangogo 营业厅Mangogo 营业厅
首页API 参考Skills插件

POST /v1/audio/speech

POST/v1/audio/speech

文本转语音(TTS)。

鉴权:Bearer Token

Content-Type:application/json

请求体

{  "model": "tts-1",  "input": "Hello, welcome to YunSell AI text-to-speech service.",  "voice": "alloy",  "response_format": "mp3",  "speed": 1.0}

请求字段

字段类型必填说明
modelstring是TTS 模型,如 tts-1、cosyvoice-v3-flash
inputstring是待合成文本
voicestring是音色代码(见上文音色列表)
response_formatstring否输出格式:mp3(默认)、opus、aac、flac、wav、pcm
speednumber否语速,0.25–4.0,默认 1.0

CosyVoice 模型示例:

{  "model": "cosyvoice-v3-flash",  "input": "你好,欢迎使用语音合成服务。",  "voice": "longxiaochun",  "response_format": "mp3",  "speed": 1.0}

请求示例(curl)

curl https://www.yunsell.com/v1/audio/speech \  -H "Authorization: Bearer sk-xxx" \  -H "Content-Type: application/json" \  -d '{    "model": "tts-1",    "input": "Hello, welcome to YunSell AI text-to-speech service.",    "voice": "alloy",    "response_format": "mp3",    "speed": 1.0  }' \  -o speech.mp3

CosyVoice 模型:

curl https://www.yunsell.com/v1/audio/speech \  -H "Authorization: Bearer sk-xxx" \  -H "Content-Type: application/json" \  -d '{    "model": "cosyvoice-v3-flash",    "input": "你好,欢迎使用语音合成服务。",    "voice": "longxiaochun",    "response_format": "mp3",    "speed": 1.0  }' \  -o speech.mp3

响应体

HTTP 200

  • Content-Type:audio/mpeg(mp3)或对应格式 MIME
  • Body:音频二进制流(非 JSON)

响应 Header 示例:

HTTP/1.1 200 OKContent-Type: audio/mpegContent-Length: 45632

响应说明

项说明
HTTP 状态码200
Content-Type由 response_format 决定,见下表
响应体音频二进制流,非 JSON

response_format 与 Content-Type 对应关系

response_formatContent-Type
mp3(默认)audio/mpeg
opusaudio/opus
aacaudio/aac
flacaudio/flac
wavaudio/wav
pcmaudio/pcm

失败响应

HTTP 400,格式见 标准错误。

{  "error": {    "message": "voice is required",    "type": "invalid_request_error",    "code": "invalid_request"  }}