fix: romaji duplicate lines for non-Japanese lyrics (#2188)

This commit is contained in:
York authored and GitHub committed 2026-06-29 19:11:46 -07:00
1 parent aa3c9251f5
commit a221a84792
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -42,13 +42,13 @@ export const convertFurigana = async (text: string): Promise<string> => {
export const convertRomaji = async (text: string): Promise<string> => {
const KuroshiroClass = (Kuroshiro as any).default || Kuroshiro;
if (!KuroshiroClass.Util.hasKana(text)) return text;
if (!KuroshiroClass.Util.hasKana(text)) return '';
try {
const kuroshiro = await getKuroshiro();
return await kuroshiro.convert(text, { mode: 'spaced', to: 'romaji' });
} catch (e) {
console.error('Romaji conversion error: ', e);
return text;
return '';
}
};
@@ -43,7 +43,7 @@ export const useRomajiLyrics = (lyrics: LyricsResponse | null | undefined, enabl
const convertedLines = converted.split('\n');
return lyrics.map(([time], i) => [
time,
convertedLines[i] ?? lyrics[i][1],
convertedLines[i] ?? '',
]) as SynchronizedLyricsArray;
}
return lyrics;