Skip to content

Commit

Permalink
Fix: MusicXML・UST読み込み時に歌詞のtrimを行うようにする (VOICEVOX#1988)
Browse files Browse the repository at this point in the history
MusicXML・UST読み込み時にtrimを行うようにした
  • Loading branch information
sigprogramming committed Apr 25, 2024
1 parent 11979f4 commit c6a6403
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,8 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
}

const lyricElement = getChild(noteElement, "lyric");
const lyric = getChild(lyricElement, "text")?.textContent ?? "";
let lyric = getChild(lyricElement, "text")?.textContent ?? "";
lyric = lyric.trim();

let tie = getTie(noteElement);
for (const childElement of noteElement.children) {
Expand Down Expand Up @@ -1995,10 +1996,11 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
if (tempo) tempos.push({ position, bpm: tempo });
const noteNumber = Number(params["NoteNum"]);
const duration = Number(params["Length"]);
let lyric = params["Lyric"].trim();
// 歌詞の前に連続音が含まれている場合は除去
const lyric = params["Lyric"].includes(" ")
? params["Lyric"].split(" ")[1]
: params["Lyric"];
if (lyric.includes(" ")) {
lyric = lyric.split(" ")[1];
}
// 休符であればポジションを進めるのみ
if (lyric === "R") {
position += duration;
Expand Down

0 comments on commit c6a6403

Please sign in to comment.