diff --git a/packages/core/components/lyrics/lyricLine.svelte b/packages/core/components/lyrics/lyricLine.svelte
index 3313778..6c246b3 100644
--- a/packages/core/components/lyrics/lyricLine.svelte
+++ b/packages/core/components/lyrics/lyricLine.svelte
@@ -4,8 +4,6 @@
import type { LyricPos } from './type';
import type { Spring } from '@core/graphics/spring/spring';
- const viewportWidth = document.documentElement.clientWidth;
-
export let line: ScriptItem;
export let index: number;
export let debugMode: Boolean;
@@ -150,25 +148,14 @@
{/if}
{line.text}
{#if line.translation}
-
+
{line.translation}
{/if}
-
-
diff --git a/packages/core/lyrics/ttml/index.ts b/packages/core/lyrics/ttml/index.ts
index 0c52a3b..58bddce 100644
--- a/packages/core/lyrics/ttml/index.ts
+++ b/packages/core/lyrics/ttml/index.ts
@@ -1,6 +1,7 @@
import type { LrcJsonData } from '../type';
import { parseTTML as ttmlParser } from './parser';
import type { LyricLine } from './ttml-types';
+
export * from './writer';
export type * from './ttml-types';
@@ -9,11 +10,22 @@ export function parseTTML(text: string) {
const lyricLines = ttmlParser(text).lyricLines;
lyrics = {
scripts: lyricLines.map((value: LyricLine, index: number, array: LyricLine[]) => {
+ let words = value.words.length == 0 ? undefined : value.words;
+ if (words) {
+ words = words.map((word) => {
+ let r = word;
+ r.startTime /= 1000;
+ r.endTime /= 1000;
+ return r;
+ });
+ }
return {
text: value.words.map((word) => word.word).join(''),
start: value.startTime / 1000,
end: value.endTime / 1000,
- translation: value.translatedLyric || undefined
+ translation: value.translatedLyric || undefined,
+ singer: value.singer || undefined,
+ words: words
};
})
};
diff --git a/packages/core/lyrics/ttml/parser.ts b/packages/core/lyrics/ttml/parser.ts
index c26701f..71d2a01 100644
--- a/packages/core/lyrics/ttml/parser.ts
+++ b/packages/core/lyrics/ttml/parser.ts
@@ -78,6 +78,7 @@ export function parseTTML(ttmlText: string): TTMLLyric {
lineEl.getAttribute("ttm:agent") !== mainAgentId,
startTime: 0,
endTime: 0,
+ singer: ""
};
if (isBG) line.isDuet = isDuet;
let haveBg = false;
@@ -101,6 +102,8 @@ export function parseTTML(ttmlText: string): TTMLLyric {
line.translatedLyric = wordEl.innerHTML;
} else if (role === "x-roman") {
line.romanLyric = wordEl.innerHTML;
+ } else if (role === "x-singer") {
+ line.singer = wordEl.innerHTML;
}
} else if (wordEl.hasAttribute("begin") && wordEl.hasAttribute("end")) {
const word: LyricWord = {
diff --git a/packages/core/lyrics/ttml/ttml-types.ts b/packages/core/lyrics/ttml/ttml-types.ts
index 644a870..a79de9f 100644
--- a/packages/core/lyrics/ttml/ttml-types.ts
+++ b/packages/core/lyrics/ttml/ttml-types.ts
@@ -23,4 +23,5 @@ export interface LyricLine {
isDuet: boolean;
startTime: number;
endTime: number;
+ singer: string;
}
diff --git a/packages/web/src/app.html b/packages/web/src/app.html
index 7d5373c..ca14725 100644
--- a/packages/web/src/app.html
+++ b/packages/web/src/app.html
@@ -12,8 +12,4 @@
%sveltekit.body%
-