mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-15 15:10:01 +02:00
fix missing spaces between ttml word cues (#2214)
This commit is contained in:
@@ -17,6 +17,18 @@ type ApiStructuredLyric = NonNullable<
|
|||||||
? T
|
? T
|
||||||
: never;
|
: never;
|
||||||
|
|
||||||
|
const getCueTrailingGap = (
|
||||||
|
lineValue: string,
|
||||||
|
byteEnd: number,
|
||||||
|
nextByteStart: number | undefined,
|
||||||
|
): string => {
|
||||||
|
if (nextByteStart === undefined || nextByteStart <= byteEnd + 1) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return sliceUtf8Bytes(lineValue, byteEnd + 1, nextByteStart - 1);
|
||||||
|
};
|
||||||
|
|
||||||
const mapCueWords = (
|
const mapCueWords = (
|
||||||
apiCueLine: NonNullable<ApiStructuredLyric['cueLine']>[number],
|
apiCueLine: NonNullable<ApiStructuredLyric['cueLine']>[number],
|
||||||
): SyncedWordCue[] => {
|
): SyncedWordCue[] => {
|
||||||
@@ -24,11 +36,17 @@ const mapCueWords = (
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiCueLine.cue.map((cue) => ({
|
return apiCueLine.cue.map((cue, cueIndex) => {
|
||||||
endMs: cue.end,
|
const nextCue = apiCueLine.cue?.[cueIndex + 1];
|
||||||
startMs: cue.start,
|
const wordText = cue.value || sliceUtf8Bytes(apiCueLine.value, cue.byteStart, cue.byteEnd);
|
||||||
text: cue.value || sliceUtf8Bytes(apiCueLine.value, cue.byteStart, cue.byteEnd),
|
const trailingGap = getCueTrailingGap(apiCueLine.value, cue.byteEnd, nextCue?.byteStart);
|
||||||
}));
|
|
||||||
|
return {
|
||||||
|
endMs: cue.end,
|
||||||
|
startMs: cue.start,
|
||||||
|
text: wordText + trailingGap,
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapCueLine = (
|
const mapCueLine = (
|
||||||
|
|||||||
Reference in New Issue
Block a user