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

# Đồng bộ lời bài hát

> Chạy lại đồng bộ lời bài hát trên một dự án hiện có

Đồng bộ lời bài hát (lyrics sync) căn chỉnh văn bản lời theo audio để các từ được tô sáng đúng thời điểm. Dùng `client.projects.syncLyrics(...)` để chạy lại đồng bộ cho bất kỳ dự án nào khi bạn đã cập nhật lời, muốn dùng model khác, hoặc đổi ngôn ngữ.

## `client.projects.syncLyrics(projectId, body, options?)`

Bắt đầu một thao tác đồng bộ lời bài hát mới.

```ts theme={null}
const operation = await client.projects.syncLyrics("prj_abc123", {
  lyricsSource: {
    type: "align",
    lyrics: "First line\nSecond line\n...",
    syncModel: "audioshake-alignment",
  },
});

const { project } = await client.projects.wait(operation);
console.log(project.alignments);
```

### Nguồn lời bài hát

Truyền một object `lyricsSource` trong body của request:

<Tabs>
  <Tab title="transcribe">
    Để model tự phiên âm lời bài hát từ audio.

    ```ts theme={null}
    {
      lyricsSource: {
        type: "transcribe",
        syncModel: "audioshake-transcription",
        language: "en",
      },
    }
    ```
  </Tab>

  <Tab title="align">
    Truyền lời bài hát chính xác. Model sẽ căn chỉnh chúng theo audio.

    ```ts theme={null}
    {
      lyricsSource: {
        type: "align",
        lyrics: "First line\nSecond line\n...",
        syncModel: "audioshake-alignment",
        language: "en",
      },
    }
    ```
  </Tab>
</Tabs>

### Các model đồng bộ

**Model căn chỉnh** (dùng với `align` khi bạn có lời bài hát chính xác):

* `audioshake-alignment`
* `musicai-alignment`
* `musicai-alignment-subword`
* `wav2vec2`

**Model phiên âm** (dùng với `transcribe`):

* `audioshake-transcription`
* `elevenlabs-transcription`
* `musicai-transcription`
* `whisper`

Xem [Choose a lyrics sync model](/vi/web/lyrics-sync-models) để được hướng dẫn.

## Ví dụ end-to-end

```ts theme={null}
import { YoukaClient } from "@youka/sdk";
import { readFile } from "node:fs/promises";

const client = new YoukaClient({ apiKey: process.env.YOUKA_API_KEY! });

async function reAlignLyrics(projectId: string) {
  const lyrics = await readFile("./lyrics.txt", "utf8");

  const operation = await client.projects.syncLyrics(projectId, {
    lyricsSource: {
      type: "align",
      lyrics,
      syncModel: "audioshake-alignment",
      language: "en",
    },
  });

  const { project } = await client.projects.wait(operation);
  console.log("Updated lyrics with", project.lyrics?.length, "lines");
}
```

## Tiếp theo

* [Stems](/vi/sdk/stems) — chạy lại tách stem trước khi đồng bộ lại
* [Tasks](/vi/sdk/tasks) — handle thao tác và các mẫu hủy (abort)
* [Choose a lyrics sync model](/vi/web/lyrics-sync-models) — chọn đúng model
