|
|
2 tháng trước cách đây | |
|---|---|---|
| .. | ||
| README.md | 2 tháng trước cách đây | |
封装出给硬件厂商用的 TTS SDK,让他们 5 分钟接入我们的 TTS 能力。
# Python 示例
from tts_sdk import TTSClient
client = TTSClient(
api_key='your-key',
base_url='https://api.your-domain.com',
)
# 短文本同步合成
audio = client.synthesize(
text='你好世界',
voice_id='female-shaonv',
)
# 长文本异步合成
task_id = client.async_synthesize(
text='很长的文本...',
voice_id='male-qn-jingying',
)
# 查询任务
result = client.get_task(task_id)
# 自然语言指令
audio = client.instruct(
text='从前有一只小兔子',
instruction='用磁性男声,悲伤语气',
)
# tts_sdk/client.py
class TTSClient:
def __init__(self, api_key, base_url):
self.api_key = api_key
self.base_url = base_url
def synthesize(self, text, voice_id=None, **kwargs):
# POST /v1/tts/synthesize
...
def async_synthesize(self, text, **kwargs):
# POST /v1/tts/async-synthesize
...
def get_task(self, task_id):
# GET /v1/tts/tasks/{task_id}
...
def instruct(self, text, instruction):
# POST /v1/tts/instruct
...
类似结构,TypeScript 实现。
给 ESP32 / 嵌入式使用,需要封装 HTTP 客户端。
| 模式 | 单价 | 客户类型 |
|---|---|---|
| 免费试用 | 10000 字符/月 | 所有客户 |
| API 调用 | ¥0.01/次 | 中小客户 |
| SDK 年费 | ¥1 万-10 万/年 | 中小硬件厂商 |
| 设备授权 | ¥10-50/台 | 大批量客户 |
等 pc-simulator/ 跑通后,抽取通用 SDK 模块。