Chanjing TTS Voice Clone
When to Use This Skill
Use this skill when the user needs to generate speech from text, with a user-provided reference voice. The reference audio needs to be provided as a publicly accessible url.
This TTS service supports:
- * bilingual Chinese and English
- adjustment of speech rate
- sentence-level timestamp
How to Use This Skill
前置条件(本地配置与鉴权):本 Skill 自己包含本地配置和鉴权流程,不依赖其他 skill 的运行时脚本。
默认读取 ~/.chanjing/credentials.json;若设置 CHANJING_CONFIG_DIR,则读取 $CHANJING_CONFIG_DIR/credentials.json。
API 固定使用 https://open-api.chanjing.cc。
当本地缺少 AK/SK 或 AK/SK 无效时,脚本默认返回登录引导信息,不自动打开浏览器。
如需本地自动开页,可显式设置:CHANJING_AUTO_OPEN_LOGIN=1。登录页:https://www.chanjing.cc/openapi/login。
Chanjing-TTS-Voice-Clone provides an asynchronous speech synthesis API.
Hostname for all APIs is: "https://open-api.chanjing.cc".
All requests communicate using json.
You should use utf-8 to encode and decode text throughout this task.
- 1. Obtain an access\_token, which is required for subsequent requests
- Call the Create Voice API, which accepts a url to an audio file as reference voice
- Poll the Query Voice API until the result is success; keep the voice ID
- Call the Create Speech Generation Task API, using the voice ID, record the INLINECODE6
- Poll the Query Speech Generation Task Status API until the result is success
- When the task status is complete, use the corresponding url in API response to download the generated audio file
Get Access Token API
从 ~/.chanjing/credentials.json 读取 app_id 和 secret_key,若无有效 Token 则调用:
CODEBLOCK0
请求体(使用本地配置的 appid、secretkey):
CODEBLOCK1
Response example:
CODEBLOCK2
Response field description:
| First-level Field | Second-level Field | Description |
|---|
| code | | Response status code |
| msg |
| Response message |
| data | | Response data |
| | access\_token | Valid for one day, previous token will be invalidated |
| | expire\_in | Token expiration time |
Response status code description:
| code | Description |
|---|
| 0 | Success |
| 400 |
Parameter format error |
| 40000 | Parameter error |
| 50000 | System internal error |
Create Voice API
Post to the following endpoint to create a voice.
CODEBLOCK3
Request body example:
CODEBLOCK4
Request field description:
| Field | Type | Required | Description |
|---|
| name | string | Yes | A name for this voice |
| url |
string | Yes | url to the reference audio file, format must be one of mp3, wav or m4a. Supported mime: audio/x-wav, audio/mpeg, audio/m4a, video/mp4. Size must not exceed 100MB. Recommended audio length: 30s-5min |
| model\_type | string | Yes | Use "Cicada3.0-turbo" |
| language | string | No | Either "cn" or "en", default to "cn" |
Response example:
CODEBLOCK5
Response field description:
| Field | Description |
|---|
| code | Status Code |
| msg |
Message |
| data | Voice ID, to be used in following steps |
Response status code description:
| Code | Description |
|---|
| 0 | Success |
| 400 |
Parameter Format Error |
| 10400 | AccessToken Error |
| 40000 | Parameter Error |
| 40001 | QPS Exceeded |
| 50000 | Internal System Error |
Poll Voice API
Send a GET request to the following endpoint to query whether the voice is ready to be used, voice ID is obtained in the previous step.
The polling process may take a few minutes, keep polling until the status indicates the voice is ready.
CODEBLOCK6
Response example:
CODEBLOCK7
Response field description:
| First-level Field | Second-level Field | Description |
|---|
| code | | Status Code |
| msg |
| Response Message |
| data | | |
| | id | Voice ID |
| | progress | Progress: range 0-100 |
| | type | |
| | name | |
| | err\_msg | Error Message |
| | audio\_path | |
| | status | 0-queued; 1-in progress; 2-done; 3-expired; 4-failed; 99-deleted |
Response status code description:
| Code | Description |
|---|
| 0 | Success |
| 10400 |
AccessToken Error |
| 40000 | Parameter Error |
| 40001 | QPS Exceeded |
| 50000 | Internal System Error |
Create Speech Generation Task API
Post to the following endpoint to submit a speech generation task:
CODEBLOCK8
Request body example:
CODEBLOCK9
Request field description:
| Parameter Name | Type | Nested Key | Required | Example | Description |
|---|
| audio\_man | string | | Yes | C-Audio-53e4e53ba1bc40de91ffaa74f20470fc | Voice ID, obtained from previous step |
| speed |
number | | Yes | 1 | Speech rate, range: 0.5 (slow) to 2 (fast) |
| pitch | number | | Yes | 1 | Pitch (always set to 1) |
| text | object | text | Yes | Hello, I am your Cicada digital human | Rich text, text length limit less than 4,000 characters |
| aigc\_watermark | bool | | No | false | Whether to add visible watermark to audio, default is false |
Response field description:
| Field | Description |
|---|
| code | Response status code |
| msg |
Response message |
| task\_id | Speech synthesis task ID |
Example Response
CODEBLOCK10
Response status code description:
| code | Description |
|---|
| 0 | Success |
| 400 |
Incoming parameter format error |
| 10400 | AccessToken verification failed |
| 40000 | Parameter error |
| 40001 | Exceeds QPS limit |
| 40002 | Production duration reached limit |
| 50000 | System internal error |
Query Speech Generation Task Status API
Post a request to the following endpoint:
CODEBLOCK11
Request body example:
CODEBLOCK12
Request field description:
| Parameter Name | Type | Required | Example | Description |
|---|
| task\_id | string | Yes | 88f789dd9b8e4a121abb9d4679e0edc8 | Task ID obtained in previous step |
Response body example:
CODEBLOCK13
Response field description:
| First-level Field | Second-level Field | Third-level Field | Description |
|---|
| code | | | Response status code |
| msg |
| | Response message |
| data | id | | Audio ID |
| | type | | Speech type |
| | status | | Status: 1 - in progress, 9 - done |
| | text | | Speech text |
| | full | url | url to download generated audio file |
| | | path | |
| | | duration | Audio duration |
| | slice | | |
| | errMsg | | Error message |
| | errReason | | Error reason |
| | subtitles(array type) | key | Subtitle ID |
| | | start\_time | Subtitle start time point |
| | | end\_time | Subtitle end time point |
| | | subtitle | Subtitle text |
Response field description:
| Code | Description |
|---|
| 0 | Response successful |
| 10400 |
AccessToken verification failed |
| 40000 | Parameter error |
| 50000 | System internal error |
Scripts
本 Skill 提供脚本(scripts/):
| 脚本 | 说明 |
|---|
| INLINECODE11 | 写入/查看本地 app_id 与 secret_key,并清理旧 token 缓存 |
| INLINECODE14 |
从本地凭证获取有效
access_token(必要时自动刷新) |
|
create_voice | 提交定制声音任务(参考音频 URL),输出 voice_id |
|
poll_voice | 轮询定制声音直到就绪(status=2),输出 voice_id |
|
create_task | 使用定制声音创建 TTS 任务,输出 task_id |
|
poll_task | 轮询 TTS 任务直到完成,输出音频下载 URL |
示例(在项目根或 skill 目录下执行):
CODEBLOCK14
Chanjing TTS 声音克隆
何时使用此技能
当用户需要根据文本生成语音,并提供用户提供的参考声音时使用此技能。参考音频需要以可公开访问的 URL 形式提供。
此 TTS 服务支持:
如何使用此技能
前置条件(本地配置与鉴权):本技能自带本地配置和鉴权流程,不依赖其他技能的运行时脚本。
默认读取 ~/.chanjing/credentials.json;若设置 CHANJINGCONFIGDIR,则读取 $CHANJINGCONFIGDIR/credentials.json。
API 固定使用 https://open-api.chanjing.cc。
当本地缺少 AK/SK 或 AK/SK 无效时,脚本默认返回登录引导信息,不自动打开浏览器。
如需本地自动开页,可显式设置:CHANJINGAUTOOPEN_LOGIN=1。登录页:https://www.chanjing.cc/openapi/login。
Chanjing-TTS-声音克隆提供异步语音合成 API。
所有 API 的主机名为:https://open-api.chanjing.cc。
所有请求均使用 JSON 进行通信。
在整个任务中,应使用 UTF-8 对文本进行编码和解码。
- 1. 获取 accesstoken,后续请求需要用到
- 调用创建声音 API,该 API 接受一个音频文件的 URL 作为参考声音
- 轮询查询声音 API,直到结果为成功;保留声音 ID
- 调用创建语音生成任务 API,使用声音 ID,记录 taskid
- 轮询查询语音生成任务状态 API,直到结果为成功
- 当任务状态完成时,使用 API 响应中的相应 URL 下载生成的音频文件
获取访问令牌 API
从 ~/.chanjing/credentials.json 读取 appid 和 secretkey,若无有效 Token 则调用:
http
POST /open/v1/access_token
Content-Type: application/json
请求体(使用本地配置的 appid、secretkey):
json
{
app_id: <从 credentials.json 读取>,
secret_key: <从 credentials.json 读取>
}
响应示例:
json
{
trace_id: 8ff3fcd57b33566048ef28568c6cee96,
code: 0,
msg: success,
data: {
access_token: 1208CuZcV1Vlzj8MxqbO0kd1Wcl4yxwoHl6pYIzvAGoP3DpwmCCa73zmgR5NCrNu,
expire_in: 1721289220
}
}
响应字段说明:
| 响应消息 |
| data | | 响应数据 |
| | access_token | 有效期一天,之前的 token 将失效 |
| | expire_in | Token 过期时间 |
响应状态码说明:
参数格式错误 |
| 40000 | 参数错误 |
| 50000 | 系统内部错误 |
创建声音 API
向以下端点发送 POST 请求以创建声音。
http
POST /open/v1/createcustomisedaudio
accesstoken: {{accesstoken}}
Content-Type: application/json
请求体示例:
json
{
name: example,
url: https://example.com/abc.mp3
}
请求字段说明:
| 字段 | 类型 | 必填 | 说明 |
|---|
| name | string | 是 | 此声音的名称 |
| url |
string | 是 | 参考音频文件的 URL,格式必须为 mp3、wav 或 m4a 之一。支持的 MIME 类型:audio/x-wav、audio/mpeg、audio/m4a、video/mp4。大小不得超过 100MB。推荐音频时长:30 秒至 5 分钟 |
| model_type | string | 是 | 使用 Cicada3.0-turbo |
| language | string | 否 | cn 或 en,默认为 cn |
响应示例:
json
{
trace_id: 2f0f50951d0bae0a3be3569097305424,
code: 0,
msg: success,
data: C-Audio-53e4e53ba1bc40de91ffaa74f20470fc
}
响应字段说明:
消息 |
| data | 声音 ID,后续步骤中使用 |
响应状态码说明:
参数格式错误 |
| 10400 | AccessToken 错误 |
| 40000 | 参数错误 |
| 40001 | QPS 超出限制 |
| 50000 | 系统内部错误 |
轮询声音 API
向以下端点发送 GET 请求以查询声音是否准备就绪,声音 ID 在上一步中获取。
轮询过程可能需要几分钟,持续轮询直到状态指示声音已准备就绪。
http
GET /open/v1/customisedaudio?id={{voiceid}}
accesstoken: {{accesstoken}}
响应示例:
json
{
trace_id: 7994cedae0f068d1e9e4f4abdf99215b,
code: 0,
msg: success,
data: {
id: C-Audio-53e4e53ba1bc40de91ffaa74f20470fc,
name: 声音克隆,
type: cicada1.0,
progress: 0,
audio_path: ,
err_msg: 不支持的音频格式,请阅读接口文档,
status: 2
}
}
响应字段说明:
| 响应消息 |
| data | | |
| | id | 声音 ID |
| | progress | 进度:范围 0-100 |
| | type | |
| | name | |
| | err_msg | 错误消息 |
| | audio_path | |
| | status | 0-排队中;1-进行中;2-已完成;3-已过期;4-失败;99-已删除 |
响应状态码说明:
AccessToken 错误 |
| 40000 | 参数错误 |
| 40001 | QPS 超出限制 |
| 50000 | 系统内部错误 |
创建语音生成任务 API
向以下端点发送 POST 请求以提交语音生成任务:
http
POST /open/v1/createaudiotask
accesstoken: {{accesstoken}}
Content-Type: application/json
请求体示例:
json
{
audio_man: C-Audio-53e4e53ba1bc40de91ffaa74f20470fc,
speed: 1,
pitch: 1,
text: {
text: 你好,我是你的 AI 助手。
}
}
请求字段说明:
| 参数名 | 类型 | 嵌套键 | 必填 | 示例 | 说明 |
|---|
| audio_man | string | | 是 | C-Audio-53e4e53ba1bc40de91ffaa74f20470fc | 声音 ID,从上一步获取 |
| speed |
number | | 是 | 1 | 语速,范围:0.5(慢)到 2(快) |
| pitch | number | | 是 | 1 | 音调(始终设置为 1) |
| text | object | text | 是 | 你好,我是你的蝉镜数字人 | 富文本,文本长度限制小于 4000 个字符 |
| aigc_watermark | bool | | 否 | false | 是否在音频中添加可见水印,默认为 false |
响应字段说明:
响应消息 |
| task_id | 语音合成任务 ID |
响应示例
json
{
trace_id: dd09f123a25b43cf2119a2449daea6de,
code: 0,
msg: success,
data: {
task_id: 88f635dd9b8e4a898abb9d4679e0edc8
}
}
响应状态码说明:
|