Kling
Kling 고급 립싱크 작업 생성
CometAPI Kling POST /kling/v1/videos/advanced-lip-sync를 통해 고급 립싱크 비디오 작업을 생성하고, 오디오와 counterpart 설정을 제출해 동기화된 결과를 생성합니다.
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
}
}소스 비디오에서 얼굴을 이미 식별한 후 이 엔드포인트를 사용해 고급 립싱크 작업을 생성합니다.
호출 전에 준비할 것
- Lip-Sync로 시작해
session_id와 사용 가능한face_id값을 가져옵니다 - 각 얼굴을 오디오 세그먼트에 매핑하는 하나 이상의
face_choose항목을 구성합니다 - 이전 작업에서 생성된 오디오에는
audio_id를 사용하고, 호스팅된 오디오 파일에는sound_file을 사용합니다 - 타이밍 필드는 밀리초 단위로 전송합니다. 예를 들어
sound_start_time: "0"및sound_end_time: "2000"은 처음 2초를 선택합니다. - 잘라낸 오디오 세그먼트는 최소 2000ms 이상이어야 하며 소스 오디오 길이를 초과하면 안 됩니다
- 웹훅 전달이나 자체 추적 id가 필요할 때만
callback_url또는external_task_id를 설정합니다
작업 흐름
1
먼저 얼굴 식별
소스 비디오에서 Lip-Sync를 실행하고 반환된
session_id와 대상 face_id 값을 보관합니다.2
고급 립싱크 작업 생성
이 엔드포인트를 통해
session_id와 face_choose 배열을 제출합니다.3
생성된 작업 추적
상태 확인 및 최종 결과 조회를 위해 반환된 작업 id를 저장합니다.
전체 파라미터 참조는 Kling 공식 문서를 확인하세요.
인증
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
}
}