Kling
Kling の高度なリップシンクタスクを作成する
CometAPI Kling POST /kling/v1/videos/advanced-lip-sync を介して高度なリップシンク動画タスクを作成し、音声と対象設定を送信して同期済みの結果を生成します。
POST
/
kling
/
v1
/
videos
/
advanced-lip-sync
cURL
curl https://api.cometapi.com/kling/v1/videos/advanced-lip-sync \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "<session_id>",
"face_choose": [
{
"face_id": "<face_id>",
"sound_file": "https://your-audio-host/speech.wav",
"sound_start_time": "0",
"sound_end_time": "2000",
"sound_insert_time": "0",
"sound_volume": 1,
"original_sound_volume": 0
}
]
}'
import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/advanced-lip-sync",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"session_id": "<session_id>",
"face_choose": [
{
"face_id": "<face_id>",
"sound_file": "https://your-audio-host/speech.wav",
"sound_start_time": "0",
"sound_end_time": "2000",
"sound_insert_time": "0",
"sound_volume": 1,
"original_sound_volume": 0
}
]
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/advanced-lip-sync", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"session_id": "<session_id>",
"face_choose": [
{
"face_id": "<face_id>",
"sound_file": "https://your-audio-host/speech.wav",
"sound_start_time": "0",
"sound_end_time": "2000",
"sound_insert_time": "0",
"sound_volume": 1,
"original_sound_volume": 0
}
]
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/advanced-lip-sync",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'session_id' => '<session_id>',
'face_choose' => [
[
'face_id' => '<face_id>',
'sound_file' => 'https://your-audio-host/speech.wav',
'sound_start_time' => '0',
'sound_end_time' => '2000',
'sound_insert_time' => '0',
'sound_volume' => 1,
'original_sound_volume' => 0
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/advanced-lip-sync"
payload := strings.NewReader("{\n \"session_id\": \"<session_id>\",\n \"face_choose\": [\n {\n \"face_id\": \"<face_id>\",\n \"sound_file\": \"https://your-audio-host/speech.wav\",\n \"sound_start_time\": \"0\",\n \"sound_end_time\": \"2000\",\n \"sound_insert_time\": \"0\",\n \"sound_volume\": 1,\n \"original_sound_volume\": 0\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/advanced-lip-sync")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"<session_id>\",\n \"face_choose\": [\n {\n \"face_id\": \"<face_id>\",\n \"sound_file\": \"https://your-audio-host/speech.wav\",\n \"sound_start_time\": \"0\",\n \"sound_end_time\": \"2000\",\n \"sound_insert_time\": \"0\",\n \"sound_volume\": 1,\n \"original_sound_volume\": 0\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/advanced-lip-sync")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"<session_id>\",\n \"face_choose\": [\n {\n \"face_id\": \"<face_id>\",\n \"sound_file\": \"https://your-audio-host/speech.wav\",\n \"sound_start_time\": \"0\",\n \"sound_end_time\": \"2000\",\n \"sound_insert_time\": \"0\",\n \"sound_volume\": 1,\n \"original_sound_volume\": 0\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"task_id": "<string>",
"task_status": "<string>",
"created_at": 123,
"updated_at": 123
}
}このエンドポイントは、ソース動画内の顔をすでに特定した後に、高度なリップシンクタスクを作成するために使用します。
呼び出す前に
session_idと利用可能なface_idの値を取得するため、まず Lip-Sync から開始します- 各顔を音声セグメントに対応付ける
face_chooseエントリを 1 つ以上構築します - 以前のタスクで生成された音声には
audio_idを、ホストされた音声ファイルにはsound_fileを使用します - タイミング関連のフィールドはミリ秒単位で送信します。たとえば、
sound_start_time: "0"とsound_end_time: "2000"は最初の 2 秒を選択します。 - 切り出した音声セグメントは少なくとも 2000 ms 以上で、かつ元の音声の長さを超えないようにしてください
- Webhook 配信または独自の追跡 id が必要な場合にのみ、
callback_urlまたはexternal_task_idを設定します
タスクフロー
1
最初に顔を特定する
ソース動画に対して Lip-Sync を実行し、返された
session_id と対象の face_id の値を保持します。2
高度なリップシンクタスクを作成する
このエンドポイントを通じて
session_id と face_choose 配列を送信します。3
生成されたタスクを追跡する
ステータス確認と最終結果の取得のために、返された task id を保存します。
完全なパラメータリファレンスについては、official Kling documentation を参照してください。
承認
Bearer token authentication. Use your CometAPI key.
ボディ
application/json
Session id returned by identify-face.
One or more face/audio mappings to synthesize.
Minimum array length:
1Show child attributes
Show child attributes
Webhook URL to receive task status updates.
Custom task id for your own tracking. Must be unique per account.
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/advanced-lip-sync \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "<session_id>",
"face_choose": [
{
"face_id": "<face_id>",
"sound_file": "https://your-audio-host/speech.wav",
"sound_start_time": "0",
"sound_end_time": "2000",
"sound_insert_time": "0",
"sound_volume": 1,
"original_sound_volume": 0
}
]
}'
import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/advanced-lip-sync",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"session_id": "<session_id>",
"face_choose": [
{
"face_id": "<face_id>",
"sound_file": "https://your-audio-host/speech.wav",
"sound_start_time": "0",
"sound_end_time": "2000",
"sound_insert_time": "0",
"sound_volume": 1,
"original_sound_volume": 0
}
]
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/advanced-lip-sync", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"session_id": "<session_id>",
"face_choose": [
{
"face_id": "<face_id>",
"sound_file": "https://your-audio-host/speech.wav",
"sound_start_time": "0",
"sound_end_time": "2000",
"sound_insert_time": "0",
"sound_volume": 1,
"original_sound_volume": 0
}
]
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/advanced-lip-sync",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'session_id' => '<session_id>',
'face_choose' => [
[
'face_id' => '<face_id>',
'sound_file' => 'https://your-audio-host/speech.wav',
'sound_start_time' => '0',
'sound_end_time' => '2000',
'sound_insert_time' => '0',
'sound_volume' => 1,
'original_sound_volume' => 0
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/advanced-lip-sync"
payload := strings.NewReader("{\n \"session_id\": \"<session_id>\",\n \"face_choose\": [\n {\n \"face_id\": \"<face_id>\",\n \"sound_file\": \"https://your-audio-host/speech.wav\",\n \"sound_start_time\": \"0\",\n \"sound_end_time\": \"2000\",\n \"sound_insert_time\": \"0\",\n \"sound_volume\": 1,\n \"original_sound_volume\": 0\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/advanced-lip-sync")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"<session_id>\",\n \"face_choose\": [\n {\n \"face_id\": \"<face_id>\",\n \"sound_file\": \"https://your-audio-host/speech.wav\",\n \"sound_start_time\": \"0\",\n \"sound_end_time\": \"2000\",\n \"sound_insert_time\": \"0\",\n \"sound_volume\": 1,\n \"original_sound_volume\": 0\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/advanced-lip-sync")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"<session_id>\",\n \"face_choose\": [\n {\n \"face_id\": \"<face_id>\",\n \"sound_file\": \"https://your-audio-host/speech.wav\",\n \"sound_start_time\": \"0\",\n \"sound_end_time\": \"2000\",\n \"sound_insert_time\": \"0\",\n \"sound_volume\": 1,\n \"original_sound_volume\": 0\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"task_id": "<string>",
"task_status": "<string>",
"created_at": 123,
"updated_at": 123
}
}