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.
歌词同步会将歌词文本与音频对齐,使单词在正确的时刻高亮显示。使用 client.projects.syncLyrics(...) 可以在任何项目上重新运行同步,以应用更新后的歌词、不同的模型或新的语言。
client.projects.syncLyrics(projectId, body, options?)
启动一个新的歌词同步操作。
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);
歌词来源
在请求体中传入一个 lyricsSource 对象:
让模型从音频中转写歌词。{
lyricsSource: {
type: "transcribe",
syncModel: "audioshake-transcription",
language: "en",
},
}
传入精确的歌词文本,模型会将其与音频对齐。{
lyricsSource: {
type: "align",
lyrics: "First line\nSecond line\n...",
syncModel: "audioshake-alignment",
language: "en",
},
}
同步模型
对齐模型(在你有准确歌词时与 align 搭配使用):
audioshake-alignment
musicai-alignment
musicai-alignment-subword
转写模型(与 transcribe 搭配使用):
audioshake-transcription
musicai-transcription
wav2vec2
whisper
参考 Sync model reference 获取使用建议。
端到端示例
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");
}
下一步