# 1. on a dubbed project: confirm the video has a face (runs once, usually automatically)
curl https://api.rask.ai/v2/projects/$ID/lipsync \
-H "Authorization: Bearer $TOKEN"
# "check_face_task_status": "done", "video_has_face": true
# 2. preview one free minute of lip-sync
curl -X PUT https://api.rask.ai/v2/projects/$ID/lipsync \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"is_multiple_speakers": true, "is_free_lipsync": true}'
# 3. lip-sync the full video - billed separately from dubbing
curl -X PUT https://api.rask.ai/v2/projects/$ID/lipsync \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"is_multiple_speakers": true, "is_free_lipsync": false}'# Poll until lipsync_task_status is done, then download lipsync_result_path
while :; do
curl -s https://api.rask.ai/v2/projects/$ID/lipsync -H "Authorization: Bearer $TOKEN" \
| jq '{lipsync_task_status, lipsync_task_progress, tasks_in_lipsync_queue}'
sleep 15
done上传输入的视频或发送公开链接,使用目标语言创建一个项目,然后等待合并完成(merging_done)。唇形同步功能需要该项目的 translated_video。
人脸检查任务可确认视频中至少包含一张人脸。它通常会自动开始。如果尚未开始,请为该项目手动运行一次。
运行唇形同步任务,跟踪 lipsync_task_progress 从 0 到 100 的进度,然后从 lipsync_result_path 下载视频。
# pip install git+ssh://[email protected]/braskai/rask-sdk.git@main
import asyncio
from rask_sdk import clients, enums, schemas
PROJECT_ID = "..." # a project with status merging_done
async def main():
client = clients.RaskSDKClient(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
info = await client.get_lipsync_info(project_id=PROJECT_ID)
if info.check_face_task_status is not enums.LipsyncStatus.DONE:
await client.run_check_face_task(project_id=PROJECT_ID)
while (info := await client.get_lipsync_info(project_id=PROJECT_ID)).check_face_task_status is not enums.LipsyncStatus.DONE:
await asyncio.sleep(10)
if not info.video_has_face:
raise SystemExit("No face found - lip-sync is not available for this video")
await client.run_lipsync_task(project_id=PROJECT_ID,
data=schemas.LipsyncTaskData(is_multiple_speakers=True, is_free_lipsync=False))
while (info := await client.get_lipsync_info(project_id=PROJECT_ID)).lipsync_task_status is not enums.LipsyncStatus.DONE:
print(info.lipsync_task_progress, info.tasks_in_lipsync_queue)
await asyncio.sleep(15)
print(info.lipsync_result_path)
asyncio.run(main())import time, requests
AUTH = "https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token"
URL = f"https://api.rask.ai/v2/projects/{PROJECT_ID}" # a dubbed project
token = requests.post(AUTH, auth=(CLIENT_ID, CLIENT_SECRET),
data={"grant_type": "client_credentials"}).json()["access_token"]
h = {"Authorization": f"Bearer {token}"}
info = requests.get(f"{URL}/lipsync", headers=h).json()
if info["check_face_task_status"] != "done":
requests.put(f"{URL}/check_face", headers=h)
while (info := requests.get(f"{URL}/lipsync", headers=h).json())["check_face_task_status"] != "done":
time.sleep(10)
assert info["video_has_face"], "No face found"
requests.put(f"{URL}/lipsync", headers=h,
json={"is_multiple_speakers": True, "is_free_lipsync": False})
while (info := requests.get(f"{URL}/lipsync", headers=h).json())["lipsync_task_status"] not in ("done", "failed"):
time.sleep(15)
print(info["lipsync_task_status"], info["lipsync_result_path"])// no dependencies, Node 18+ global fetch - PROJECT_ID is a dubbed project
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const auth = await fetch('https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token', {
method: 'POST',
headers: { Authorization: 'Basic ' + btoa(`${CLIENT_ID}:${CLIENT_SECRET}`) },
body: new URLSearchParams({ grant_type: 'client_credentials' }),
}).then((r) => r.json());
const h = { Authorization: `Bearer ${auth.access_token}`, 'Content-Type': 'application/json' };
const url = `https://api.rask.ai/v2/projects/${PROJECT_ID}`;
const info = () => fetch(`${url}/lipsync`, { headers: h }).then((r) => r.json());
let i = await info();
if (i.check_face_task_status !== 'done') {
await fetch(`${url}/check_face`, { method: 'PUT', headers: h });
while ((i = await info()).check_face_task_status !== 'done') await sleep(10000);
}
if (!i.video_has_face) throw new Error('No face found');
await fetch(`${url}/lipsync`, {
method: 'PUT', headers: h,
body: JSON.stringify({ is_multiple_speakers: true, is_free_lipsync: false }),
});
while (!['done', 'failed'].includes((i = await info()).lipsync_task_status)) {
console.log(i.lipsync_task_progress, i.tasks_in_lipsync_queue);
await sleep(15000);
}
console.log(i.lipsync_result_path);# 1. token (valid 1 hour - cache and reuse it)
TOKEN=$(curl -s -X POST https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token \
-u "$CLIENT_ID:$CLIENT_SECRET" -d "grant_type=client_credentials" | jq -r .access_token)
# 2. face check on the dubbed project - start it only if it has not run yet
curl -s https://api.rask.ai/v2/projects/$ID/lipsync -H "Authorization: Bearer $TOKEN" \
| jq '{check_face_task_status, video_has_face}'
curl -s -X PUT https://api.rask.ai/v2/projects/$ID/check_face -H "Authorization: Bearer $TOKEN"
# 3. run lip-sync (set is_free_lipsync to true for the free preview minute)
curl -s -X PUT https://api.rask.ai/v2/projects/$ID/lipsync \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"is_multiple_speakers": true, "is_free_lipsync": false}'
# 4. follow progress, then download the result
curl -s https://api.rask.ai/v2/projects/$ID/lipsync -H "Authorization: Bearer $TOKEN" \
| jq '{lipsync_task_status, lipsync_task_progress, lipsync_result_path}'<?php
use GuzzleHttp\Client;
$http = new Client(['base_uri' => 'https://api.rask.ai']);
$json = fn($r) => json_decode($r->getBody(), true);
$auth = $json((new Client)->post('https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token',
['auth' => [$clientId, $clientSecret], 'form_params' => ['grant_type' => 'client_credentials']]));
$h = ['Authorization' => 'Bearer ' . $auth['access_token']];
$info = fn() => $json($http->get("/v2/projects/$projectId/lipsync", ['headers' => $h]));
$i = $info();
if ($i['check_face_task_status'] !== 'done') {
$http->put("/v2/projects/$projectId/check_face", ['headers' => $h]);
while (($i = $info())['check_face_task_status'] !== 'done') sleep(10);
}
if (!$i['video_has_face']) exit('No face found');
$http->put("/v2/projects/$projectId/lipsync", ['headers' => $h,
'json' => ['is_multiple_speakers' => true, 'is_free_lipsync' => false]]);
while (!in_array(($i = $info())['lipsync_task_status'], ['done', 'failed'])) sleep(15);
echo $i['lipsync_result_path'];check face check_face_task_status done video_has_face true
queued lipsync_task_status started tasks_in_lipsync_queue 2
processing lipsync_task_progress 0 → 50 → 100
complete lipsync_task_status done
lipsync_result_path https://...

es-mx 和 es-es 类似内容。项目记录 glossary_version,因此后续的修改绝不会悄悄改变已完成的工作。有。Rask 口型同步 API 适用于您项目中已完成配音的任何视频。检查视频中是否包含人脸,启动口型同步任务,并在任务完成后下载同步后的视频。身份验证使用 OAuth 2.0 客户端凭据,因此 API 集成方式与 Rask API 的其余部分保持一致。
口型同步基于翻译后的视频运行。请先创建并配音您的项目,当项目拥有 translated_video 链接且状态为 merging_done 时,再启动口型同步。
口型同步使用项目的配音音频。如需使用您自己的措辞,请编辑翻译后的文本或通过您自己的 .srt 创建脚本,重新为项目配音,然后在最新版本上运行口型同步。
Rask 的口型同步功能针对您输入视频中真人说话的真实素材。根据图片或文字提示词生成会说话的虚拟形象、数字人和人工智能视频属于不同的产品类别,人工智能视频生成工具会更适合这些需求。
请使用说话者的脸部清晰可见、光线充足且嘴部无遮挡的素材。避免使用明显的侧脸以及任何遮挡嘴部的物体,例如麦克风、手或字幕。人脸检查用于确认是否存在人脸;您可以使用预览功能来评估素材的处理效果。
每次生成完整视频时,唇形同步与配音分开计费。编辑后如果生成新的唇形同步版本,将会产生另一笔唇形同步费用。
有的。每个账号的免费额度中包含一分钟的免费唇形同步时长。将 is_free_lipsync 设置为 true 来运行任务,即可同步视频的一分钟并进行预览。额度接口中会显示为 lipsync_free_minutes。
支持。当屏幕上可能同时出现不止一张面孔时(例如采访或小组讨论),请将 is_multiple_speakers 设置为 true。如果视频中任何时候都只出现一张面孔,请将其设置为 false 以加快处理速度。
调用 GET /v2/projects/{id}/lipsync。在响应中,lipsync_task_status 会从已开始变为已完成或失败,lipsync_task_progress 会从 0 变为 100,而 tasks_in_lipsync_queue 会显示排在你前面的任务数量。
处理时间取决于视频长度和唇形同步队列。队列位置和进度值可让你向用户准确展示任务当前的状态。
每个配音版本只生成一次唇形同步。更改文本、时间戳、说话者或声音后,请重新为项目配音,等待 merging_done,然后再次运行唇形同步。新的唇形同步生成过程是单独计费的。已完成的面部检查不需要重新运行。
如果 check_face_task_status 或 lipsync_task_status 显示失败,请附上你的 project_id 联系 [email protected],团队会进行核查。
付费套餐已包含 API 访问权限。你可以在应用中生成客户端 ID 和密钥,并立即开始调用。如需企业级条款、大容量定价和定制语言覆盖,请联系我们的团队。