@tscaps/engine 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -7
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/bidi/BidiAnalyzer.d.ts +23 -0
- package/dist/modules/bidi/BidiAnalyzer.d.ts.map +1 -0
- package/dist/modules/bidi/BidiAnalyzer.js +2 -0
- package/dist/modules/bidi/BidiAnalyzer.js.map +1 -0
- package/dist/modules/bidi/BidiCharacterClassifier.d.ts +13 -0
- package/dist/modules/bidi/BidiCharacterClassifier.d.ts.map +1 -0
- package/dist/modules/bidi/BidiCharacterClassifier.js +2 -0
- package/dist/modules/bidi/BidiCharacterClassifier.js.map +1 -0
- package/dist/modules/bidi/BidiJsAnalyzer.d.ts +14 -0
- package/dist/modules/bidi/BidiJsAnalyzer.d.ts.map +1 -0
- package/dist/modules/bidi/BidiJsAnalyzer.js +19 -0
- package/dist/modules/bidi/BidiJsAnalyzer.js.map +1 -0
- package/dist/modules/bidi/BidiJsCharacterClassifier.d.ts +8 -0
- package/dist/modules/bidi/BidiJsCharacterClassifier.d.ts.map +1 -0
- package/dist/modules/bidi/BidiJsCharacterClassifier.js +19 -0
- package/dist/modules/bidi/BidiJsCharacterClassifier.js.map +1 -0
- package/dist/modules/bidi/CursiveScriptDetector.d.ts +12 -0
- package/dist/modules/bidi/CursiveScriptDetector.d.ts.map +1 -0
- package/dist/modules/bidi/CursiveScriptDetector.js +20 -0
- package/dist/modules/bidi/CursiveScriptDetector.js.map +1 -0
- package/dist/modules/bidi/HorizontalSide.d.ts +18 -0
- package/dist/modules/bidi/HorizontalSide.d.ts.map +1 -0
- package/dist/modules/bidi/HorizontalSide.js +3 -0
- package/dist/modules/bidi/HorizontalSide.js.map +1 -0
- package/dist/modules/bidi/HorizontalSideResolver.d.ts +21 -0
- package/dist/modules/bidi/HorizontalSideResolver.d.ts.map +1 -0
- package/dist/modules/bidi/HorizontalSideResolver.js +27 -0
- package/dist/modules/bidi/HorizontalSideResolver.js.map +1 -0
- package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.d.ts +24 -0
- package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.d.ts.map +1 -0
- package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.js +34 -0
- package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.js.map +1 -0
- package/dist/modules/bidi/TextDirection.d.ts +9 -0
- package/dist/modules/bidi/TextDirection.d.ts.map +1 -0
- package/dist/modules/bidi/TextDirection.js +2 -0
- package/dist/modules/bidi/TextDirection.js.map +1 -0
- package/dist/modules/bidi/TextDirectionDetector.d.ts +12 -0
- package/dist/modules/bidi/TextDirectionDetector.d.ts.map +1 -0
- package/dist/modules/bidi/TextDirectionDetector.js +2 -0
- package/dist/modules/bidi/TextDirectionDetector.js.map +1 -0
- package/dist/modules/bidi/WordFragment.d.ts +34 -0
- package/dist/modules/bidi/WordFragment.d.ts.map +1 -0
- package/dist/modules/bidi/WordFragment.js +2 -0
- package/dist/modules/bidi/WordFragment.js.map +1 -0
- package/dist/modules/bidi/WordFragmenter.d.ts +43 -0
- package/dist/modules/bidi/WordFragmenter.d.ts.map +1 -0
- package/dist/modules/bidi/WordFragmenter.js +112 -0
- package/dist/modules/bidi/WordFragmenter.js.map +1 -0
- package/dist/modules/bidi/index.d.ts +14 -0
- package/dist/modules/bidi/index.d.ts.map +1 -0
- package/dist/modules/bidi/index.js +8 -0
- package/dist/modules/bidi/index.js.map +1 -0
- package/dist/modules/css/CssBlockSealer.d.ts +30 -0
- package/dist/modules/css/CssBlockSealer.d.ts.map +1 -0
- package/dist/modules/css/CssBlockSealer.js +64 -0
- package/dist/modules/css/CssBlockSealer.js.map +1 -0
- package/dist/modules/css/CssCustomPropertyDefinitionScanner.d.ts +13 -0
- package/dist/modules/css/CssCustomPropertyDefinitionScanner.d.ts.map +1 -0
- package/dist/modules/css/CssCustomPropertyDefinitionScanner.js +24 -0
- package/dist/modules/css/CssCustomPropertyDefinitionScanner.js.map +1 -0
- package/dist/modules/css/CssFilterReferenceScanner.d.ts +15 -0
- package/dist/modules/css/CssFilterReferenceScanner.d.ts.map +1 -0
- package/dist/modules/css/CssFilterReferenceScanner.js +22 -0
- package/dist/modules/css/CssFilterReferenceScanner.js.map +1 -0
- package/dist/modules/css/CssFragmentParser.d.ts +53 -0
- package/dist/modules/css/CssFragmentParser.d.ts.map +1 -0
- package/dist/modules/css/CssFragmentParser.js +127 -0
- package/dist/modules/css/CssFragmentParser.js.map +1 -0
- package/dist/modules/css/CssKeyframeNamespacer.d.ts +21 -0
- package/dist/modules/css/CssKeyframeNamespacer.d.ts.map +1 -0
- package/dist/modules/css/CssKeyframeNamespacer.js +48 -0
- package/dist/modules/css/CssKeyframeNamespacer.js.map +1 -0
- package/dist/modules/css/CssKeyframesScanner.d.ts +29 -0
- package/dist/modules/css/CssKeyframesScanner.d.ts.map +1 -0
- package/dist/modules/css/CssKeyframesScanner.js +102 -0
- package/dist/modules/css/CssKeyframesScanner.js.map +1 -0
- package/dist/modules/css/CssLayer.d.ts +20 -0
- package/dist/modules/css/CssLayer.d.ts.map +1 -0
- package/dist/modules/css/CssLayer.js +21 -0
- package/dist/modules/css/CssLayer.js.map +1 -0
- package/dist/modules/css/CssScoper.d.ts +11 -2
- package/dist/modules/css/CssScoper.d.ts.map +1 -1
- package/dist/modules/css/CssScoper.js +53 -37
- package/dist/modules/css/CssScoper.js.map +1 -1
- package/dist/modules/css/CssSelectorClassScanner.d.ts +25 -0
- package/dist/modules/css/CssSelectorClassScanner.d.ts.map +1 -0
- package/dist/modules/css/CssSelectorClassScanner.js +91 -0
- package/dist/modules/css/CssSelectorClassScanner.js.map +1 -0
- package/dist/modules/css/CssVarReferenceScanner.d.ts +8 -5
- package/dist/modules/css/CssVarReferenceScanner.d.ts.map +1 -1
- package/dist/modules/css/CssVarReferenceScanner.js +14 -7
- package/dist/modules/css/CssVarReferenceScanner.js.map +1 -1
- package/dist/modules/css/index.d.ts +8 -0
- package/dist/modules/css/index.d.ts.map +1 -1
- package/dist/modules/css/index.js +8 -0
- package/dist/modules/css/index.js.map +1 -1
- package/dist/modules/document/CssClass.d.ts +20 -0
- package/dist/modules/document/CssClass.d.ts.map +1 -0
- package/dist/modules/document/CssClass.js +21 -0
- package/dist/modules/document/CssClass.js.map +1 -0
- package/dist/modules/document/CssVariable.d.ts +0 -6
- package/dist/modules/document/CssVariable.d.ts.map +1 -1
- package/dist/modules/document/CssVariable.js +0 -6
- package/dist/modules/document/CssVariable.js.map +1 -1
- package/dist/modules/document/DataAttribute.d.ts +26 -0
- package/dist/modules/document/DataAttribute.d.ts.map +1 -0
- package/dist/modules/document/DataAttribute.js +27 -0
- package/dist/modules/document/DataAttribute.js.map +1 -0
- package/dist/modules/document/DocumentEditor.d.ts +40 -9
- package/dist/modules/document/DocumentEditor.d.ts.map +1 -1
- package/dist/modules/document/DocumentEditor.js +69 -17
- package/dist/modules/document/DocumentEditor.js.map +1 -1
- package/dist/modules/document/DocumentNodeId.d.ts +23 -0
- package/dist/modules/document/DocumentNodeId.d.ts.map +1 -0
- package/dist/modules/document/DocumentNodeId.js +31 -0
- package/dist/modules/document/DocumentNodeId.js.map +1 -0
- package/dist/modules/document/Line.d.ts +1 -1
- package/dist/modules/document/Line.d.ts.map +1 -1
- package/dist/modules/document/Line.js +2 -1
- package/dist/modules/document/Line.js.map +1 -1
- package/dist/modules/document/Section.d.ts +1 -4
- package/dist/modules/document/Section.d.ts.map +1 -1
- package/dist/modules/document/Section.js +2 -17
- package/dist/modules/document/Section.js.map +1 -1
- package/dist/modules/document/Segment.d.ts +14 -7
- package/dist/modules/document/Segment.d.ts.map +1 -1
- package/dist/modules/document/Segment.js +26 -1
- package/dist/modules/document/Segment.js.map +1 -1
- package/dist/modules/document/Word.d.ts +1 -1
- package/dist/modules/document/Word.d.ts.map +1 -1
- package/dist/modules/document/Word.js +2 -1
- package/dist/modules/document/Word.js.map +1 -1
- package/dist/modules/document/index.d.ts +4 -2
- package/dist/modules/document/index.d.ts.map +1 -1
- package/dist/modules/document/index.js +3 -1
- package/dist/modules/document/index.js.map +1 -1
- package/dist/modules/effect/GapFreeEffect.d.ts +15 -0
- package/dist/modules/effect/GapFreeEffect.d.ts.map +1 -1
- package/dist/modules/effect/GapFreeEffect.js +29 -4
- package/dist/modules/effect/GapFreeEffect.js.map +1 -1
- package/dist/modules/pipeline/RenderPipelineBuilder.js +3 -3
- package/dist/modules/pipeline/RenderPipelineBuilder.js.map +1 -1
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts.map +1 -1
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js +4 -1
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js.map +1 -1
- package/dist/modules/rendering/HorizontalPlacementResolver.d.ts +27 -0
- package/dist/modules/rendering/HorizontalPlacementResolver.d.ts.map +1 -0
- package/dist/modules/rendering/HorizontalPlacementResolver.js +31 -0
- package/dist/modules/rendering/HorizontalPlacementResolver.js.map +1 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.d.ts +2 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.d.ts.map +1 -1
- package/dist/modules/rendering/index.d.ts +7 -4
- package/dist/modules/rendering/index.d.ts.map +1 -1
- package/dist/modules/rendering/index.js +5 -2
- package/dist/modules/rendering/index.js.map +1 -1
- package/dist/modules/rendering/styles/BaselineCssComposer.d.ts +19 -1
- package/dist/modules/rendering/styles/BaselineCssComposer.d.ts.map +1 -1
- package/dist/modules/rendering/styles/BaselineCssComposer.js +32 -8
- package/dist/modules/rendering/styles/BaselineCssComposer.js.map +1 -1
- package/dist/modules/rendering/styles/DecorationContainerBaselineCss.d.ts.map +1 -1
- package/dist/modules/rendering/styles/DecorationContainerBaselineCss.js +5 -4
- package/dist/modules/rendering/styles/DecorationContainerBaselineCss.js.map +1 -1
- package/dist/modules/rendering/styles/FrozenFrameCss.d.ts +28 -0
- package/dist/modules/rendering/styles/FrozenFrameCss.d.ts.map +1 -0
- package/dist/modules/rendering/styles/FrozenFrameCss.js +28 -0
- package/dist/modules/rendering/styles/FrozenFrameCss.js.map +1 -0
- package/dist/modules/rendering/styles/InlineStyleEmitter.d.ts +0 -7
- package/dist/modules/rendering/styles/InlineStyleEmitter.d.ts.map +1 -1
- package/dist/modules/rendering/styles/InlineStyleEmitter.js +0 -9
- package/dist/modules/rendering/styles/InlineStyleEmitter.js.map +1 -1
- package/dist/modules/rendering/styles/{VideoFrameLayerClass.d.ts → VideoFrameLayerBaselineCss.d.ts} +3 -10
- package/dist/modules/rendering/styles/VideoFrameLayerBaselineCss.d.ts.map +1 -0
- package/dist/modules/rendering/styles/VideoFrameLayerBaselineCss.js +15 -0
- package/dist/modules/rendering/styles/VideoFrameLayerBaselineCss.js.map +1 -0
- package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.d.ts +3 -1
- package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.js +9 -4
- package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.js.map +1 -1
- package/dist/modules/rendering/subtitle/AnimationProbe.d.ts +23 -9
- package/dist/modules/rendering/subtitle/AnimationProbe.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/AnimationProbe.js +86 -81
- package/dist/modules/rendering/subtitle/AnimationProbe.js.map +1 -1
- package/dist/modules/rendering/subtitle/BatchPlanner.d.ts +1 -0
- package/dist/modules/rendering/subtitle/BatchPlanner.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/BatchPlanner.js +16 -14
- package/dist/modules/rendering/subtitle/BatchPlanner.js.map +1 -1
- package/dist/modules/rendering/subtitle/PreparedStyle.d.ts +1 -0
- package/dist/modules/rendering/subtitle/PreparedStyle.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/PreparedStyleFactory.js +1 -1
- package/dist/modules/rendering/subtitle/PreparedStyleFactory.js.map +1 -1
- package/dist/modules/rendering/subtitle/SegmentPaintRegionResolver.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/SegmentPaintRegionResolver.js +7 -4
- package/dist/modules/rendering/subtitle/SegmentPaintRegionResolver.js.map +1 -1
- package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.d.ts +30 -2
- package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.js +85 -27
- package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.js.map +1 -1
- package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.d.ts +3 -8
- package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.js +31 -40
- package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.js.map +1 -1
- package/dist/modules/rendering/subtitle/SpriteSheetCompositor.d.ts +2 -0
- package/dist/modules/rendering/subtitle/SpriteSheetCompositor.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/SpriteSheetCompositor.js +18 -9
- package/dist/modules/rendering/subtitle/SpriteSheetCompositor.js.map +1 -1
- package/dist/modules/rendering/subtitle/SvgFilterMaterializer.d.ts +8 -15
- package/dist/modules/rendering/subtitle/SvgFilterMaterializer.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/SvgFilterMaterializer.js +10 -20
- package/dist/modules/rendering/subtitle/SvgFilterMaterializer.js.map +1 -1
- package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.d.ts.map +1 -1
- package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.js +12 -3
- package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.js.map +1 -1
- package/dist/modules/rendering/types/AlignmentConfig.d.ts +16 -4
- package/dist/modules/rendering/types/AlignmentConfig.d.ts.map +1 -1
- package/dist/modules/rendering/types/AlignmentConfig.js +2 -1
- package/dist/modules/rendering/types/AlignmentConfig.js.map +1 -1
- package/dist/modules/rendering/types/ElementRenderOverrides.d.ts +8 -0
- package/dist/modules/rendering/types/ElementRenderOverrides.d.ts.map +1 -1
- package/dist/modules/rendering/types/ElementRenderOverrides.js +28 -0
- package/dist/modules/rendering/types/ElementRenderOverrides.js.map +1 -1
- package/dist/modules/rendering/types/RenderingConfig.d.ts +7 -2
- package/dist/modules/rendering/types/RenderingConfig.d.ts.map +1 -1
- package/dist/modules/rendering/types/ScopedRenderOverride.d.ts +9 -4
- package/dist/modules/rendering/types/ScopedRenderOverride.d.ts.map +1 -1
- package/dist/modules/subtitle-file/AssSubtitleFileSerializer.d.ts +53 -0
- package/dist/modules/subtitle-file/AssSubtitleFileSerializer.d.ts.map +1 -0
- package/dist/modules/subtitle-file/AssSubtitleFileSerializer.js +133 -0
- package/dist/modules/subtitle-file/AssSubtitleFileSerializer.js.map +1 -0
- package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.d.ts +20 -0
- package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.js +31 -0
- package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.js.map +1 -0
- package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.d.ts +21 -0
- package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.js +33 -0
- package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.js.map +1 -0
- package/dist/modules/subtitle-file/SubtitleCue.d.ts +18 -0
- package/dist/modules/subtitle-file/SubtitleCue.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SubtitleCue.js +20 -0
- package/dist/modules/subtitle-file/SubtitleCue.js.map +1 -0
- package/dist/modules/subtitle-file/SubtitleCueBuilder.d.ts +38 -0
- package/dist/modules/subtitle-file/SubtitleCueBuilder.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SubtitleCueBuilder.js +106 -0
- package/dist/modules/subtitle-file/SubtitleCueBuilder.js.map +1 -0
- package/dist/modules/subtitle-file/SubtitleFileJob.d.ts +17 -0
- package/dist/modules/subtitle-file/SubtitleFileJob.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SubtitleFileJob.js +2 -0
- package/dist/modules/subtitle-file/SubtitleFileJob.js.map +1 -0
- package/dist/modules/subtitle-file/SubtitleFileSerializer.d.ts +36 -0
- package/dist/modules/subtitle-file/SubtitleFileSerializer.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SubtitleFileSerializer.js +44 -0
- package/dist/modules/subtitle-file/SubtitleFileSerializer.js.map +1 -0
- package/dist/modules/subtitle-file/SubtitleGranularity.d.ts +11 -0
- package/dist/modules/subtitle-file/SubtitleGranularity.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SubtitleGranularity.js +2 -0
- package/dist/modules/subtitle-file/SubtitleGranularity.js.map +1 -0
- package/dist/modules/subtitle-file/SubtitleRow.d.ts +11 -0
- package/dist/modules/subtitle-file/SubtitleRow.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SubtitleRow.js +14 -0
- package/dist/modules/subtitle-file/SubtitleRow.js.map +1 -0
- package/dist/modules/subtitle-file/SubtitleToken.d.ts +13 -0
- package/dist/modules/subtitle-file/SubtitleToken.d.ts.map +1 -0
- package/dist/modules/subtitle-file/SubtitleToken.js +15 -0
- package/dist/modules/subtitle-file/SubtitleToken.js.map +1 -0
- package/dist/modules/subtitle-file/TextSubtitleFileSerializer.d.ts +19 -0
- package/dist/modules/subtitle-file/TextSubtitleFileSerializer.d.ts.map +1 -0
- package/dist/modules/subtitle-file/TextSubtitleFileSerializer.js +24 -0
- package/dist/modules/subtitle-file/TextSubtitleFileSerializer.js.map +1 -0
- package/dist/modules/subtitle-file/Timecode.d.ts +20 -0
- package/dist/modules/subtitle-file/Timecode.d.ts.map +1 -0
- package/dist/modules/subtitle-file/Timecode.js +32 -0
- package/dist/modules/subtitle-file/Timecode.js.map +1 -0
- package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.d.ts +22 -0
- package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.d.ts.map +1 -0
- package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.js +57 -0
- package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.js.map +1 -0
- package/dist/modules/subtitle-file/VttSubtitleFileSerializer.d.ts +21 -0
- package/dist/modules/subtitle-file/VttSubtitleFileSerializer.d.ts.map +1 -0
- package/dist/modules/subtitle-file/VttSubtitleFileSerializer.js +39 -0
- package/dist/modules/subtitle-file/VttSubtitleFileSerializer.js.map +1 -0
- package/dist/modules/subtitle-file/index.d.ts +10 -0
- package/dist/modules/subtitle-file/index.d.ts.map +1 -0
- package/dist/modules/subtitle-file/index.js +8 -0
- package/dist/modules/subtitle-file/index.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilter.d.ts +8 -1
- package/dist/modules/svg-filter/SvgFilter.d.ts.map +1 -1
- package/dist/modules/svg-filter/SvgFilter.js +9 -1
- package/dist/modules/svg-filter/SvgFilter.js.map +1 -1
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts.map +1 -1
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js +9 -1
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js.map +1 -1
- package/dist/modules/svg-filter/SvgFilterDefsRenderer.d.ts +44 -0
- package/dist/modules/svg-filter/SvgFilterDefsRenderer.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefsRenderer.js +47 -0
- package/dist/modules/svg-filter/SvgFilterDefsRenderer.js.map +1 -0
- package/dist/modules/svg-filter/index.d.ts +2 -0
- package/dist/modules/svg-filter/index.d.ts.map +1 -1
- package/dist/modules/svg-filter/index.js +1 -0
- package/dist/modules/svg-filter/index.js.map +1 -1
- package/dist/modules/tagging/PauseTagger.d.ts.map +1 -1
- package/dist/modules/tagging/PauseTagger.js +2 -1
- package/dist/modules/tagging/PauseTagger.js.map +1 -1
- package/dist/modules/tagging/RegexTagger.js +1 -1
- package/dist/modules/tagging/RegexTagger.js.map +1 -1
- package/dist/modules/tagging/SpanTagger.js +1 -1
- package/dist/modules/tagging/SpanTagger.js.map +1 -1
- package/dist/modules/tagging/StructureTagger.d.ts +0 -1
- package/dist/modules/tagging/StructureTagger.d.ts.map +1 -1
- package/dist/modules/tagging/StructureTagger.js +3 -8
- package/dist/modules/tagging/StructureTagger.js.map +1 -1
- package/dist/modules/tagging/WordlistTagger.js +1 -1
- package/dist/modules/tagging/WordlistTagger.js.map +1 -1
- package/dist/modules/tags/AndTagCondition.d.ts +10 -0
- package/dist/modules/tags/AndTagCondition.d.ts.map +1 -0
- package/dist/modules/tags/AndTagCondition.js +14 -0
- package/dist/modules/tags/AndTagCondition.js.map +1 -0
- package/dist/modules/tags/HasTagCondition.d.ts +10 -0
- package/dist/modules/tags/HasTagCondition.d.ts.map +1 -0
- package/dist/modules/tags/HasTagCondition.js +18 -0
- package/dist/modules/tags/HasTagCondition.js.map +1 -0
- package/dist/modules/tags/NotTagCondition.d.ts +10 -0
- package/dist/modules/tags/NotTagCondition.d.ts.map +1 -0
- package/dist/modules/tags/NotTagCondition.js +14 -0
- package/dist/modules/tags/NotTagCondition.js.map +1 -0
- package/dist/modules/tags/OrTagCondition.d.ts +10 -0
- package/dist/modules/tags/OrTagCondition.d.ts.map +1 -0
- package/dist/modules/tags/OrTagCondition.js +14 -0
- package/dist/modules/tags/OrTagCondition.js.map +1 -0
- package/dist/modules/{document/Tag.d.ts → tags/StructureTag.d.ts} +2 -11
- package/dist/modules/tags/StructureTag.d.ts.map +1 -0
- package/dist/modules/{document/Tag.js → tags/StructureTag.js} +1 -19
- package/dist/modules/tags/StructureTag.js.map +1 -0
- package/dist/modules/tags/Tag.d.ts +8 -0
- package/dist/modules/tags/Tag.d.ts.map +1 -0
- package/dist/modules/tags/Tag.js +16 -0
- package/dist/modules/tags/Tag.js.map +1 -0
- package/dist/modules/tags/TagCondition.d.ts +12 -0
- package/dist/modules/tags/TagCondition.d.ts.map +1 -0
- package/dist/modules/tags/TagCondition.js +2 -0
- package/dist/modules/tags/TagCondition.js.map +1 -0
- package/dist/modules/tags/TagConditionParser.d.ts +21 -0
- package/dist/modules/tags/TagConditionParser.d.ts.map +1 -0
- package/dist/modules/tags/TagConditionParser.js +75 -0
- package/dist/modules/tags/TagConditionParser.js.map +1 -0
- package/dist/modules/tags/index.d.ts +9 -0
- package/dist/modules/tags/index.d.ts.map +1 -0
- package/dist/modules/tags/index.js +8 -0
- package/dist/modules/tags/index.js.map +1 -0
- package/dist/modules/transcription/AudioDecoder.d.ts +9 -4
- package/dist/modules/transcription/AudioDecoder.d.ts.map +1 -1
- package/dist/modules/transcription/BatchedMonoResampler.d.ts +45 -0
- package/dist/modules/transcription/BatchedMonoResampler.d.ts.map +1 -0
- package/dist/modules/transcription/BatchedMonoResampler.js +116 -0
- package/dist/modules/transcription/BatchedMonoResampler.js.map +1 -0
- package/dist/modules/transcription/CacheStorageModelFileCache.d.ts +38 -0
- package/dist/modules/transcription/CacheStorageModelFileCache.d.ts.map +1 -0
- package/dist/modules/transcription/CacheStorageModelFileCache.js +86 -0
- package/dist/modules/transcription/CacheStorageModelFileCache.js.map +1 -0
- package/dist/modules/transcription/CueDocumentBuilder.d.ts +40 -0
- package/dist/modules/transcription/CueDocumentBuilder.d.ts.map +1 -0
- package/dist/modules/transcription/CueDocumentBuilder.js +77 -0
- package/dist/modules/transcription/CueDocumentBuilder.js.map +1 -0
- package/dist/modules/transcription/CueParseResult.d.ts +16 -0
- package/dist/modules/transcription/CueParseResult.d.ts.map +1 -0
- package/dist/modules/transcription/CueParseResult.js +2 -0
- package/dist/modules/transcription/CueParseResult.js.map +1 -0
- package/dist/modules/transcription/CueTextTokenizer.d.ts +10 -0
- package/dist/modules/transcription/CueTextTokenizer.d.ts.map +1 -0
- package/dist/modules/transcription/CueTextTokenizer.js +21 -0
- package/dist/modules/transcription/CueTextTokenizer.js.map +1 -0
- package/dist/modules/transcription/CueTimecodeReader.d.ts +19 -0
- package/dist/modules/transcription/CueTimecodeReader.d.ts.map +1 -0
- package/dist/modules/transcription/CueTimecodeReader.js +45 -0
- package/dist/modules/transcription/CueTimecodeReader.js.map +1 -0
- package/dist/modules/transcription/CueWordReader.d.ts +12 -0
- package/dist/modules/transcription/CueWordReader.d.ts.map +1 -0
- package/dist/modules/transcription/CueWordReader.js +2 -0
- package/dist/modules/transcription/CueWordReader.js.map +1 -0
- package/dist/modules/transcription/EstimatedCueWordReader.d.ts +16 -0
- package/dist/modules/transcription/EstimatedCueWordReader.d.ts.map +1 -0
- package/dist/modules/transcription/EstimatedCueWordReader.js +17 -0
- package/dist/modules/transcription/EstimatedCueWordReader.js.map +1 -0
- package/dist/modules/transcription/LogitsProcessorListFactory.d.ts +43 -0
- package/dist/modules/transcription/LogitsProcessorListFactory.d.ts.map +1 -0
- package/dist/modules/transcription/LogitsProcessorListFactory.js +72 -0
- package/dist/modules/transcription/LogitsProcessorListFactory.js.map +1 -0
- package/dist/modules/transcription/MediaBunnyAudioDecoder.d.ts +27 -0
- package/dist/modules/transcription/MediaBunnyAudioDecoder.d.ts.map +1 -0
- package/dist/modules/transcription/MediaBunnyAudioDecoder.js +76 -0
- package/dist/modules/transcription/MediaBunnyAudioDecoder.js.map +1 -0
- package/dist/modules/transcription/ModelFileCache.d.ts +20 -0
- package/dist/modules/transcription/ModelFileCache.d.ts.map +1 -0
- package/dist/modules/transcription/ModelFileCache.js +2 -0
- package/dist/modules/transcription/ModelFileCache.js.map +1 -0
- package/dist/modules/transcription/ModelFileCacheUnavailableError.d.ts +18 -0
- package/dist/modules/transcription/ModelFileCacheUnavailableError.d.ts.map +1 -0
- package/dist/modules/transcription/ModelFileCacheUnavailableError.js +18 -0
- package/dist/modules/transcription/ModelFileCacheUnavailableError.js.map +1 -0
- package/dist/modules/transcription/SrtTranscriber.d.ts +24 -15
- package/dist/modules/transcription/SrtTranscriber.d.ts.map +1 -1
- package/dist/modules/transcription/SrtTranscriber.js +32 -90
- package/dist/modules/transcription/SrtTranscriber.js.map +1 -1
- package/dist/modules/transcription/SubtitleFileUnreadableError.d.ts +22 -0
- package/dist/modules/transcription/SubtitleFileUnreadableError.d.ts.map +1 -0
- package/dist/modules/transcription/SubtitleFileUnreadableError.js +22 -0
- package/dist/modules/transcription/SubtitleFileUnreadableError.js.map +1 -0
- package/dist/modules/transcription/TimestampedCueWordReader.d.ts +27 -0
- package/dist/modules/transcription/TimestampedCueWordReader.d.ts.map +1 -0
- package/dist/modules/transcription/TimestampedCueWordReader.js +52 -0
- package/dist/modules/transcription/TimestampedCueWordReader.js.map +1 -0
- package/dist/modules/transcription/Transcriber.d.ts +13 -0
- package/dist/modules/transcription/Transcriber.d.ts.map +1 -1
- package/dist/modules/transcription/TransformersRuntime.d.ts +50 -0
- package/dist/modules/transcription/TransformersRuntime.d.ts.map +1 -0
- package/dist/modules/transcription/TransformersRuntime.js +79 -0
- package/dist/modules/transcription/TransformersRuntime.js.map +1 -0
- package/dist/modules/transcription/VttTranscriber.d.ts +25 -7
- package/dist/modules/transcription/VttTranscriber.d.ts.map +1 -1
- package/dist/modules/transcription/VttTranscriber.js +36 -15
- package/dist/modules/transcription/VttTranscriber.js.map +1 -1
- package/dist/modules/transcription/WhisperChunkStitcher.d.ts +51 -0
- package/dist/modules/transcription/WhisperChunkStitcher.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperChunkStitcher.js +101 -0
- package/dist/modules/transcription/WhisperChunkStitcher.js.map +1 -0
- package/dist/modules/transcription/WhisperDeviceUnavailableError.d.ts +16 -0
- package/dist/modules/transcription/WhisperDeviceUnavailableError.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperDeviceUnavailableError.js +16 -0
- package/dist/modules/transcription/WhisperDeviceUnavailableError.js.map +1 -0
- package/dist/modules/transcription/WhisperInferenceFailedError.d.ts +16 -0
- package/dist/modules/transcription/WhisperInferenceFailedError.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperInferenceFailedError.js +16 -0
- package/dist/modules/transcription/WhisperInferenceFailedError.js.map +1 -0
- package/dist/modules/transcription/WhisperInferenceProgressTracker.d.ts +61 -0
- package/dist/modules/transcription/WhisperInferenceProgressTracker.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperInferenceProgressTracker.js +102 -0
- package/dist/modules/transcription/WhisperInferenceProgressTracker.js.map +1 -0
- package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.d.ts +38 -0
- package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.js +94 -0
- package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.js.map +1 -0
- package/dist/modules/transcription/WhisperModelLoadFailedError.d.ts +15 -0
- package/dist/modules/transcription/WhisperModelLoadFailedError.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperModelLoadFailedError.js +15 -0
- package/dist/modules/transcription/WhisperModelLoadFailedError.js.map +1 -0
- package/dist/modules/transcription/WhisperTranscriber.d.ts +106 -7
- package/dist/modules/transcription/WhisperTranscriber.d.ts.map +1 -1
- package/dist/modules/transcription/WhisperTranscriber.js +312 -25
- package/dist/modules/transcription/WhisperTranscriber.js.map +1 -1
- package/dist/modules/transcription/WhisperWindowCoverage.d.ts +79 -0
- package/dist/modules/transcription/WhisperWindowCoverage.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperWindowCoverage.js +129 -0
- package/dist/modules/transcription/WhisperWindowCoverage.js.map +1 -0
- package/dist/modules/transcription/WordTimingEstimator.d.ts +14 -0
- package/dist/modules/transcription/WordTimingEstimator.d.ts.map +1 -0
- package/dist/modules/transcription/WordTimingEstimator.js +33 -0
- package/dist/modules/transcription/WordTimingEstimator.js.map +1 -0
- package/dist/modules/transcription/index.d.ts +8 -2
- package/dist/modules/transcription/index.d.ts.map +1 -1
- package/dist/modules/transcription/index.js +5 -1
- package/dist/modules/transcription/index.js.map +1 -1
- package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.d.ts.map +1 -1
- package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.js +8 -0
- package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.js.map +1 -1
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts +3 -1
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts.map +1 -1
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js +33 -23
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js.map +1 -1
- package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.js +1 -1
- package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.js.map +1 -1
- package/dist/modules/video/mediabunny/painter/TopLayerSource.d.ts +6 -7
- package/dist/modules/video/mediabunny/painter/TopLayerSource.d.ts.map +1 -1
- package/package.json +16 -10
- package/dist/modules/document/Tag.d.ts.map +0 -1
- package/dist/modules/document/Tag.js.map +0 -1
- package/dist/modules/rendering/styles/BehindActorBaselineCss.d.ts +0 -19
- package/dist/modules/rendering/styles/BehindActorBaselineCss.d.ts.map +0 -1
- package/dist/modules/rendering/styles/BehindActorBaselineCss.js +0 -19
- package/dist/modules/rendering/styles/BehindActorBaselineCss.js.map +0 -1
- package/dist/modules/rendering/styles/VideoFrameLayerClass.d.ts.map +0 -1
- package/dist/modules/rendering/styles/VideoFrameLayerClass.js +0 -21
- package/dist/modules/rendering/styles/VideoFrameLayerClass.js.map +0 -1
- package/dist/modules/rendering/types/BehindActorRequirement.d.ts +0 -12
- package/dist/modules/rendering/types/BehindActorRequirement.d.ts.map +0 -1
- package/dist/modules/rendering/types/BehindActorRequirement.js +0 -2
- package/dist/modules/rendering/types/BehindActorRequirement.js.map +0 -1
- package/dist/modules/transcription/BrowserAudioDecoder.d.ts +0 -13
- package/dist/modules/transcription/BrowserAudioDecoder.d.ts.map +0 -1
- package/dist/modules/transcription/BrowserAudioDecoder.js +0 -34
- package/dist/modules/transcription/BrowserAudioDecoder.js.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ModelFileCacheUnavailableError } from '../transcription/ModelFileCacheUnavailableError';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps model files in the browser's Cache Storage.
|
|
4
|
+
*
|
|
5
|
+
* Browsers refuse this write far more often than one would expect —
|
|
6
|
+
* an origin over its quota, a private window, a page outside a secure
|
|
7
|
+
* context — and every refusal costs the next run a full re-download of
|
|
8
|
+
* hundreds of megabytes with nothing on screen to explain it. The
|
|
9
|
+
* refusal is therefore handed to `onKeepFailure` instead of being
|
|
10
|
+
* swallowed, while the run in flight carries on regardless: the files
|
|
11
|
+
* are already in memory and the transcription does not need them kept.
|
|
12
|
+
*
|
|
13
|
+
* Only the first refusal of an instance's lifetime is announced. A
|
|
14
|
+
* model is several files and the condition behind a refusal applies to
|
|
15
|
+
* all of them, so the rest would say the same thing again.
|
|
16
|
+
*/
|
|
17
|
+
export class CacheStorageModelFileCache {
|
|
18
|
+
onKeepFailure;
|
|
19
|
+
// The name transformers.js opens by default. Matching it keeps the
|
|
20
|
+
// files downloaded by earlier versions, which used the library's own
|
|
21
|
+
// caching, readable by this one.
|
|
22
|
+
static CACHE_NAME = 'transformers-cache';
|
|
23
|
+
opening = null;
|
|
24
|
+
failureAnnounced = false;
|
|
25
|
+
/**
|
|
26
|
+
* @param onKeepFailure Called at most once per instance, with the
|
|
27
|
+
* refusal that stopped a file from being kept.
|
|
28
|
+
*/
|
|
29
|
+
constructor(onKeepFailure) {
|
|
30
|
+
this.onKeepFailure = onKeepFailure;
|
|
31
|
+
}
|
|
32
|
+
async match(key) {
|
|
33
|
+
const cache = await this.open();
|
|
34
|
+
if (!cache)
|
|
35
|
+
return undefined;
|
|
36
|
+
try {
|
|
37
|
+
return await cache.match(key);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// A cache that cannot be read is indistinguishable from one that
|
|
41
|
+
// never held the file: both mean it has to be downloaded.
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async put(key, response) {
|
|
46
|
+
const cache = await this.open();
|
|
47
|
+
if (!cache) {
|
|
48
|
+
this.announce(new ModelFileCacheUnavailableError('Cache Storage is not exposed in this context'));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await cache.put(key, response);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.announce(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
announce(error) {
|
|
59
|
+
if (this.failureAnnounced)
|
|
60
|
+
return;
|
|
61
|
+
this.failureAnnounced = true;
|
|
62
|
+
this.onKeepFailure(error);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolves to `null` when this runtime has no Cache Storage at all,
|
|
66
|
+
* which is a standing condition rather than a transient one — hence
|
|
67
|
+
* the single attempt, reused by every later call.
|
|
68
|
+
*/
|
|
69
|
+
open() {
|
|
70
|
+
this.opening ??= this.openOnce();
|
|
71
|
+
return this.opening;
|
|
72
|
+
}
|
|
73
|
+
async openOnce() {
|
|
74
|
+
if (typeof caches === 'undefined')
|
|
75
|
+
return null;
|
|
76
|
+
try {
|
|
77
|
+
return await caches.open(CacheStorageModelFileCache.CACHE_NAME);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Opening is refused outright in some privacy modes. There is
|
|
81
|
+
// nothing to fall back to, and `put` reports the consequence.
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=CacheStorageModelFileCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheStorageModelFileCache.js","sourceRoot":"","sources":["../../../src/modules/transcription/CacheStorageModelFileCache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,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACK,IAAI;QACV,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,QAAQ;QACpB,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,IAAI,CAAC;QAC/C,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAClE,CAAC;QAAC,MAAM,CAAC;YACP,8DAA8D;YAC9D,8DAA8D;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CueParseResult } from '../transcription/CueParseResult';
|
|
2
|
+
import type { CueTimecodeReader } from '../transcription/CueTimecodeReader';
|
|
3
|
+
import type { CueWordReader } from '../transcription/CueWordReader';
|
|
4
|
+
/**
|
|
5
|
+
* Builds a Document from the cue blocks of a caption file: blank lines
|
|
6
|
+
* separate cues, a `-->` line states the range, and everything below it
|
|
7
|
+
* is the text. Each cue becomes one Segment holding one Line.
|
|
8
|
+
*
|
|
9
|
+
* A counter or identifier above the range line is ignored, since
|
|
10
|
+
* neither says anything the Document keeps. A cue whose text is empty
|
|
11
|
+
* is dropped. How the text becomes timed words is the reader's business
|
|
12
|
+
* and the only thing that differs between formats.
|
|
13
|
+
*
|
|
14
|
+
* A block carrying no range line is skipped and handed back in the
|
|
15
|
+
* result rather than ending the read. This is what the WebVTT parser
|
|
16
|
+
* algorithm prescribes, and it is the only behaviour that serves
|
|
17
|
+
* someone holding a file they did not write: one stray blank line
|
|
18
|
+
* inside a cue, or one paragraph of prose at the end, would otherwise
|
|
19
|
+
* cost them every cue in the file. Deciding whether the remainder is
|
|
20
|
+
* worth using belongs to the caller, which is why the count of what
|
|
21
|
+
* was lost travels with it.
|
|
22
|
+
*
|
|
23
|
+
* A file where every block was skipped is refused outright: what is
|
|
24
|
+
* left is not a thin transcript, it is no transcript, and returning
|
|
25
|
+
* one would say the file was silent rather than unreadable. A file
|
|
26
|
+
* with no blocks at all is not refused — there is nothing in it to
|
|
27
|
+
* misread.
|
|
28
|
+
*
|
|
29
|
+
* A malformed *timecode* still throws. That block announced its
|
|
30
|
+
* intent to state a time and got it wrong, so placing its text
|
|
31
|
+
* anywhere would be a guess.
|
|
32
|
+
*/
|
|
33
|
+
export declare class CueDocumentBuilder {
|
|
34
|
+
private readonly timecodeReader;
|
|
35
|
+
constructor(timecodeReader: CueTimecodeReader);
|
|
36
|
+
build(source: string, wordReader: CueWordReader): CueParseResult;
|
|
37
|
+
private splitIntoBlocks;
|
|
38
|
+
private buildSegment;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=CueDocumentBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueDocumentBuilder.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/CueDocumentBuilder.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAK1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,iBAAiB;IAE9D,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,cAAc;IAgBhE,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,YAAY;CAkBrB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Document } from '../document/Document';
|
|
2
|
+
import { Line } from '../document/Line';
|
|
3
|
+
import { Section } from '../document/Section';
|
|
4
|
+
import { Segment } from '../document/Segment';
|
|
5
|
+
import { SubtitleFileUnreadableError } from '../transcription/SubtitleFileUnreadableError';
|
|
6
|
+
const BOM_RE = /^\uFEFF/;
|
|
7
|
+
/**
|
|
8
|
+
* Builds a Document from the cue blocks of a caption file: blank lines
|
|
9
|
+
* separate cues, a `-->` line states the range, and everything below it
|
|
10
|
+
* is the text. Each cue becomes one Segment holding one Line.
|
|
11
|
+
*
|
|
12
|
+
* A counter or identifier above the range line is ignored, since
|
|
13
|
+
* neither says anything the Document keeps. A cue whose text is empty
|
|
14
|
+
* is dropped. How the text becomes timed words is the reader's business
|
|
15
|
+
* and the only thing that differs between formats.
|
|
16
|
+
*
|
|
17
|
+
* A block carrying no range line is skipped and handed back in the
|
|
18
|
+
* result rather than ending the read. This is what the WebVTT parser
|
|
19
|
+
* algorithm prescribes, and it is the only behaviour that serves
|
|
20
|
+
* someone holding a file they did not write: one stray blank line
|
|
21
|
+
* inside a cue, or one paragraph of prose at the end, would otherwise
|
|
22
|
+
* cost them every cue in the file. Deciding whether the remainder is
|
|
23
|
+
* worth using belongs to the caller, which is why the count of what
|
|
24
|
+
* was lost travels with it.
|
|
25
|
+
*
|
|
26
|
+
* A file where every block was skipped is refused outright: what is
|
|
27
|
+
* left is not a thin transcript, it is no transcript, and returning
|
|
28
|
+
* one would say the file was silent rather than unreadable. A file
|
|
29
|
+
* with no blocks at all is not refused — there is nothing in it to
|
|
30
|
+
* misread.
|
|
31
|
+
*
|
|
32
|
+
* A malformed *timecode* still throws. That block announced its
|
|
33
|
+
* intent to state a time and got it wrong, so placing its text
|
|
34
|
+
* anywhere would be a guess.
|
|
35
|
+
*/
|
|
36
|
+
export class CueDocumentBuilder {
|
|
37
|
+
timecodeReader;
|
|
38
|
+
constructor(timecodeReader) {
|
|
39
|
+
this.timecodeReader = timecodeReader;
|
|
40
|
+
}
|
|
41
|
+
build(source, wordReader) {
|
|
42
|
+
const skippedBlocks = [];
|
|
43
|
+
const segments = this.splitIntoBlocks(source)
|
|
44
|
+
.map((block) => this.buildSegment(block, wordReader, skippedBlocks))
|
|
45
|
+
.filter((segment) => segment !== null);
|
|
46
|
+
if (segments.length === 0 && skippedBlocks.length > 0) {
|
|
47
|
+
throw new SubtitleFileUnreadableError(`None of the ${skippedBlocks.length} block(s) in the file carried a timecode line`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
document: new Document({ sections: [new Section({ segments, kind: '' })] }),
|
|
51
|
+
skippedBlocks,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
splitIntoBlocks(source) {
|
|
55
|
+
const normalized = source.replace(BOM_RE, '').replace(/\r\n?/g, '\n').trim();
|
|
56
|
+
if (normalized.length === 0)
|
|
57
|
+
return [];
|
|
58
|
+
return normalized.split(/\n{2,}/);
|
|
59
|
+
}
|
|
60
|
+
buildSegment(block, wordReader, skippedBlocks) {
|
|
61
|
+
const lines = block.split('\n').map((line) => line.trim()).filter((line) => line.length > 0);
|
|
62
|
+
if (lines.length === 0)
|
|
63
|
+
return null;
|
|
64
|
+
const rangeAt = lines.findIndex((line) => this.timecodeReader.isRangeLine(line));
|
|
65
|
+
if (rangeAt === -1) {
|
|
66
|
+
skippedBlocks.push(block);
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const range = this.timecodeReader.readRange(lines[rangeAt]);
|
|
70
|
+
const text = lines.slice(rangeAt + 1).join(' ');
|
|
71
|
+
const words = wordReader.read(text, range.startSeconds, range.endSeconds);
|
|
72
|
+
if (words.length === 0)
|
|
73
|
+
return null;
|
|
74
|
+
return new Segment({ lines: [new Line({ words })] });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=CueDocumentBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueDocumentBuilder.js","sourceRoot":"","sources":["../../../src/modules/transcription/CueDocumentBuilder.ts"],"names":[],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AAO,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Document } from '../document/Document';
|
|
2
|
+
/**
|
|
3
|
+
* What reading a caption file produced: the cues that could be read,
|
|
4
|
+
* and the blocks that could not.
|
|
5
|
+
*
|
|
6
|
+
* The two travel together because a caption file is rarely all right
|
|
7
|
+
* or all wrong. A reader that returned only the document would leave
|
|
8
|
+
* its caller unable to tell a file that was fully understood from one
|
|
9
|
+
* that was mostly understood.
|
|
10
|
+
*/
|
|
11
|
+
export interface CueParseResult {
|
|
12
|
+
readonly document: Document;
|
|
13
|
+
/** Verbatim text of every block that carried no timecode. */
|
|
14
|
+
readonly skippedBlocks: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=CueParseResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueParseResult.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/CueParseResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueParseResult.js","sourceRoot":"","sources":["../../../src/modules/transcription/CueParseResult.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reduces the text of one cue to the words it says.
|
|
3
|
+
*
|
|
4
|
+
* Markup is dropped, runs of whitespace collapse, and a cue that turns
|
|
5
|
+
* out to hold nothing but markup yields no words at all.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CueTextTokenizer {
|
|
8
|
+
tokenize(text: string): ReadonlyArray<string>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=CueTextTokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueTextTokenizer.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/CueTextTokenizer.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,qBAAa,gBAAgB;IAE3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;CAM9C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markup a caption file may wrap its text in: WebVTT's angle-bracket
|
|
3
|
+
* tags and the brace-delimited overrides SubRip files sometimes carry
|
|
4
|
+
* from SubStation. None of it survives into a word.
|
|
5
|
+
*/
|
|
6
|
+
const MARKUP = /<[^>]+>|\{[^}]+\}/g;
|
|
7
|
+
/**
|
|
8
|
+
* Reduces the text of one cue to the words it says.
|
|
9
|
+
*
|
|
10
|
+
* Markup is dropped, runs of whitespace collapse, and a cue that turns
|
|
11
|
+
* out to hold nothing but markup yields no words at all.
|
|
12
|
+
*/
|
|
13
|
+
export class CueTextTokenizer {
|
|
14
|
+
tokenize(text) {
|
|
15
|
+
return text
|
|
16
|
+
.replace(MARKUP, '')
|
|
17
|
+
.split(/\s+/)
|
|
18
|
+
.filter((token) => token.length > 0);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=CueTextTokenizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueTextTokenizer.js","sourceRoot":"","sources":["../../../src/modules/transcription/CueTextTokenizer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,GAAG,oBAAoB,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAE3B,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI;aACR,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;aACnB,KAAK,CAAC,KAAK,CAAC;aACZ,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Half-open range a cue occupies, in seconds. */
|
|
2
|
+
export interface CueTimeRange {
|
|
3
|
+
readonly startSeconds: number;
|
|
4
|
+
readonly endSeconds: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads the timecodes a caption file states its timings with.
|
|
8
|
+
*
|
|
9
|
+
* Positions are returned in seconds. A malformed timecode throws rather
|
|
10
|
+
* than resolving to zero, so a file that cannot be trusted is refused
|
|
11
|
+
* instead of silently landing every caption at the start.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CueTimecodeReader {
|
|
14
|
+
isRangeLine(line: string): boolean;
|
|
15
|
+
readRange(line: string): CueTimeRange;
|
|
16
|
+
readPosition(timecode: string): number;
|
|
17
|
+
private toSeconds;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=CueTimecodeReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueTimecodeReader.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/CueTimecodeReader.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAYD;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAE5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAWrC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAMtC,OAAO,CAAC,SAAS;CAalB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A position written `HH:MM:SS,mmm` or `HH:MM:SS.mmm`. SubRip settled
|
|
3
|
+
* on the comma and WebVTT on the dot, and both are accepted either way
|
|
4
|
+
* because files in the wild mix them. WebVTT also allows the hour to be
|
|
5
|
+
* left out, so it is optional.
|
|
6
|
+
*/
|
|
7
|
+
const POSITION = String.raw `(?:(\d{1,3}):)?(\d{2}):(\d{2})[,.](\d{1,3})`;
|
|
8
|
+
const RANGE_LINE = new RegExp(`^${POSITION}\\s*-->\\s*${POSITION}`);
|
|
9
|
+
const POSITION_ONLY = new RegExp(`^${POSITION}$`);
|
|
10
|
+
/**
|
|
11
|
+
* Reads the timecodes a caption file states its timings with.
|
|
12
|
+
*
|
|
13
|
+
* Positions are returned in seconds. A malformed timecode throws rather
|
|
14
|
+
* than resolving to zero, so a file that cannot be trusted is refused
|
|
15
|
+
* instead of silently landing every caption at the start.
|
|
16
|
+
*/
|
|
17
|
+
export class CueTimecodeReader {
|
|
18
|
+
isRangeLine(line) {
|
|
19
|
+
return RANGE_LINE.test(line);
|
|
20
|
+
}
|
|
21
|
+
readRange(line) {
|
|
22
|
+
const match = RANGE_LINE.exec(line);
|
|
23
|
+
if (match === null)
|
|
24
|
+
throw new Error(`Malformed cue timecode: ${JSON.stringify(line)}`);
|
|
25
|
+
const startSeconds = this.toSeconds(match[1], match[2], match[3], match[4]);
|
|
26
|
+
const endSeconds = this.toSeconds(match[5], match[6], match[7], match[8]);
|
|
27
|
+
if (endSeconds < startSeconds) {
|
|
28
|
+
throw new Error(`Cue timecode ends before it starts: ${JSON.stringify(line)}`);
|
|
29
|
+
}
|
|
30
|
+
return { startSeconds, endSeconds };
|
|
31
|
+
}
|
|
32
|
+
readPosition(timecode) {
|
|
33
|
+
const match = POSITION_ONLY.exec(timecode);
|
|
34
|
+
if (match === null)
|
|
35
|
+
throw new Error(`Malformed timecode: ${JSON.stringify(timecode)}`);
|
|
36
|
+
return this.toSeconds(match[1], match[2], match[3], match[4]);
|
|
37
|
+
}
|
|
38
|
+
toSeconds(hours, minutes, seconds, milliseconds) {
|
|
39
|
+
return (Number(hours ?? 0) * 3600 +
|
|
40
|
+
Number(minutes) * 60 +
|
|
41
|
+
Number(seconds) +
|
|
42
|
+
Number(milliseconds.padEnd(3, '0')) / 1000);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=CueTimecodeReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueTimecodeReader.js","sourceRoot":"","sources":["../../../src/modules/transcription/CueTimecodeReader.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA,6CAA6C,CAAC;AACzE,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,IAAI,QAAQ,cAAc,QAAQ,EAAE,CAAC,CAAC;AACpE,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IAE5B,WAAW,CAAC,IAAY;QACtB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,IAAY;QACpB,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvF,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;QAC/E,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;QAC7E,IAAI,UAAU,GAAG,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,uCAAuC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;IACtC,CAAC;IAED,YAAY,CAAC,QAAgB;QAC3B,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvF,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IACnE,CAAC;IAEO,SAAS,CACf,KAAyB,EACzB,OAAe,EACf,OAAe,EACf,YAAoB;QAEpB,OAAO,CACL,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI;YACzB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC;YACf,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAC3C,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Word } from '../document/Word';
|
|
2
|
+
/**
|
|
3
|
+
* Turns the text of one cue into the words it holds, timed.
|
|
4
|
+
*
|
|
5
|
+
* Implementations differ in how much the file told them: some formats
|
|
6
|
+
* time nothing below the cue and leave the words to be guessed at,
|
|
7
|
+
* others mark when each word is spoken and can be taken at their word.
|
|
8
|
+
*/
|
|
9
|
+
export interface CueWordReader {
|
|
10
|
+
read(text: string, startSeconds: number, endSeconds: number): ReadonlyArray<Word>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CueWordReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueWordReader.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/CueWordReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;CACnF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueWordReader.js","sourceRoot":"","sources":["../../../src/modules/transcription/CueWordReader.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Word } from '../document/Word';
|
|
2
|
+
import type { CueTextTokenizer } from '../transcription/CueTextTokenizer';
|
|
3
|
+
import type { CueWordReader } from '../transcription/CueWordReader';
|
|
4
|
+
import type { WordTimingEstimator } from '../transcription/WordTimingEstimator';
|
|
5
|
+
/**
|
|
6
|
+
* Reads a cue from a format that times nothing below the cue itself.
|
|
7
|
+
* The words are known, when each is spoken is not, so the cue's own
|
|
8
|
+
* window is shared out among them.
|
|
9
|
+
*/
|
|
10
|
+
export declare class EstimatedCueWordReader implements CueWordReader {
|
|
11
|
+
private readonly tokenizer;
|
|
12
|
+
private readonly estimator;
|
|
13
|
+
constructor(tokenizer: CueTextTokenizer, estimator: WordTimingEstimator);
|
|
14
|
+
read(text: string, startSeconds: number, endSeconds: number): ReadonlyArray<Word>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=EstimatedCueWordReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EstimatedCueWordReader.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/EstimatedCueWordReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEtF;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,aAAa;IAExD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,mBAAmB;IAGjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;CAGlF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a cue from a format that times nothing below the cue itself.
|
|
3
|
+
* The words are known, when each is spoken is not, so the cue's own
|
|
4
|
+
* window is shared out among them.
|
|
5
|
+
*/
|
|
6
|
+
export class EstimatedCueWordReader {
|
|
7
|
+
tokenizer;
|
|
8
|
+
estimator;
|
|
9
|
+
constructor(tokenizer, estimator) {
|
|
10
|
+
this.tokenizer = tokenizer;
|
|
11
|
+
this.estimator = estimator;
|
|
12
|
+
}
|
|
13
|
+
read(text, startSeconds, endSeconds) {
|
|
14
|
+
return this.estimator.spread(this.tokenizer.tokenize(text), startSeconds, endSeconds);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=EstimatedCueWordReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EstimatedCueWordReader.js","sourceRoot":"","sources":["../../../src/modules/transcription/EstimatedCueWordReader.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAEd;IACA;IAFnB,YACmB,SAA2B,EAC3B,SAA8B;QAD9B,cAAS,GAAT,SAAS,CAAkB;QAC3B,cAAS,GAAT,SAAS,CAAqB;IAC9C,CAAC;IAEJ,IAAI,CAAC,IAAY,EAAE,YAAoB,EAAE,UAAkB;QACzD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACxF,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as Transformers from '@huggingface/transformers';
|
|
2
|
+
import type { LogitsProcessorList } from '@huggingface/transformers';
|
|
3
|
+
import type { WhisperLoopAbortLogitsProcessor } from '../transcription/WhisperLoopAbortLogitsProcessor';
|
|
4
|
+
/**
|
|
5
|
+
* Builds the logits-processor list a generation is handed, out of the
|
|
6
|
+
* inference library's base classes.
|
|
7
|
+
*
|
|
8
|
+
* The two subclasses below are defined here, against a module passed in,
|
|
9
|
+
* rather than at the top of their own files against a static import.
|
|
10
|
+
* `extends` runs when a module loads, so a subclass of a library class
|
|
11
|
+
* makes that library a load-time dependency of every file that can reach
|
|
12
|
+
* it — which is the whole package, through its entry point. Everything
|
|
13
|
+
* that does not need the base class stays outside: the loop guard holds
|
|
14
|
+
* its own detection and this only dresses it.
|
|
15
|
+
*
|
|
16
|
+
* Both classes are built once and reused. They close over nothing per
|
|
17
|
+
* call, and rebuilding them would give the pipeline a different
|
|
18
|
+
* `constructor` identity each time, which is exactly what the list's
|
|
19
|
+
* replacement rule compares.
|
|
20
|
+
*/
|
|
21
|
+
export declare class LogitsProcessorListFactory {
|
|
22
|
+
private readonly module;
|
|
23
|
+
private listClass;
|
|
24
|
+
private guardClass;
|
|
25
|
+
constructor(module: typeof Transformers);
|
|
26
|
+
/** A list holding `guard`, ready to be passed as `logits_processor`. */
|
|
27
|
+
build(guard: WhisperLoopAbortLogitsProcessor): LogitsProcessorList;
|
|
28
|
+
/**
|
|
29
|
+
* A processor list whose `push` replaces any already-held processor of
|
|
30
|
+
* the same class instead of appending a duplicate.
|
|
31
|
+
*
|
|
32
|
+
* The ASR pipeline reuses one options object across every window of a
|
|
33
|
+
* long transcription, and Whisper's `generate` pushes a fresh set of
|
|
34
|
+
* internal processors into the provided list on every call. On a plain
|
|
35
|
+
* list those pile up — window N would run N copies of each internal
|
|
36
|
+
* processor. Replacement reproduces the fresh-list semantics the
|
|
37
|
+
* library assumes: the newest instance wins.
|
|
38
|
+
*/
|
|
39
|
+
private replacingList;
|
|
40
|
+
/** Presents the loop guard as the processor shape the pipeline calls. */
|
|
41
|
+
private guardAdapter;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=LogitsProcessorListFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogitsProcessorListFactory.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/LogitsProcessorListFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAmB,mBAAmB,EAAU,MAAM,2BAA2B,CAAC;AAC9F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAC;AAE9G;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,0BAA0B;IAIzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,SAAS,CAAgD;IACjE,OAAO,CAAC,UAAU,CAAkF;gBAEvE,MAAM,EAAE,OAAO,YAAY;IAExD,wEAAwE;IACxE,KAAK,CAAC,KAAK,EAAE,+BAA+B,GAAG,mBAAmB;IAMlE;;;;;;;;;;OAUG;IACH,OAAO,CAAC,aAAa;IAerB,yEAAyE;IACzE,OAAO,CAAC,YAAY;CAcrB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the logits-processor list a generation is handed, out of the
|
|
3
|
+
* inference library's base classes.
|
|
4
|
+
*
|
|
5
|
+
* The two subclasses below are defined here, against a module passed in,
|
|
6
|
+
* rather than at the top of their own files against a static import.
|
|
7
|
+
* `extends` runs when a module loads, so a subclass of a library class
|
|
8
|
+
* makes that library a load-time dependency of every file that can reach
|
|
9
|
+
* it — which is the whole package, through its entry point. Everything
|
|
10
|
+
* that does not need the base class stays outside: the loop guard holds
|
|
11
|
+
* its own detection and this only dresses it.
|
|
12
|
+
*
|
|
13
|
+
* Both classes are built once and reused. They close over nothing per
|
|
14
|
+
* call, and rebuilding them would give the pipeline a different
|
|
15
|
+
* `constructor` identity each time, which is exactly what the list's
|
|
16
|
+
* replacement rule compares.
|
|
17
|
+
*/
|
|
18
|
+
export class LogitsProcessorListFactory {
|
|
19
|
+
module;
|
|
20
|
+
listClass = null;
|
|
21
|
+
guardClass = null;
|
|
22
|
+
constructor(module) {
|
|
23
|
+
this.module = module;
|
|
24
|
+
}
|
|
25
|
+
/** A list holding `guard`, ready to be passed as `logits_processor`. */
|
|
26
|
+
build(guard) {
|
|
27
|
+
const list = new (this.replacingList())();
|
|
28
|
+
list.push(new (this.guardAdapter())(guard));
|
|
29
|
+
return list;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A processor list whose `push` replaces any already-held processor of
|
|
33
|
+
* the same class instead of appending a duplicate.
|
|
34
|
+
*
|
|
35
|
+
* The ASR pipeline reuses one options object across every window of a
|
|
36
|
+
* long transcription, and Whisper's `generate` pushes a fresh set of
|
|
37
|
+
* internal processors into the provided list on every call. On a plain
|
|
38
|
+
* list those pile up — window N would run N copies of each internal
|
|
39
|
+
* processor. Replacement reproduces the fresh-list semantics the
|
|
40
|
+
* library assumes: the newest instance wins.
|
|
41
|
+
*/
|
|
42
|
+
replacingList() {
|
|
43
|
+
if (this.listClass === null) {
|
|
44
|
+
this.listClass = class extends this.module.LogitsProcessorList {
|
|
45
|
+
push(item) {
|
|
46
|
+
const existing = this.processors.findIndex((held) => held.constructor === item.constructor);
|
|
47
|
+
if (existing >= 0)
|
|
48
|
+
this.processors.splice(existing, 1);
|
|
49
|
+
super.push(item);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return this.listClass;
|
|
54
|
+
}
|
|
55
|
+
/** Presents the loop guard as the processor shape the pipeline calls. */
|
|
56
|
+
guardAdapter() {
|
|
57
|
+
if (this.guardClass === null) {
|
|
58
|
+
this.guardClass = class extends this.module.LogitsProcessor {
|
|
59
|
+
guard;
|
|
60
|
+
constructor(guard) {
|
|
61
|
+
super();
|
|
62
|
+
this.guard = guard;
|
|
63
|
+
}
|
|
64
|
+
_call(inputIds, logits) {
|
|
65
|
+
return this.guard.apply(inputIds, logits);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return this.guardClass;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=LogitsProcessorListFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogitsProcessorListFactory.js","sourceRoot":"","sources":["../../../src/modules/transcription/LogitsProcessorListFactory.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,0BAA0B;IAIR;IAHrB,SAAS,GAA2C,IAAI,CAAC;IACzD,UAAU,GAA6E,IAAI,CAAC;IAEpG,YAA6B,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAE5D,wEAAwE;IACxE,KAAK,CAAC,KAAsC;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,C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`Float32Array` PCM at the
|
|
4
|
+
* requested sample rate by demuxing the container with mediabunny and
|
|
5
|
+
* iterating the primary audio track through {@link AudioSampleSink}.
|
|
6
|
+
* Downmixes and resamples in fixed-size batches via
|
|
7
|
+
* {@link BatchedMonoResampler} so peak memory is bounded by one batch
|
|
8
|
+
* of source-rate audio plus the pre-sized target buffer, not by the
|
|
9
|
+
* whole track — a long video no longer holds ~4× its useful PCM size
|
|
10
|
+
* in transient buffers on the way to the worker.
|
|
11
|
+
*
|
|
12
|
+
* Main-thread only — `OfflineAudioContext` is not available inside
|
|
13
|
+
* Worker contexts.
|
|
14
|
+
*
|
|
15
|
+
* A codec the current browser cannot decode surfaces as a
|
|
16
|
+
* `DOMException` named `NotSupportedError`, following the WebCodecs
|
|
17
|
+
* convention. Any other underlying mediabunny / WebCodecs failure is
|
|
18
|
+
* re-thrown verbatim so callers can inspect its `name` / `cause` to
|
|
19
|
+
* classify the reason.
|
|
20
|
+
*/
|
|
21
|
+
export declare class MediaBunnyAudioDecoder implements AudioDecoder {
|
|
22
|
+
decode(audio: Blob, targetSampleRate: number, onProgress?: (progress: number) => void): Promise<Float32Array>;
|
|
23
|
+
private decodeInput;
|
|
24
|
+
private streamMonoInto;
|
|
25
|
+
private progressAt;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=MediaBunnyAudioDecoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaBunnyAudioDecoder.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/MediaBunnyAudioDecoder.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGxE;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,sBAAuB,YAAW,YAAY;IACnD,MAAM,CACV,KAAK,EAAE,IAAI,EACX,gBAAgB,EAAE,MAAM,EACxB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC,YAAY,CAAC;YASV,WAAW;YAuBX,cAAc;IAmB5B,OAAO,CAAC,UAAU;CAQnB"}
|