Join two adjacent tokens, omitting the space across a CJK boundary.
(left: string, right: string)
| 358 | |
| 359 | /** Join two adjacent tokens, omitting the space across a CJK boundary. */ |
| 360 | function joinTokens(left: string, right: string): string { |
| 361 | const a = left.at(-1) ?? ""; |
| 362 | const b = right[0] ?? ""; |
| 363 | const sep = CJK_CHAR.test(a) || CJK_CHAR.test(b) ? "" : " "; |
| 364 | return `${left}${sep}${right}`; |
| 365 | } |
| 366 | |
| 367 | export function wordsToCues(words: Word[], opts: WordsToCuesOptions = {}): Cue[] { |
| 368 | // Phrase-level transcripts (imported .srt/.vtt cues) must keep their existing |