石榴AI开放平台
  1. Speaker
石榴AI开放平台
  • Overview
    • Authentication
    • Limits
  • API
    • Speaker
      • Create Speaker
        POST
      • Text To Speech
        POST
      • List Speakers
        POST
      • Query Status
        POST
      • Recreate Speaker
        POST
      • Delete Speaker
        POST
      • Get Recreated Record
        POST
    • Avatar
      • Train Avatar Model
      • Train Avatar Model By Image
      • Query Training Status
      • List Avatars
      • Delete Avatar
    • Video
      • Query Status
      • Create Video By Voice
      • Create Video By AudioFile
      • Create Video By Text
    • Asset
      • Get Asset
      • Get Records
    • Upload
      • Get Upload URL
    • AuthVideo
      • Create ​Authorization Video​
  • Error Code
    • Error Code
  1. Speaker

Text To Speech

POST
/speaker/tts
语音合成

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Body 参数application/json
speakerId
integer 
音色ID
必需
text
string 
待合成的文本
必需
speedRatio
number 
语速
可选
浮点数类型,[0.2, 3.0],默认为1.0,通常保留一位小数即可
volumeRatio
number 
音量
可选
浮点数类型,[0.1, 3],默认为1.0,通常保留一位小数即可
pitchRatio
number 
语调
可选
浮点数类型,[0.1, 3],默认为1.0,通常保留一位小数即可
示例
{
    "speakerId": 0,
    "text": "string",
    "speedRatio": 0,
    "volumeRatio": 0,
    "pitchRatio": 0
}

示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.16ai.chat/api/v1/speaker/tts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "speakerId": 0,
    "text": "string",
    "speedRatio": 0,
    "volumeRatio": 0,
    "pitchRatio": 0
}'

返回响应

🟢200成功
application/json
Body
code
integer 
状态码
必需
data
object 
响应内容
必需
audio
string 
音频数据(Base64编码)
必需
音源为mp3格式
length
integer 
音频时长
必需
单位:毫秒
msg
string 
错误信息
必需
示例
{"code":0,"data":{"audio":"//PkxAA......VVVVV","length":1616},"msg":""}
修改于 2025-05-21 09:14:57
上一页
Create Speaker
下一页
List Speakers
Built with