lgtm
This commit is contained in:
parent
8708bf000d
commit
11711c57e6
38 changed files with 5361 additions and 265 deletions
|
|
@ -25,6 +25,7 @@ export interface RunnerResult {
|
|||
const MAP_ZOOM_WHEEL_DELTA = -120;
|
||||
const FALLBACK_MS_PER_WORD = 750;
|
||||
const FALLBACK_TAIL_BUFFER_MS = 800;
|
||||
const CJK_CHARS_PER_FALLBACK_WORD = 2;
|
||||
|
||||
interface SynthCue {
|
||||
cueIndex: number;
|
||||
|
|
@ -266,10 +267,15 @@ function loadSynthIndex(storyboard: Storyboard): SynthCue[] {
|
|||
return storyboard.cues.map((cue, cueIndex) => ({
|
||||
cueIndex,
|
||||
text: cue.text,
|
||||
durationMs:
|
||||
cue.text.split(/\s+/).filter(Boolean).length * FALLBACK_MS_PER_WORD +
|
||||
FALLBACK_TAIL_BUFFER_MS,
|
||||
durationMs: estimateFallbackDurationMs(cue.text),
|
||||
}));
|
||||
}
|
||||
|
||||
function estimateFallbackDurationMs(text: string): number {
|
||||
const wordCount = text.split(/\s+/).filter(Boolean).length;
|
||||
const cjkCount = text.match(/\p{Script=Han}/gu)?.length ?? 0;
|
||||
const units = Math.max(wordCount, Math.ceil(cjkCount / CJK_CHARS_PER_FALLBACK_WORD), 1);
|
||||
return units * FALLBACK_MS_PER_WORD + FALLBACK_TAIL_BUFFER_MS;
|
||||
}
|
||||
|
||||
export type { Page };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue