Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix: address PR review for auto captions and locales
parse-nip2b7e6f1677db
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsxindex e96202ac9..2edf90dc9 100644--- a/src/components/video-editor/VideoEditor.tsx+++ b/src/components/video-editor/VideoEditor.tsx@@ -1022,6 +1022,9 @@ export default function VideoEditor() {const handleAnnotationSpanChange = useCallback((id: string, span: Span) => {pushState((prev) => {+ const editedAutoCaption =+ prev.annotationRegions.find((region) => region.id === id)?.annotationSource ===+ "auto-caption";const next = prev.annotationRegions.map((region) =>region.id === id? {@@ -1032,7 +1035,7 @@ export default function VideoEditor() {: region,);return {- annotationRegions: reconcileAutoCaptionTimelineGaps(next),+ annotationRegions: editedAutoCaption ? reconcileAutoCaptionTimelineGaps(next) : next,};});},@@ -1831,6 +1834,7 @@ export default function VideoEditor() {...transcribeOptions,},);+ let transcribedFromTrimmedBuffer = true;// Some recordings come back empty after leading-silence trimming even though the full// source has recognizable speech. Retry once against the untouched audio buffer before@@ -1840,10 +1844,11 @@ export default function VideoEditor() {trimRegions,...transcribeOptions,}));+ transcribedFromTrimmedBuffer = false;}const segments =- trimSec > 0+ transcribedFromTrimmedBuffer && trimSec > 0? segmentsRaw.map((s) => ({...s,startSec: s.startSec + trimSec,diff --git a/src/i18n/locales/ar/editor.json b/src/i18n/locales/ar/editor.jsonindex d0f99ed60..35ba08b23 100644--- a/src/i18n/locales/ar/editor.json+++ b/src/i18n/locales/ar/editor.json@@ -43,21 +43,21 @@"permissionDenied": "تم رفض إذن التسجيل. يرجى السماح بتسجيل الشاشة."},"autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "التسميات التوضيحية التلقائية",+ "dialogTitle": "التسميات التوضيحية التلقائية",+ "dialogDescription": "اختر تقريبا كم عدد الكلمات التي تظهر في كل تسمية توضيحية. يتم توزيع التوقيت عبر الكلمات في تلك العبارة.",+ "minWords": "الحد الأدنى من الكلمات لكل تسمية",+ "maxWords": "الحد الأقصى من الكلمات لكل تسمية",+ "wordsCount": "{{count}} كلمة",+ "generate": "توليد",+ "dialogCancel": "إلغاء",+ "generating": "جارٍ توليد التسميات من الصوت…",+ "loadingModel": "جارٍ تحميل نموذج الكلام (سيتم تنزيل ~75 ميغابايت عند الاستخدام الأول)…",+ "busy": "توليد التسميات قيد التنفيذ بالفعل.",+ "done": "تمت إضافة {{count}} تسمية.",+ "noneHeard": "لم يتم الكشف عن أي كلام.",+ "noAudio": "لا يحتوي هذا الفيديو على صوت صالح للنسخ.",+ "failed": "تعذّر توليد التسميات.",+ "truncated": "تم نسخ الدقائق الأولى فقط: {{minutes}} دقيقة."}}diff --git a/src/i18n/locales/es/editor.json b/src/i18n/locales/es/editor.jsonindex 64faff9e7..c7a2c2aff 100644--- a/src/i18n/locales/es/editor.json+++ b/src/i18n/locales/es/editor.json@@ -43,21 +43,21 @@"confirm": "Confirmar"},"autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "Subtítulos automáticos",+ "dialogTitle": "Subtítulos automáticos",+ "dialogDescription": "Elige aproximadamente cuántas palabras muestra cada subtítulo a la vez. El tiempo se reparte entre las palabras de esa frase.",+ "minWords": "Número mínimo de palabras por subtítulo",+ "maxWords": "Número máximo de palabras por subtítulo",+ "wordsCount": "{{count}} palabras",+ "generate": "Generar",+ "dialogCancel": "Cancelar",+ "generating": "Generando subtítulos a partir del audio…",+ "loadingModel": "Cargando el modelo de voz (el primer uso descarga ~75 MB)…",+ "busy": "La generación de subtítulos ya está en curso.",+ "done": "Se añadieron {{count}} subtítulos.",+ "noneHeard": "No se detectó voz.",+ "noAudio": "Este video no tiene audio utilizable para transcribir.",+ "failed": "No se pudieron generar los subtítulos.",+ "truncated": "Solo se transcribieron los primeros {{minutes}} minutos."}}diff --git a/src/i18n/locales/fr/editor.json b/src/i18n/locales/fr/editor.jsonindex 4137a7035..e1acdc741 100644--- a/src/i18n/locales/fr/editor.json+++ b/src/i18n/locales/fr/editor.json@@ -43,21 +43,21 @@},"loadingVideo": "Chargement de la vidéo...","autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "Sous-titres automatiques",+ "dialogTitle": "Sous-titres automatiques",+ "dialogDescription": "Choisissez approximativement combien de mots chaque sous-titre affiche à la fois. Le timing est réparti entre les mots de cette phrase.",+ "minWords": "Nombre minimum de mots par sous-titre",+ "maxWords": "Nombre maximum de mots par sous-titre",+ "wordsCount": "{{count}} mots",+ "generate": "Générer",+ "dialogCancel": "Annuler",+ "generating": "Génération des sous-titres à partir de l'audio…",+ "loadingModel": "Chargement du modèle vocal (le premier usage télécharge ~75 MB)…",+ "busy": "La génération des sous-titres est déjà en cours.",+ "done": "{{count}} sous-titres ajoutés.",+ "noneHeard": "Aucune parole n'a été détectée.",+ "noAudio": "Cette vidéo ne contient pas d'audio exploitable pour la transcription.",+ "failed": "Impossible de générer les sous-titres.",+ "truncated": "Seules les {{minutes}} premières minutes ont été transcrites."}}diff --git a/src/i18n/locales/ja-JP/editor.json b/src/i18n/locales/ja-JP/editor.jsonindex e488dadc8..fb755db6a 100644--- a/src/i18n/locales/ja-JP/editor.json+++ b/src/i18n/locales/ja-JP/editor.json@@ -43,21 +43,21 @@"cameraNotFound": "カメラが見つかりません。"},"autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "自動キャプション",+ "dialogTitle": "自動キャプション",+ "dialogDescription": "各キャプションに一度に表示する語数の目安を選びます。タイミングはそのフレーズ内の語に分配されます。",+ "minWords": "キャプションあたりの最小語数",+ "maxWords": "キャプションあたりの最大語数",+ "wordsCount": "{{count}} 語",+ "generate": "生成",+ "dialogCancel": "キャンセル",+ "generating": "音声からキャプションを生成しています…",+ "loadingModel": "音声モデルを読み込んでいます(初回利用時は約 75 MB をダウンロードします)…",+ "busy": "キャプションの生成はすでに実行中です。",+ "done": "{{count}} 件のキャプションを追加しました。",+ "noneHeard": "音声が検出されませんでした。",+ "noAudio": "この動画には書き起こしに使える音声がありません。",+ "failed": "キャプションを生成できませんでした。",+ "truncated": "最初の {{minutes}} 分のみが書き起こされました。"}}diff --git a/src/i18n/locales/ko-KR/editor.json b/src/i18n/locales/ko-KR/editor.jsonindex 2c57b9c13..51712b22f 100644--- a/src/i18n/locales/ko-KR/editor.json+++ b/src/i18n/locales/ko-KR/editor.json@@ -43,21 +43,21 @@"cameraNotFound": "카메라를 찾을 수 없습니다."},"autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "자동 자막",+ "dialogTitle": "자동 자막",+ "dialogDescription": "각 자막에 한 번에 표시할 단어 수의 대략적인 값을 선택하세요. 타이밍은 해당 구문의 단어들에 나뉩니다.",+ "minWords": "자막당 최소 단어 수",+ "maxWords": "자막당 최대 단어 수",+ "wordsCount": "{{count}}개 단어",+ "generate": "생성",+ "dialogCancel": "취소",+ "generating": "오디오에서 자막을 생성하는 중…",+ "loadingModel": "음성 모델을 불러오는 중(첫 사용 시 약 75MB 다운로드)…",+ "busy": "자막 생성이 이미 진행 중입니다.",+ "done": "자막 {{count}}개를 추가했습니다.",+ "noneHeard": "음성이 감지되지 않았습니다.",+ "noAudio": "이 동영상에는 전사에 사용할 수 있는 음성이 없습니다.",+ "failed": "자막을 생성할 수 없습니다.",+ "truncated": "처음 {{minutes}}분만 전사되었습니다."}}diff --git a/src/i18n/locales/tr/editor.json b/src/i18n/locales/tr/editor.jsonindex e5946a9a0..e85ae5ebe 100644--- a/src/i18n/locales/tr/editor.json+++ b/src/i18n/locales/tr/editor.json@@ -43,21 +43,21 @@"confirm": "Onayla"},"autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "Otomatik altyazılar",+ "dialogTitle": "Otomatik altyazılar",+ "dialogDescription": "Her altyazının aynı anda yaklaşık kaç kelime göstermesini istediğinizi seçin. Zamanlama, o ifadedeki kelimelere dağıtılır.",+ "minWords": "Altyazı başına en az kelime",+ "maxWords": "Altyazı başına en fazla kelime",+ "wordsCount": "{{count}} kelime",+ "generate": "Oluştur",+ "dialogCancel": "İptal",+ "generating": "Sesten altyazılar oluşturuluyor…",+ "loadingModel": "Konuşma modeli yükleniyor (ilk kullanımda ~75 MB indirilir)…",+ "busy": "Altyazı oluşturma zaten devam ediyor.",+ "done": "{{count}} altyazı eklendi.",+ "noneHeard": "Konuşma algılanmadı.",+ "noAudio": "Bu videoda yazıya dökülebilecek kullanılabilir bir ses yok.",+ "failed": "Altyazılar oluşturulamadı.",+ "truncated": "Yalnızca ilk {{minutes}} dakika yazıya döküldü."}}diff --git a/src/i18n/locales/zh-CN/editor.json b/src/i18n/locales/zh-CN/editor.jsonindex ca48fa6df..4f576f4c4 100644--- a/src/i18n/locales/zh-CN/editor.json+++ b/src/i18n/locales/zh-CN/editor.json@@ -43,21 +43,21 @@"permissionDenied": "录屏权限被拒绝。请允许屏幕录制。"},"autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "自动字幕",+ "dialogTitle": "自动字幕",+ "dialogDescription": "大致选择每条字幕一次显示多少个字词。时间会在该语句内的字词之间分配。",+ "minWords": "每条字幕的最少字数",+ "maxWords": "每条字幕的最多字数",+ "wordsCount": "{{count}} 个词",+ "generate": "生成",+ "dialogCancel": "取消",+ "generating": "正在从音频生成字幕…",+ "loadingModel": "正在加载语音模型(首次使用将下载约 75 MB)…",+ "busy": "字幕生成已在进行中。",+ "done": "已添加 {{count}} 条字幕。",+ "noneHeard": "未检测到语音。",+ "noAudio": "此视频没有可用于转写的音频。",+ "failed": "无法生成字幕。",+ "truncated": "仅转写了最前 {{minutes}} 分钟。"}}diff --git a/src/i18n/locales/zh-TW/editor.json b/src/i18n/locales/zh-TW/editor.jsonindex 2ba567499..b61f408eb 100644--- a/src/i18n/locales/zh-TW/editor.json+++ b/src/i18n/locales/zh-TW/editor.json@@ -43,21 +43,21 @@"cameraNotFound": "找不到攝影機。"},"autoCaptions": {- "button": "Auto captions",- "dialogTitle": "Auto captions",- "dialogDescription": "Choose roughly how many words each caption shows at once. Timing is spread across the words in that phrase.",- "minWords": "Minimum words per caption",- "maxWords": "Maximum words per caption",- "wordsCount": "{{count}} words",- "generate": "Generate",- "dialogCancel": "Cancel",- "generating": "Generating captions from audio…",- "loadingModel": "Loading speech model (first use downloads ~75 MB)…",- "busy": "Caption generation is already in progress.",- "done": "Added {{count}} captions.",- "noneHeard": "No speech was detected.",- "noAudio": "This video has no usable audio to transcribe.",- "failed": "Could not generate captions.",- "truncated": "Only the first {{minutes}} minutes were transcribed."+ "button": "自動字幕",+ "dialogTitle": "自動字幕",+ "dialogDescription": "大致選擇每條字幕一次顯示多少字詞。時間會在該語句內的字詞之間分配。",+ "minWords": "每條字幕的最少字數",+ "maxWords": "每條字幕的最多字數",+ "wordsCount": "{{count}} 個詞",+ "generate": "產生",+ "dialogCancel": "取消",+ "generating": "正在從音訊產生字幕…",+ "loadingModel": "正在載入語音模型(首次使用將下載約 75 MB)…",+ "busy": "字幕產生已在進行中。",+ "done": "已新增 {{count}} 條字幕。",+ "noneHeard": "未偵測到語音。",+ "noAudio": "此影片沒有可用於轉寫的音訊。",+ "failed": "無法產生字幕。",+ "truncated": "僅轉寫了最前 {{minutes}} 分鐘。"}}diff --git a/src/lib/captioning/annotationsFromCaptions.test.ts b/src/lib/captioning/annotationsFromCaptions.test.tsindex ea2b3a7be..31679f7f5 100644--- a/src/lib/captioning/annotationsFromCaptions.test.ts+++ b/src/lib/captioning/annotationsFromCaptions.test.ts@@ -73,6 +73,21 @@ describe("captionSegmentsToAnnotationRegions", () => {expect(lines[0]).toMatchObject({ startSec: 0, endSec: 0.28, text: "first caption" });expect(lines[1]).toMatchObject({ startSec: 0.7, endSec: 0.98, text: "second caption" });});++ it("preserves repeated words before grouping in word mode", () => {+ const { regions } = captionSegmentsToAnnotationRegions(+ [+ { startSec: 0, endSec: 0.12, text: "I" },+ { startSec: 0.13, endSec: 0.25, text: "I" },+ ],+ 1,+ 1,+ { minWordsPerCaption: 2, maxWordsPerCaption: 2, timestampGranularity: "word" },+ );++ expect(regions).toHaveLength(1);+ expect(regions[0]).toMatchObject({ content: "I I" });+ });});describe("reconcileAutoCaptionTimelineGaps", () => {diff --git a/src/lib/captioning/annotationsFromCaptions.ts b/src/lib/captioning/annotationsFromCaptions.tsindex cfae163ee..ca82b0477 100644--- a/src/lib/captioning/annotationsFromCaptions.ts+++ b/src/lib/captioning/annotationsFromCaptions.ts@@ -532,15 +532,14 @@ export function captionSegmentsToAnnotationRegions(): { regions: AnnotationRegion[]; nextNumericId: number; nextZIndex: number } {// Do not echo-collapse raw word tokens before grouping: repeated words ("I … I") share a// normalized key and would merge spans while keeping only the first token's text.- const dedupedIn = dedupeAdjacentCaptionRepeats(segments);const minW = layout?.minWordsPerCaption ?? 2;const maxW = layout?.maxWordsPerCaption ?? 7;const granularity = layout?.timestampGranularity ?? "word";const grouped =granularity === "phrase"- ? groupPhraseCaptionSegmentsIntoLines(dedupedIn, minW, maxW)- : groupTimedCaptionWordsIntoLines(dedupedIn, minW, maxW);+ ? groupPhraseCaptionSegmentsIntoLines(segments, minW, maxW)+ : groupTimedCaptionWordsIntoLines(segments, minW, maxW);const dedupedOut = dedupeAdjacentCaptionRepeats(grouped);const finalized = finalizeCaptionSegmentsForPlayback(dedupedOut);diff --git a/src/lib/captioning/extractMono16k.ts b/src/lib/captioning/extractMono16k.tsindex 9e932ea3d..53258567c 100644--- a/src/lib/captioning/extractMono16k.ts+++ b/src/lib/captioning/extractMono16k.ts@@ -99,7 +99,7 @@ async function truncateAndResampleTo16k(}const samples = await resampleMono(work, fromRate, 16_000, signal);- return { samples, truncated, durationSec };+ return { samples, truncated, durationSec: samples.length / 16_000 };}/**diff --git a/src/lib/captioning/extractMono16kWebDemuxer.ts b/src/lib/captioning/extractMono16kWebDemuxer.tsindex 4898ca011..fd85f5703 100644--- a/src/lib/captioning/extractMono16kWebDemuxer.ts+++ b/src/lib/captioning/extractMono16kWebDemuxer.ts@@ -42,7 +42,7 @@ function audioDataFrameToMono(frame: AudioData): Float32Array {return out;}-function mergeDecodedAudioToMonoLinear(+function mergeAndConsumeDecodedAudioToMonoLinear(frames: AudioData[],sampleRate: number,durationSec: number,@@ -129,7 +129,7 @@ export async function extractMonoPcmViaWebDemuxer(const sampleRate = audioConfig.sampleRate || 48_000;// Many WebM/Matroska files report a too-short duration; capping read at reported time stops- // demux early and mergeDecodedAudioToMonoLinear clips everything past that. Read up to the+ // demux early and mergeAndConsumeDecodedAudioToMonoLinear clips everything past that. Read up to the// same ceiling as caption decode (demuxer stops when the track ends).const readEndSec = MAX_CAPTION_AUDIO_SEC + READ_END_PADDING_SEC;const decodedFrames: AudioData[] = [];@@ -182,6 +182,6 @@ export async function extractMonoPcmViaWebDemuxer(// duration, fall back to reported metadata.const durationSec = inferredDurationSec > 0.02 ? inferredDurationSec : reportedDurationSec;- const mono = mergeDecodedAudioToMonoLinear(decodedFrames, sampleRate, durationSec);+ const mono = mergeAndConsumeDecodedAudioToMonoLinear(decodedFrames, sampleRate, durationSec);return { mono, sampleRate, durationSec };}diff --git a/src/lib/captioning/leadingSilence.ts b/src/lib/captioning/leadingSilence.tsindex 5ad7c50f4..4bd6a11aa 100644--- a/src/lib/captioning/leadingSilence.ts+++ b/src/lib/captioning/leadingSilence.ts@@ -71,13 +71,8 @@ export function shiftTrimRegionsMsForCaptionBuffer(return regions.map((r) => ({...r,- startMs: r.startMs - trimMs,- endMs: r.endMs - trimMs,- }))- .map((r) => ({- ...r,- startMs: Math.max(0, r.startMs),- endMs: Math.max(0, r.endMs),+ startMs: Math.max(0, r.startMs - trimMs),+ endMs: Math.max(0, r.endMs - trimMs),})).filter((r) => r.endMs > r.startMs);}diff --git a/src/lib/captioning/transcribe.ts b/src/lib/captioning/transcribe.tsindex e3c854cff..1c649c613 100644--- a/src/lib/captioning/transcribe.ts+++ b/src/lib/captioning/transcribe.ts@@ -124,10 +124,9 @@ function segmentsFromTranscriberChunks(segments.sort((u, v) => u.startSec - v.startSec || u.endSec - v.endSec);const rawDeduped: CaptionSegment[] = [];- const CHUNK_DUP_MAX_GAP_SEC = 0.42;for (const seg of segments) {const prev = rawDeduped[rawDeduped.length - 1];- if (prev && prev.text === seg.text && seg.startSec <= prev.endSec + CHUNK_DUP_MAX_GAP_SEC) {+ if (prev && prev.text === seg.text && seg.startSec <= prev.endSec) {prev.endSec = Math.max(prev.endSec, seg.endSec);prev.startSec = Math.min(prev.startSec, seg.startSec);continue;