创建语音(tts
OpenAPI Specification
语音合成(TTS)接口:提交待合成文本与音色等参数,返回音频内容,支持流式返回以边接收边播放。
请求方式:POST
接口地址
text
https://api.allyang.cn/v1/audio/speech
请求头
Authorization(可选):鉴权头,使用控制台创建的令牌,格式为 Bearer + 令牌。(示例:Bearer {{YOUR_API_KEY}})
请求参数(application/json)
model(string,必填):TTS 模型,可选 tts-1 或 tts-1-hd。input(string,必填):待合成的文本,最长 4096 字符。voice(string,必填):发音音色,支持 alloy、echo、fable、onyx、nova、shimmer。response_format(string,可选):音频格式,缺省 mp3;支持 mp3、opus、aac、flac。speed(number,可选):语速,缺省 1;取值范围 0.25~4.0。
请求示例
json
{
"model": "gpt-4o-mini-tts",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}
返回:HTTP 200 表示成功,响应体字段待补(以实测为准)。
使用提示:文本最大长度与音色可用范围以参数说明为准;流式场景请按音频流方式处理返回。