文本转语音
POST
/v1/tts
语音合成
请求参数
Authorization
Header 参数
model
enum<string>
可选
枚举值:
speech-1.5speech-1.6s1s1-mini
默认值:
speech-1.5
Authorization
string
可选
示例值:
Bearer sk-xxx
Body 参数application/json
text
string
必需
示例值:
测试语音文本
chunk_length
integer
文本分块长度
>= 100<= 300
默认值:
200
format
enum<string>
输出音频格式
枚举值:
wavpcmmp3opus
默认值:
mp3
mp3_bitrate
enum<integer>
MP3 比特率
枚举值:
64128192
默认值:
128
reference_id
string
预上传模型的 ID
示例值:
7f92f8afb8ec43bf81429cc1c9199cb1
normalize
boolean
可选
默认值:
true
latency
enum<string>
延迟模式
枚举值:
normalbalanced
默认值:
normal
temperature
number
语音生成随机性控制
>= 0.1<= 2
默认值:
0.7
top_p
number
核采样参数
>= 0.1<= 1
默认值:
0.7
示例
{
"text": "测试语音生成系统是否有效",
"chunk_length": 106,
"format": "opus",
"mp3_bitrate": 192,
"reference_id": "7f92f8afb8ec43bf81429cc1c9199cb1",
"normalize": true,
"latency": "normal",
"temperature": 0.1821629194370873,
"top_p": 0.6951457824758468
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST '/v1/tts' \
--header 'model;' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "测试语音生成系统是否有效",
"chunk_length": 106,
"format": "opus",
"mp3_bitrate": 192,
"reference_id": "7f92f8afb8ec43bf81429cc1c9199cb1",
"normalize": true,
"latency": "normal",
"temperature": 0.1821629194370873,
"top_p": 0.6951457824758468
}'
返回响应
🟢200成功
audio/mpeg
Body
object {0}
示例
{}
🟠401没有权限
🟠402402
🟠422参数错误
修改于 2025-06-20 04:28:13