📖 简介

维吾尔语智能文字转语音 API 系统,提供完整的 RESTful API 接口,支持语音合成、发音人管理、音频下载等功能。

基础 URL
/api/
响应格式
JSON / MP3
认证方式
Token (可选)
🔗 API 接口
GET 语音合成
http://your-domain.com/api/tts.php

将文本转换为语音,支持维吾尔语、中文等多种语言。

参数 类型 必填 说明 默认值
text String 要转换的文本内容 -
voice String 发音人: female(女声), male(男声), ug-female, ug-male, 或克隆音色 female
speed Float 语速: 0.5 ~ 2.0 1.0
pitch Int 音调: -10 ~ 10 0
lang String 语言: ug-CN(维吾尔语), zh-CN, zh-TW, en ug-CN
token String API 密钥 (如已配置) -
请求示例
# 基本调用
curl "http://localhost/api/tts.php?text=ئۇيغۇرچە&voice=female&speed=1"

# 指定语言和音调
curl "http://localhost/api/tts.php?text=你好世界&voice=male&speed=1.2&pitch=2&lang=zh-CN"

# 使用克隆音色
curl "http://localhost/api/tts.php?text=测试文本&voice=my_voice"
// JavaScript/Fetch
const response = await fetch('/api/tts.php?text=' + encodeURIComponent('ئۇيغۇرچە'));

// 播放音频
const blob = await response.blob();
const url = URL.createObjectURL(blob);
new Audio(url).play();

// 下载音频
const a = document.createElement('a');
a.href = url;
a.download = 'tts.mp3';
a.click();
# Python Requests
import requests

url = "http://localhost/api/tts.php"
params = {
    'text': 'ئۇيغۇرچە',
    'voice': 'female',
    'speed': 1,
    'lang': 'ug-CN'
}

response = requests.get(url, params=params)

# 保存音频文件
with open('output.mp3', 'wb') as f:
    f.write(response.content)
GET 获取发音人列表
http://your-domain.com/api/voices.php

获取所有可用的发音人和语言列表。

参数 类型 必填 说明
token String API 密钥
响应示例
{
  "success": true,
  "languages": {
    "ug-CN": "维吾尔语",
    "zh-CN": "中文(简体)"
  },
  "voices": [
    {"code": "female", "name": "女声", "type": "standard"},
    {"code": "male", "name": "男声", "type": "standard"}
  ],
  "defaults": {
    "voice": "female",
    "speed": 1,
    "lang": "ug-CN"
  }
}
GET 下载音频
http://your-domain.com/api/download.php

下载合成的音频文件。

参数 类型 必填 说明
text String 要转换的文本
voice String 发音人
speed Float 语速
lang String 语言
⚠️ 错误代码
代码 说明
200 成功
400 参数错误
401 认证失败
500 服务器错误