> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling lip-sync の顔識別

> Kling Lip-Sync API（POST /kling/v1/videos/identify-face）を使用して動画内の顔を検出し、高精度な lip-sync 動画生成ワークフローを実行します。

下流の lip-sync ワークフローを実行する前に、このエンドポイントを使用してソース動画内の顔を識別します。

## このルートが返すもの

* 現在の顔検出結果をグループ化する `session_id`
* 1つ以上の検出された顔を含む `face_data` 配列
* `face_id`、プレビュー画像、時間範囲などの顔ごとのメタデータ

## 使用するタイミング

* ソースは必ず1つだけ送信します: 完了した Kling 動画には `video_id`、ホストされた MP4 または MOV には `video_url`
* 画面上に複数の人物がいる動画の lip-sync リクエストを作成する前
* 自動選択に頼らず、特定の顔を選ぶ必要がある場合
* よりコストの高いタスクを開始する前に、顔の検出範囲をプレビューしたい場合

<Tip>
  完全なパラメータリファレンスについては、[Kling 公式ドキュメント](https://kling.ai/document-api/apiReference/model/lipSync)を参照してください。
</Tip>


## OpenAPI

````yaml api/openapi/video/kling/post-lip-sync.openapi.json POST /kling/v1/videos/identify-face
openapi: 3.1.0
info:
  title: Lip-Sync API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/identify-face:
    post:
      summary: Lip-Sync
      operationId: lip_sync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                video_id:
                  type: string
                  description: >-
                    Kling video id from a completed task. Send either video_id
                    or video_url.
                video_url:
                  type: string
                  description: Public MP4 or MOV URL. Send either video_id or video_url.
              default:
                video_url: https://your-video-host/source.mp4
              oneOf:
                - required:
                    - video_id
                - required:
                    - video_url
            examples:
              Default:
                summary: Identify faces from a video URL
                value:
                  video_url: https://your-video-host/source.mp4
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                  - request_id
                  - data
                properties:
                  code:
                    type: integer
                  message:
                    type: string
                  request_id:
                    type: string
                  data:
                    type: object
                    required:
                      - session_id
                      - face_data
                    properties:
                      session_id:
                        type: string
                      face_data:
                        type: array
                        items:
                          type: object
                          properties:
                            face_id:
                              type: string
                            face_image:
                              type: string
                            start_time:
                              type: integer
                            end_time:
                              type: integer
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/kling/v1/videos/identify-face \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "video_url": "https://your-video-host/source.mp4"
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/identify-face",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "video_url": "https://your-video-host/source.mp4"
                },
            )

            result = response.json()
            print(result.get("code"), result.get("data", {}).get("session_id"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/kling/v1/videos/identify-face", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "video_url": "https://your-video-host/source.mp4"
              }),
            });


            const result = await response.json();

            console.log(result.code, result.data?.session_id);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````