将文本转换为语音,支持多种声音类型
http://api.xuewutheme.com/api/other/tts?text=123&voice=云小宁
将文本转换为语音,支持多种声音类型
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| apikey string | 整数 | string |
用户开通的apikey |
| text string | 整数 | string |
文本内容 |
| format string | 整数 | string |
输出类型(MP3/WAV) |
| volume int | 整数 | int |
音量大小(0-10) |
| speech_rate int | 整数 | int |
语速(0-10) |
| pitch_rate int | 整数 | int |
语调(0-10) |
| voice string | 整数 | string |
声音类型(/api/get/ttstypelist)获取 |
| 参数名 | 类型 | 描述 |
|---|---|---|
| code integer | integer |
返回的状态码 |
| data object | object |
返回的数据/数据对象 |
| msg string | string |
返回的消息 |
| time string | string |
请求时间 |
| data.file_link string | string |
下载链接 |
| data.params.format string | string |
音频类型 |
| data.params.pitch_rate int | int |
音调调整 |
| data.params.speech_rate int | int |
语速调整 |
| data.params.volume int | int |
音量调整 |
| data.text string | string |
转换文本 |
| data.voice_info.category string | string |
声音分类 |
| data.voice_info.desc string | string |
声音特点 |
| data.voice_info.name string | string |
声音名称 |
{
"code": 200,
"data": {
"file_link": "http://asr-tmp-resource.oss-cn-shanghai.aliyuncs.com/text-to-voice/188d9316a260adc4f6e22833e775b0c9.mp3?OSSAccessKeyId=LTAItIQd1kGPPB9P&Expires=1743075404&Signature=OrMB9T4sWlGC3PvEQRT98bcBcMg%3D",
"params": {
"format": "MP3",
"pitch_rate": 5,
"speech_rate": 5,
"volume": 10
},
"text": "123",
"voice_info": {
"category": "女声",
"desc": "亲和温柔",
"name": "云小宁"
}
},
"msg": "请求成功!",
"time": "2025-03-23 20:17:11"
}
curl -X GET \
"https://api.example.com/v1/users/12345" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json"
import requests
url = "https://api.example.com/v1/users/12345"
headers = {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
print(response.json())
const response = await fetch(
'https://api.example.com/v1/users/12345',
{
method: 'GET',
headers: {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
'Content-Type': 'application/json'
}
}
);
const data = await response.json();
console.log(data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.example.com/v1/users/12345");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$headers = array();
$headers[] = "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
| 状态码 | 描述 |
|---|---|
| 100 | 您的apikey值为空! |
| 101 | 您的apikey值不存在! |
| 103 | 当前接口为实名认证后可用,请您先进行实名! |
| 104 | 请求频率超限! |
| 105 | 接口不存在或已下线! |
| 106 | 您的余额不足,请及时充值! |
| 107 | 您当前的接口免费使用次数已用完,请明日再来! |
| 109 | 您的账号已被封禁,不可使用任何接口! |
| 110 | 接口维护中,请稍后再试! |
| 111 | 请求参数不完整,请检查后再次访问! |
{
"code": 1001,
"message": "用户不存在",
"data": null
}