Chanjing Avatar
When to Use This Skill
Use this skill when the user wants to create lip-sync avatar videos with Chanjing Avatar.
Typical uses:
- - create text-driven lip-sync videos from a source avatar video
- create audio-driven lip-sync videos from a source avatar video plus uploaded audio
- upload video or audio assets and obtain INLINECODE0
- create a lip-sync generation task
- poll task status until completion and return the remote video URL
How to Use This Skill
This skill includes its own local configuration and authentication flow.
Local Configuration
This skill reads credentials from:
- - INLINECODE1
- or INLINECODE2
The credentials file should contain:
CODEBLOCK0
Supported environment variables:
- -
CHANJING_CONFIG_DIR: custom local config directory - INLINECODE4 : custom API base URL, default is INLINECODE5
If credentials are missing or invalid, scripts return login guidance with the official Chanjing login URL (no browser auto-open by default):
Optional behavior:
- - set
CHANJING_AUTO_OPEN_LOGIN=1 only when you explicitly want local scripts to try opening the login page in your default browser.
Standard Workflow
All API calls use JSON and UTF-8.
- 1. Read local credentials and obtain a valid INLINECODE8
- Upload the source avatar video and optional driving audio to obtain INLINECODE9
- Create a lip-sync task with either:
- text-driven TTS input, or
- uploaded audio input
- 4. Poll the task status until success or failure
- On success, return the remote video URL from the API response
By default, return the remote video URL only. Do not auto-download the generated video unless the user explicitly asks to save it locally.
Covered APIs
This skill currently covers:
- - INLINECODE10
- INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
Scripts
Scripts are located in scripts/.
| Script | Purpose |
|---|
| INLINECODE17 | write or inspect local app_id / secret_key configuration |
| INLINECODE20 |
read local credentials and print a valid
access_token |
|
_auth.py | read local credentials, fetch or refresh
access_token |
|
get_upload_url | request an upload URL and return
sign_url,
mime_type, and
file_id |
|
upload_file | upload a local file, poll
file_detail until ready, then print
file_id |
|
create_task | create a lip-sync task and print the returned task id |
|
poll_task | poll task status until completion and print the remote
video_url |
Usage Examples
TTS-driven lip-sync
CODEBLOCK1
Audio-driven lip-sync
CODEBLOCK2
API Notes
Access Token
Read app_id and secret_key from the local credentials file. If there is no valid token, request one from:
CODEBLOCK3
Request body:
CODEBLOCK4
Important response fields:
| Field | Description |
|---|
| INLINECODE36 | response status code |
| INLINECODE37 |
response message |
|
data.access_token | valid token for subsequent calls |
|
data.expire_in | token expiration timestamp |
Common status codes:
| Code | Description |
|---|
| INLINECODE40 | success |
| INLINECODE41 |
invalid parameter format |
|
40000 | parameter error |
|
50000 | system internal error |
Upload Media Files
Before creating a lip-sync task, upload the source avatar video and optional driving audio through the File Management API.
Get upload URL
CODEBLOCK5
Query parameters:
| Parameter | Description |
|---|
| INLINECODE44 | use lip_sync_video for avatar video and lip_sync_audio for driving audio |
| INLINECODE47 |
original file name with extension |
The response includes:
- - INLINECODE48
- INLINECODE49
- INLINECODE50
Use the returned sign_url with HTTP PUT to upload the file, and set Content-Type to the returned mime_type.
After upload completes, poll the file detail API until the file is ready:
CODEBLOCK6
Only use the returned file_id for task creation after the file status is ready.
Create Lip-Sync Task
Create a lip-sync task:
CODEBLOCK7
TTS-driven example
CODEBLOCK8
Audio-driven example
CODEBLOCK9
Important request fields:
| Field | Description |
|---|
| INLINECODE56 | uploaded avatar video INLINECODE57 |
| INLINECODE58 |
output width, default
1080 |
|
screen_height | output height, default
1920 |
|
model |
0 basic,
1 high quality |
|
audio_type |
tts or
audio |
|
tts_config.text | text content for TTS-driven mode |
|
tts_config.audio_man_id | voice ID for TTS-driven mode |
|
tts_config.speed | speech speed, range
0.5 to
2 |
|
tts_config.pitch | pitch, usually keep
1 |
|
audio_file_id | uploaded driving audio
file_id for audio-driven mode |
|
callback | optional callback URL |
|
volume | optional volume, range
1 to
100 |
Successful response:
CODEBLOCK10
Important response fields:
| Field | Description |
|---|
| INLINECODE81 | response status code |
| INLINECODE82 |
response message |
|
data | task id used for polling |
Query Task List
List lip-sync tasks:
CODEBLOCK11
Request body:
CODEBLOCK12
Important response fields in each task item:
| Field | Description |
|---|
| INLINECODE84 | task id |
| INLINECODE85 |
0 pending,
10 generating,
20 success,
30 failed |
|
progress | generation progress |
|
msg | task message |
|
video_url | remote generated video URL |
|
preview_url | preview image URL |
|
duration | video duration in ms |
|
create_time | unix timestamp |
Poll Task Detail
Poll task status until completion:
CODEBLOCK13
Query parameter:
| Parameter | Description |
|---|
| INLINECODE96 | task id |
Important response fields:
| Field | Description |
|---|
| INLINECODE97 | task id |
| INLINECODE98 |
0 pending,
10 generating,
20 success,
30 failed |
|
data.progress | progress
0-100 |
|
data.msg | task message |
|
data.video_url | remote video URL |
|
data.preview_url | preview image URL |
|
data.duration | video duration in ms |
|
data.create_time | unix timestamp |
Callback Notification
If a callback URL is provided, the system may send a POST request after task completion with the same task detail payload shape.
Output Convention
Default behavior:
- - return the remote video URL from INLINECODE110
- return task status and progress when polling
- do not auto-download the generated file unless the user explicitly asks
禅境数字人
何时使用此技能
当用户想要使用禅境数字人创建唇形同步数字人视频时,使用此技能。
典型用途:
- - 从源数字人视频创建文本驱动的唇形同步视频
- 从源数字人视频加上上传的音频创建音频驱动的唇形同步视频
- 上传视频或音频资源并获取file_id
- 创建唇形同步生成任务
- 轮询任务状态直至完成并返回远程视频URL
如何使用此技能
此技能包含自身的本地配置和认证流程。
本地配置
此技能从以下位置读取凭证:
- - ~/.chanjing/credentials.json
- 或 $CHANJINGCONFIGDIR/credentials.json
凭证文件应包含:
json
{
app_id: <你的应用ID>,
secret_key: <你的密钥>
}
支持的环境变量:
- - CHANJINGCONFIGDIR:自定义本地配置目录
- CHANJINGAPIBASE:自定义API基础URL,默认为https://open-api.chanjing.cc
如果凭证缺失或无效,脚本将返回带有官方禅境登录URL的登录指引(默认不自动打开浏览器):
- - https://www.chanjing.cc/openapi/login
可选行为:
- - 仅当您明确希望本地脚本尝试在默认浏览器中打开登录页面时,设置CHANJINGAUTOOPEN_LOGIN=1。
标准工作流程
所有API调用使用JSON和UTF-8编码。
- 1. 读取本地凭证并获取有效的accesstoken
- 上传源数字人视频和可选的驱动音频以获取fileid
- 使用以下任一方式创建唇形同步任务:
- 文本驱动的TTS输入,或
- 上传的音频输入
- 4. 轮询任务状态直至成功或失败
- 成功后,从API响应返回远程视频URL
默认情况下,仅返回远程视频URL。除非用户明确要求保存到本地,否则不要自动下载生成的视频。
涵盖的API
此技能目前涵盖:
- - POST /open/v1/accesstoken
- GET /open/v1/common/createuploadurl
- GET /open/v1/common/filedetail
- POST /open/v1/videolipsync/create
- POST /open/v1/videolipsync/list
- GET /open/v1/videolipsync/detail
脚本
脚本位于scripts/目录。
| 脚本 | 用途 |
|---|
| chanjing-config | 写入或检查本地appid/secretkey配置 |
| chanjing-get-token |
读取本地凭证并打印有效的access_token |
|
auth.py | 读取本地凭证,获取或刷新accesstoken |
| get
uploadurl | 请求上传URL并返回sign
url、mimetype和file_id |
| upload
file | 上传本地文件,轮询filedetail直至就绪,然后打印file_id |
| create_task | 创建唇形同步任务并打印返回的任务ID |
| poll
task | 轮询任务状态直至完成并打印远程videourl |
使用示例
TTS驱动的唇形同步
bash
0. 配置凭证
python scripts/chanjing-config \
--ak <你的应用ID> \
--sk <你的密钥>
1. 上传源视频并获取视频文件ID
VIDEO
FILEID=$(python scripts/upload_file \
--service lip
syncvideo \
--file ./my_video.mp4)
2. 创建TTS驱动的唇形同步任务
TASK
ID=$(python scripts/createtask \
--video-file-id $VIDEO
FILEID \
--text 君不见黄河之水天上来 \
--audio-man-id C-f2429d07554749839849497589199916)
3. 轮询直至完成并获取远程视频URL
python scripts/poll
task --id $TASKID
音频驱动的唇形同步
bash
1. 上传源视频
VIDEO
FILEID=$(python scripts/upload_file \
--service lip
syncvideo \
--file ./my_video.mp4)
2. 上传驱动音频
AUDIO
FILEID=$(python scripts/upload_file \
--service lip
syncaudio \
--file ./my_audio.wav)
3. 创建音频驱动的唇形同步任务
TASK
ID=$(python scripts/createtask \
--video-file-id $VIDEO
FILEID \
--audio-file-id $AUDIO
FILEID)
4. 轮询直至完成并获取远程视频URL
python scripts/poll
task --id $TASKID
API说明
访问令牌
从本地凭证文件中读取appid和secretkey。如果没有有效的令牌,则从以下接口请求:
http
POST /open/v1/access_token
Content-Type: application/json
请求体:
json
{
app_id: <来自本地凭证>,
secret_key: <来自本地凭证>
}
重要响应字段:
响应消息 |
| data.access_token | 用于后续调用的有效令牌 |
| data.expire_in | 令牌过期时间戳 |
常见状态码:
无效的参数格式 |
| 40000 | 参数错误 |
| 50000 | 系统内部错误 |
上传媒体文件
在创建唇形同步任务之前,通过文件管理API上传源数字人视频和可选的驱动音频。
获取上传URL
http
GET /open/v1/common/createuploadurl
accesstoken: {{accesstoken}}
查询参数:
| 参数 | 描述 |
|---|
| service | 数字人视频使用lipsyncvideo,驱动音频使用lipsyncaudio |
| name |
带扩展名的原始文件名 |
响应包含:
使用返回的signurl配合HTTP PUT方法上传文件,并将Content-Type设置为返回的mimetype。
上传完成后,轮询文件详情API直至文件就绪:
http
GET /open/v1/common/filedetail?id={{fileid}}
accesstoken: {{accesstoken}}
仅在文件状态就绪后,才能使用返回的file_id创建任务。
创建唇形同步任务
创建唇形同步任务:
http
POST /open/v1/videolipsync/create
accesstoken: {{accesstoken}}
Content-Type: application/json
TTS驱动示例
json
{
videofileid: e284db4d95de4220afe78132158156b5,
screen_width: 1080,
screen_height: 1920,
model: 0,
audio_type: tts,
tts_config: {
text: 君不见黄河之水天上来,奔流到海不复回。,
audiomanid: C-f2429d07554749839849497589199916,
speed: 1,
pitch: 1
}
}
音频驱动示例
json
{
videofileid: e284db4d95de4220afe78132158156b5,
screen_width: 1080,
screen_height: 1920,
model: 0,
audio_type: audio,
audiofileid: 来自文件管理的音频文件ID
}
重要请求字段:
| 字段 | 描述 |
|---|
| videofileid | 上传的数字人视频fileid |
| screenwidth |
输出宽度,默认为1080 |
| screen_height | 输出高度,默认为1920 |
| model | 0基础版,1高清版 |
| audio_type | tts或audio |
| tts_config.text | TTS驱动模式的文本内容 |
| tts
config.audioman_id | TTS驱动模式的语音ID |
| tts_config.speed | 语速,范围0.5到2 |
| tts_config.pitch | 音调,通常保持1 |
| audio
fileid | 音频驱动模式下上传的驱动音频file_id |
| callback | 可选的回调URL |
| volume | 可选的音量,范围1到100 |
成功响应:
json
{
trace_id: 8d10659438827bd4d59eaa