$npx -y skills add chanjing-ai/chan-skills --skill chanjing-tts-voice-cloneUse Chanjing TTS API to synthesize speech from text with a user-provided cloned voice (reference audio via public URL).
| 1 | # Chanjing TTS Voice Clone |
| 2 | |
| 3 | ## 功能说明 |
| 4 | |
| 5 | 基于用户提供的**参考音频公网 URL**(由蝉镜服务端拉取)创建音色并合成语音;轮询任务并从接口返回 URL 下载结果。脚本**不**依赖 ffmpeg/ffprobe。凭据、令牌写回与权限见 **`manifest.yaml`**;**`access_token` / `expire_in` 刷新时会覆盖同文件字段**,勿将凭证提交版本库。 |
| 6 | |
| 7 | ## 运行依赖 |
| 8 | |
| 9 | - **python3** 与同仓库 `scripts/*.py` |
| 10 | - **无** ffmpeg/ffprobe 门控 |
| 11 | |
| 12 | ## 环境变量与机器可读声明 |
| 13 | |
| 14 | - 环境变量键名与说明:**`manifest.yaml`**(`environment` 段)及本文 |
| 15 | - 变量、凭据、**`permissions.userContent`**(含参考音公网 URL 由蝉镜拉取):**`manifest.yaml`** |
| 16 | |
| 17 | ## 使用命令 |
| 18 | |
| 19 | - **ClawHub**(slug 以注册表为准):`clawhub run chanjing-tts-voice-clone` |
| 20 | - **本仓库**:`python skills/chanjing-tts-voice-clone/scripts/create_voice.py …`(见正文 **How to Use**) |
| 21 | |
| 22 | --- |
| 23 | |
| 24 | ## 登记与审稿(单一事实来源) |
| 25 | |
| 26 | 主凭据、**`expire_in`** 写回与覆盖行为、用户参考音 URL 边界等:**以 `manifest.yaml` 为准**。本篇 **How to Use** 起为 API 步骤与英文接口说明。 |
| 27 | |
| 28 | ## When to Use This Skill |
| 29 | |
| 30 | 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. |
| 31 | |
| 32 | This TTS service supports: |
| 33 | |
| 34 | * bilingual Chinese and English |
| 35 | * adjustment of speech rate |
| 36 | * sentence-level timestamp |
| 37 | |
| 38 | ## How to Use This Skill |
| 39 | |
| 40 | **前置条件(权限验证)**:执行本 Skill 前,必须先通过 **chanjing-credentials-guard** 完成 AK/SK 与 Token 校验。脚本与 guard 使用同一套凭证;无凭证时会执行 `open_login_page.py` 打开注册/登录页。凭据与审稿对表见 **`manifest.yaml`**。 |
| 41 | |
| 42 | ### Security & credentials(引用) |
| 43 | |
| 44 | **Purpose / Credentials / user-supplied reference URL / downloads**:见 **`manifest.yaml`** 中 **`credentials`** 与 **`clientPermissions`**(及合规 **`permissions`**);勿与本节以下 API 文档重复维护表格。 |
| 45 | |
| 46 | Chanjing-TTS-Voice-Clone provides an asynchronous speech synthesis API. |
| 47 | Hostname for all APIs is: "https://open-api.chanjing.cc". |
| 48 | All requests communicate using json. |
| 49 | You should use utf-8 to encode and decode text throughout this task. |
| 50 | |
| 51 | 1. Obtain an access\_token, which is required for subsequent requests |
| 52 | 2. Call the Create Voice API, which accepts a url to an audio file as reference voice |
| 53 | 3. Poll the Query Voice API until the result is success; keep the voice ID |
| 54 | 4. Call the Create Speech Generation Task API, using the voice ID, record the `task_id` |
| 55 | 5. Poll the Query Speech Generation Task Status API until the result is success |
| 56 | 6. When the task status is complete, use the corresponding url in API response to download the generated audio file |
| 57 | |
| 58 | ### Get Access Token API |
| 59 | |
| 60 | 从 `~/.chanjing/credentials.json` 读取 `app_id` 和 `secret_key`,若无有效 Token 则调用: |
| 61 | |
| 62 | ```http |
| 63 | POST /open/v1/access_token |
| 64 | Content-Type: application/json |
| 65 | ``` |
| 66 | |
| 67 | 请求体(使用本地配置的 app_id、secret_key): |
| 68 | |
| 69 | ```json |
| 70 | { |
| 71 | "app_id": "<从 credentials.json 读取>", |
| 72 | "secret_key": "<从 credentials.json 读取>" |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | Response example: |
| 77 | |
| 78 | ```json |
| 79 | { |
| 80 | "trace_id": "8ff3fcd57b33566048ef28568c6cee96", |
| 81 | "code": 0, |
| 82 | "msg": "success", |
| 83 | "data": { |
| 84 | "access_token": "1208CuZcV1Vlzj8MxqbO0kd1Wcl4yxwoHl6pYIzvAGoP3DpwmCCa73zmgR5NCrNu", |
| 85 | "expire_in": 1721289220 |
| 86 | } |
| 87 | } |
| 88 | ``` |
| 89 | |
| 90 | Response field description: |
| 91 | |
| 92 | | First-level Field | Second-level Field | Description | |
| 93 | |---|---|---| |
| 94 | | code | | Response status code | |
| 95 | | msg | | Response message | |
| 96 | | data | | Response data | |
| 97 | | | access\_token | Valid for one day, previous token will be invalidated | |
| 98 | | | expire\_in | Token expiration time | |
| 99 | |
| 100 | Response status code description: |
| 101 | |
| 102 | | code | Description | |
| 103 | |---|---| |
| 104 | | 0 | Success | |
| 105 | | 400 | Parameter format error | |
| 106 | | 40000 | Parameter error | |
| 107 | | 50000 | System internal error | |
| 108 | |
| 109 | ### Create Voice API |
| 110 | |
| 111 | Post to the following endpoint to create a voice. |
| 112 | |
| 113 | ```http |
| 114 | POST /open/v1/create_customised_audio |
| 115 | access_token: {{access_token}} |
| 116 | Content-Type: application/json |
| 117 | ``` |
| 118 | |
| 119 | Request body example: |
| 120 | |
| 121 | ```json |
| 122 | { |
| 123 | "name": "example", |
| 124 | "url": "https://example.com/abc.mp3" |
| 125 | } |
| 126 | ``` |
| 127 | |
| 128 | Request field description: |
| 129 | |
| 130 | | Field | Type | Required | Description | |
| 131 | |---|---|---|---| |
| 132 | | name | string | Yes | A name for this voice | |
| 133 | | 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 | |
| 134 | | model\_type | string | Yes | Use "Cicada3.0-turbo" | |
| 135 | | language | string | No | Either "cn" or "en", default to "cn" | |
| 136 | |
| 137 | Response example: |
| 138 | |
| 139 | ```json |
| 140 | { |
| 141 | "trace_id": "2f0f50951d0bae0a3be3569097305424", |
| 142 | "code": 0, |
| 143 | "msg": "success", |
| 144 | "data": "C-Audio-53e4e53ba1bc40de91ffaa74f20470fc" |
| 145 | } |
| 146 | ``` |
| 147 | |
| 148 | Response field description: |
| 149 | |
| 150 | | Field | Description | |
| 151 | |---|---| |
| 152 | | code | Status Code | |
| 153 | | msg | Message | |
| 154 | | data | Voice ID, to be used in following steps | |
| 155 | |
| 156 | Response status |