@tscaps/engine 0.2.1 → 0.3.0
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 +13 -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,76 @@
|
|
|
1
|
+
import { ALL_FORMATS, AudioSampleSink, BlobSource, Input, } from 'mediabunny';
|
|
2
|
+
import { BatchedMonoResampler } from '../transcription/BatchedMonoResampler';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes an audio/video Blob to mono `Float32Array` PCM at the
|
|
5
|
+
* requested sample rate by demuxing the container with mediabunny and
|
|
6
|
+
* iterating the primary audio track through {@link AudioSampleSink}.
|
|
7
|
+
* Downmixes and resamples in fixed-size batches via
|
|
8
|
+
* {@link BatchedMonoResampler} so peak memory is bounded by one batch
|
|
9
|
+
* of source-rate audio plus the pre-sized target buffer, not by the
|
|
10
|
+
* whole track — a long video no longer holds ~4× its useful PCM size
|
|
11
|
+
* in transient buffers on the way to the worker.
|
|
12
|
+
*
|
|
13
|
+
* Main-thread only — `OfflineAudioContext` is not available inside
|
|
14
|
+
* Worker contexts.
|
|
15
|
+
*
|
|
16
|
+
* A codec the current browser cannot decode surfaces as a
|
|
17
|
+
* `DOMException` named `NotSupportedError`, following the WebCodecs
|
|
18
|
+
* convention. Any other underlying mediabunny / WebCodecs failure is
|
|
19
|
+
* re-thrown verbatim so callers can inspect its `name` / `cause` to
|
|
20
|
+
* classify the reason.
|
|
21
|
+
*/
|
|
22
|
+
export class MediaBunnyAudioDecoder {
|
|
23
|
+
async decode(audio, targetSampleRate, onProgress) {
|
|
24
|
+
const input = new Input({ formats: ALL_FORMATS, source: new BlobSource(audio) });
|
|
25
|
+
try {
|
|
26
|
+
return await this.decodeInput(input, targetSampleRate, onProgress);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
input.dispose();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async decodeInput(input, targetSampleRate, onProgress) {
|
|
33
|
+
const track = await input.getPrimaryAudioTrack();
|
|
34
|
+
if (!track)
|
|
35
|
+
return new Float32Array(0);
|
|
36
|
+
if (!(await track.canDecode())) {
|
|
37
|
+
const codec = await track.getCodec();
|
|
38
|
+
throw new DOMException(`Audio codec is not supported by this browser: ${codec ?? 'unknown'}`, 'NotSupportedError');
|
|
39
|
+
}
|
|
40
|
+
const durationSeconds = await track.computeDuration();
|
|
41
|
+
if (durationSeconds <= 0)
|
|
42
|
+
return new Float32Array(0);
|
|
43
|
+
const target = new Float32Array(Math.max(1, Math.ceil(durationSeconds * targetSampleRate)));
|
|
44
|
+
const resampler = new BatchedMonoResampler(target, targetSampleRate);
|
|
45
|
+
const written = await this.streamMonoInto(track, resampler, durationSeconds, onProgress);
|
|
46
|
+
return target.subarray(0, written);
|
|
47
|
+
}
|
|
48
|
+
async streamMonoInto(track, resampler, durationSeconds, onProgress) {
|
|
49
|
+
const sink = new AudioSampleSink(track);
|
|
50
|
+
for await (const sample of sink.samples(0)) {
|
|
51
|
+
try {
|
|
52
|
+
await resampler.append(sample);
|
|
53
|
+
if (onProgress)
|
|
54
|
+
onProgress(this.progressAt(sample, durationSeconds));
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
sample.close();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (onProgress)
|
|
61
|
+
onProgress(1);
|
|
62
|
+
return resampler.flush();
|
|
63
|
+
}
|
|
64
|
+
progressAt(sample, durationSeconds) {
|
|
65
|
+
const decodedSeconds = sample.timestamp + sample.numberOfFrames / sample.sampleRate;
|
|
66
|
+
if (durationSeconds <= 0)
|
|
67
|
+
return 0;
|
|
68
|
+
const ratio = decodedSeconds / durationSeconds;
|
|
69
|
+
if (ratio < 0)
|
|
70
|
+
return 0;
|
|
71
|
+
if (ratio > 1)
|
|
72
|
+
return 1;
|
|
73
|
+
return ratio;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=MediaBunnyAudioDecoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaBunnyAudioDecoder.js","sourceRoot":"","sources":["../../../src/modules/transcription/MediaBunnyAudioDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,UAAU,EACV,KAAK,GAGN,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,sBAAsB;IACjC,KAAK,CAAC,MAAM,CACV,KAAW,EACX,gBAAwB,EACxB,UAAuC;QAEvC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;QACrE,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,WAAW,CACvB,KAAY,EACZ,gBAAwB,EACxB,UAAuC;QAEvC,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC;QACjD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;YAC/B,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;YACrC,MAAM,IAAI,YAAY,CACpB,iDAAiD,KAAK,IAAI,SAAS,EAAE,EACrE,mBAAmB,CACpB,CAAC;QACJ,CAAC;QACD,MAAM,eAAe,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;QACtD,IAAI,eAAe,IAAI,CAAC;YAAE,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAErD,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC5F,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QACzF,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,cAAc,CAC1B,KAAsB,EACtB,SAA+B,EAC/B,eAAuB,EACvB,UAAuC;QAEvC,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC;gBACH,MAAM,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC/B,IAAI,UAAU;oBAAE,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;YACvE,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;QACH,CAAC;QACD,IAAI,UAAU;YAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9B,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEO,UAAU,CAAC,MAAmB,EAAE,eAAuB;QAC7D,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC;QACpF,IAAI,eAAe,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,cAAc,GAAG,eAAe,CAAC;QAC/C,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;QACxB,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local store for the model files a transcriber downloads, so a later
|
|
3
|
+
* run reads them back instead of fetching them again.
|
|
4
|
+
*
|
|
5
|
+
* Both operations are best-effort by contract: a store that cannot
|
|
6
|
+
* answer reports a miss, and a store that cannot keep a file resolves
|
|
7
|
+
* anyway. Neither ever rejects. Losing the copy costs a download on
|
|
8
|
+
* the next run, which is worth far less than the transcription in
|
|
9
|
+
* flight.
|
|
10
|
+
*
|
|
11
|
+
* Keys are opaque strings chosen by the caller and must round-trip
|
|
12
|
+
* verbatim between `put` and `match`.
|
|
13
|
+
*/
|
|
14
|
+
export interface ModelFileCache {
|
|
15
|
+
/** The stored file, or `undefined` when this key was never kept. */
|
|
16
|
+
match(key: string): Promise<Response | undefined>;
|
|
17
|
+
/** Keeps `response` under `key`, replacing nothing already there. */
|
|
18
|
+
put(key: string, response: Response): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ModelFileCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelFileCache.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;IAElD,qEAAqE;IACrE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelFileCache.js","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCache.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raised when the runtime exposes no place to keep model files, so
|
|
3
|
+
* every run has to download them again.
|
|
4
|
+
*
|
|
5
|
+
* The Cache Storage API is restricted to secure contexts and withheld
|
|
6
|
+
* altogether by some privacy modes, so a page served over plain HTTP
|
|
7
|
+
* from anything other than localhost has nowhere to put them.
|
|
8
|
+
*
|
|
9
|
+
* The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
|
|
10
|
+
* the class, so consumers can recognise the failure across a Worker
|
|
11
|
+
* boundary (where structured cloning preserves the string fields but
|
|
12
|
+
* not the class identity) with a single source of truth.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ModelFileCacheUnavailableError extends Error {
|
|
15
|
+
static readonly ERROR_NAME = "ModelFileCacheUnavailableError";
|
|
16
|
+
readonly name = "ModelFileCacheUnavailableError";
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ModelFileCacheUnavailableError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelFileCacheUnavailableError.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCacheUnavailableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAC,QAAQ,CAAC,UAAU,oCAAoC;IAC9D,QAAQ,CAAC,IAAI,oCAA6C;CAC3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raised when the runtime exposes no place to keep model files, so
|
|
3
|
+
* every run has to download them again.
|
|
4
|
+
*
|
|
5
|
+
* The Cache Storage API is restricted to secure contexts and withheld
|
|
6
|
+
* altogether by some privacy modes, so a page served over plain HTTP
|
|
7
|
+
* from anything other than localhost has nowhere to put them.
|
|
8
|
+
*
|
|
9
|
+
* The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
|
|
10
|
+
* the class, so consumers can recognise the failure across a Worker
|
|
11
|
+
* boundary (where structured cloning preserves the string fields but
|
|
12
|
+
* not the class identity) with a single source of truth.
|
|
13
|
+
*/
|
|
14
|
+
export class ModelFileCacheUnavailableError extends Error {
|
|
15
|
+
static ERROR_NAME = 'ModelFileCacheUnavailableError';
|
|
16
|
+
name = ModelFileCacheUnavailableError.ERROR_NAME;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ModelFileCacheUnavailableError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelFileCacheUnavailableError.js","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCacheUnavailableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAU,UAAU,GAAG,gCAAgC,CAAC;IACrD,IAAI,GAAG,8BAA8B,CAAC,UAAU,CAAC"}
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
import { Document } from '../document/Document';
|
|
1
|
+
import type { Document } from '../document/Document';
|
|
2
2
|
import type { Transcriber, TranscriberOptions, TranscriberProgressEvent } from '../transcription/Transcriber';
|
|
3
3
|
/**
|
|
4
4
|
* Builds a Document by parsing a SubRip (SRT) caption file. Each cue
|
|
5
5
|
* becomes one `Segment` carrying the cue's full time range; the cue's
|
|
6
6
|
* text (multi-line entries joined with a space, formatting tags
|
|
7
|
-
* stripped) becomes one `Line
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* stripped) becomes one `Line`.
|
|
8
|
+
*
|
|
9
|
+
* SubRip times nothing below a cue, so word timings are shared out
|
|
10
|
+
* across the cue in proportion to how long each word is to write. Each
|
|
11
|
+
* word lights up in sequence rather than all at once, but where one
|
|
12
|
+
* begins is a guess, not something the file said.
|
|
10
13
|
*
|
|
11
14
|
* The audio Blob passed to `transcribe` is ignored. Useful when the
|
|
12
15
|
* caption text and timing are already known — burning a hand-authored
|
|
13
16
|
* SRT into a video, replaying captions from a previous run, etc.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
18
|
+
* A block that carries no timecode is skipped and announced through
|
|
19
|
+
* `onSkippedCueBlock`, so a single broken cue costs its own text and
|
|
20
|
+
* nothing else. Throws only when the file has blocks and none of them
|
|
21
|
+
* could be read, or when a timecode itself is malformed.
|
|
22
|
+
*
|
|
23
|
+
* Builds its own collaborators rather than receiving them. The
|
|
24
|
+
* constructor is the surface a consumer of the engine reaches for, and
|
|
25
|
+
* it asks for a source and nothing else, so this class is where the
|
|
26
|
+
* parsing side is assembled rather than a participant in someone
|
|
27
|
+
* else's assembly.
|
|
17
28
|
*/
|
|
18
29
|
export declare class SrtTranscriber implements Transcriber {
|
|
19
30
|
private readonly source;
|
|
20
31
|
onProgress?: (event: TranscriberProgressEvent) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Fired once per block left out of the document, before
|
|
34
|
+
* `transcribe` resolves, carrying the block verbatim.
|
|
35
|
+
*/
|
|
36
|
+
onSkippedCueBlock?: (block: string) => void;
|
|
37
|
+
private readonly documentBuilder;
|
|
38
|
+
private readonly wordReader;
|
|
21
39
|
constructor(source: string);
|
|
22
40
|
transcribe(_audio: Blob, _options?: TranscriberOptions): Promise<Document>;
|
|
23
|
-
private buildDocumentFromSource;
|
|
24
|
-
private parseCues;
|
|
25
|
-
private parseCueBlock;
|
|
26
|
-
private findTimecodeLineIndex;
|
|
27
|
-
private parseTimecodeLine;
|
|
28
|
-
private toSeconds;
|
|
29
|
-
private normalizeCueText;
|
|
30
|
-
private buildSegmentFromCue;
|
|
31
|
-
private distributeWordsAcrossCueRange;
|
|
32
41
|
}
|
|
33
42
|
//# sourceMappingURL=SrtTranscriber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SrtTranscriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/SrtTranscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"SrtTranscriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/SrtTranscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAM3D,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,cAAe,YAAW,WAAW;IAepC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAdnC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAEvD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmD;IACnF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAGzB;gBAE2B,MAAM,EAAE,MAAM;IAErC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAMjF"}
|
|
@@ -1,111 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { TimeFragment } from '../document/TimeFragment';
|
|
7
|
-
const SRT_TIMECODE_RE = /^(\d{1,2}):(\d{2}):(\d{2})[,.](\d{1,3})\s*-->\s*(\d{1,2}):(\d{2}):(\d{2})[,.](\d{1,3})/;
|
|
8
|
-
const FORMATTING_TAG_RE = /<[^>]+>|\{[^}]+\}/g;
|
|
9
|
-
const BOM_RE = /^\uFEFF/;
|
|
1
|
+
import { CueDocumentBuilder } from '../transcription/CueDocumentBuilder';
|
|
2
|
+
import { CueTextTokenizer } from '../transcription/CueTextTokenizer';
|
|
3
|
+
import { CueTimecodeReader } from '../transcription/CueTimecodeReader';
|
|
4
|
+
import { EstimatedCueWordReader } from '../transcription/EstimatedCueWordReader';
|
|
5
|
+
import { WordTimingEstimator } from '../transcription/WordTimingEstimator';
|
|
10
6
|
/**
|
|
11
7
|
* Builds a Document by parsing a SubRip (SRT) caption file. Each cue
|
|
12
8
|
* becomes one `Segment` carrying the cue's full time range; the cue's
|
|
13
9
|
* text (multi-line entries joined with a space, formatting tags
|
|
14
|
-
* stripped) becomes one `Line
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* stripped) becomes one `Line`.
|
|
11
|
+
*
|
|
12
|
+
* SubRip times nothing below a cue, so word timings are shared out
|
|
13
|
+
* across the cue in proportion to how long each word is to write. Each
|
|
14
|
+
* word lights up in sequence rather than all at once, but where one
|
|
15
|
+
* begins is a guess, not something the file said.
|
|
17
16
|
*
|
|
18
17
|
* The audio Blob passed to `transcribe` is ignored. Useful when the
|
|
19
18
|
* caption text and timing are already known — burning a hand-authored
|
|
20
19
|
* SRT into a video, replaying captions from a previous run, etc.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* A block that carries no timecode is skipped and announced through
|
|
22
|
+
* `onSkippedCueBlock`, so a single broken cue costs its own text and
|
|
23
|
+
* nothing else. Throws only when the file has blocks and none of them
|
|
24
|
+
* could be read, or when a timecode itself is malformed.
|
|
25
|
+
*
|
|
26
|
+
* Builds its own collaborators rather than receiving them. The
|
|
27
|
+
* constructor is the surface a consumer of the engine reaches for, and
|
|
28
|
+
* it asks for a source and nothing else, so this class is where the
|
|
29
|
+
* parsing side is assembled rather than a participant in someone
|
|
30
|
+
* else's assembly.
|
|
24
31
|
*/
|
|
25
32
|
export class SrtTranscriber {
|
|
26
33
|
source;
|
|
27
34
|
onProgress;
|
|
35
|
+
/**
|
|
36
|
+
* Fired once per block left out of the document, before
|
|
37
|
+
* `transcribe` resolves, carrying the block verbatim.
|
|
38
|
+
*/
|
|
39
|
+
onSkippedCueBlock;
|
|
40
|
+
documentBuilder = new CueDocumentBuilder(new CueTimecodeReader());
|
|
41
|
+
wordReader = new EstimatedCueWordReader(new CueTextTokenizer(), new WordTimingEstimator());
|
|
28
42
|
constructor(source) {
|
|
29
43
|
this.source = source;
|
|
30
44
|
}
|
|
31
45
|
async transcribe(_audio, _options) {
|
|
32
46
|
this.onProgress?.({ stage: 'inferring', progress: 1 });
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const section = new Section({ segments, kind: '' });
|
|
38
|
-
return new Document({ sections: [section] });
|
|
39
|
-
}
|
|
40
|
-
parseCues(source) {
|
|
41
|
-
const normalized = source.replace(BOM_RE, '').replace(/\r\n?/g, '\n').trim();
|
|
42
|
-
if (normalized.length === 0)
|
|
43
|
-
return [];
|
|
44
|
-
return normalized
|
|
45
|
-
.split(/\n{2,}/)
|
|
46
|
-
.map((block) => this.parseCueBlock(block))
|
|
47
|
-
.filter((cue) => cue !== null);
|
|
48
|
-
}
|
|
49
|
-
parseCueBlock(block) {
|
|
50
|
-
const lines = block.split('\n').map((l) => l.trim()).filter((l) => l.length > 0);
|
|
51
|
-
if (lines.length === 0)
|
|
52
|
-
return null;
|
|
53
|
-
const timecodeLineIndex = this.findTimecodeLineIndex(lines);
|
|
54
|
-
if (timecodeLineIndex === -1) {
|
|
55
|
-
throw new Error(`SRT block has no timecode line: ${JSON.stringify(block)}`);
|
|
56
|
-
}
|
|
57
|
-
const range = this.parseTimecodeLine(lines[timecodeLineIndex]);
|
|
58
|
-
const text = this.normalizeCueText(lines.slice(timecodeLineIndex + 1));
|
|
59
|
-
if (text.length === 0)
|
|
60
|
-
return null;
|
|
61
|
-
return { startSeconds: range.startSeconds, endSeconds: range.endSeconds, text };
|
|
62
|
-
}
|
|
63
|
-
findTimecodeLineIndex(lines) {
|
|
64
|
-
return lines.findIndex((line) => SRT_TIMECODE_RE.test(line));
|
|
65
|
-
}
|
|
66
|
-
parseTimecodeLine(line) {
|
|
67
|
-
const match = SRT_TIMECODE_RE.exec(line);
|
|
68
|
-
if (match === null)
|
|
69
|
-
throw new Error(`Malformed SRT timecode: ${JSON.stringify(line)}`);
|
|
70
|
-
const startSeconds = this.toSeconds(match[1], match[2], match[3], match[4]);
|
|
71
|
-
const endSeconds = this.toSeconds(match[5], match[6], match[7], match[8]);
|
|
72
|
-
if (endSeconds < startSeconds) {
|
|
73
|
-
throw new Error(`SRT timecode ends before it starts: ${JSON.stringify(line)}`);
|
|
74
|
-
}
|
|
75
|
-
return { startSeconds, endSeconds };
|
|
76
|
-
}
|
|
77
|
-
toSeconds(hours, minutes, seconds, milliseconds) {
|
|
78
|
-
return (Number(hours) * 3600 +
|
|
79
|
-
Number(minutes) * 60 +
|
|
80
|
-
Number(seconds) +
|
|
81
|
-
Number(milliseconds.padEnd(3, '0')) / 1000);
|
|
82
|
-
}
|
|
83
|
-
normalizeCueText(textLines) {
|
|
84
|
-
return textLines.join(' ').replace(FORMATTING_TAG_RE, '').replace(/\s+/g, ' ').trim();
|
|
85
|
-
}
|
|
86
|
-
buildSegmentFromCue(cue) {
|
|
87
|
-
const tokens = cue.text.split(/\s+/).filter((token) => token.length > 0);
|
|
88
|
-
if (tokens.length === 0) {
|
|
89
|
-
return new Segment({ lines: [new Line({ words: [] })] });
|
|
90
|
-
}
|
|
91
|
-
const words = this.distributeWordsAcrossCueRange(tokens, cue.startSeconds, cue.endSeconds);
|
|
92
|
-
return new Segment({ lines: [new Line({ words })] });
|
|
93
|
-
}
|
|
94
|
-
distributeWordsAcrossCueRange(tokens, startSeconds, endSeconds) {
|
|
95
|
-
const totalWeight = tokens.reduce((sum, token) => sum + token.length, 0);
|
|
96
|
-
const cueDuration = endSeconds - startSeconds;
|
|
97
|
-
if (totalWeight === 0 || cueDuration <= 0) {
|
|
98
|
-
return tokens.map((token) => new Word({ text: token, time: new TimeFragment(startSeconds, endSeconds) }));
|
|
99
|
-
}
|
|
100
|
-
const words = [];
|
|
101
|
-
let elapsedWeight = 0;
|
|
102
|
-
for (const token of tokens) {
|
|
103
|
-
const wordStart = startSeconds + (elapsedWeight / totalWeight) * cueDuration;
|
|
104
|
-
elapsedWeight += token.length;
|
|
105
|
-
const wordEnd = startSeconds + (elapsedWeight / totalWeight) * cueDuration;
|
|
106
|
-
words.push(new Word({ text: token, time: new TimeFragment(wordStart, wordEnd) }));
|
|
107
|
-
}
|
|
108
|
-
return words;
|
|
47
|
+
const result = this.documentBuilder.build(this.source, this.wordReader);
|
|
48
|
+
for (const block of result.skippedBlocks)
|
|
49
|
+
this.onSkippedCueBlock?.(block);
|
|
50
|
+
return result.document;
|
|
109
51
|
}
|
|
110
52
|
}
|
|
111
53
|
//# sourceMappingURL=SrtTranscriber.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SrtTranscriber.js","sourceRoot":"","sources":["../../../src/modules/transcription/SrtTranscriber.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SrtTranscriber.js","sourceRoot":"","sources":["../../../src/modules/transcription/SrtTranscriber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAOjF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,cAAc;IAeI;IAd7B,UAAU,CAA6C;IAEvD;;;OAGG;IACH,iBAAiB,CAA2B;IAE3B,eAAe,GAAG,IAAI,kBAAkB,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;IAClE,UAAU,GAAG,IAAI,sBAAsB,CACtD,IAAI,gBAAgB,EAAE,EACtB,IAAI,mBAAmB,EAAE,CAC1B,CAAC;IAEF,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,KAAK,CAAC,UAAU,CAAC,MAAY,EAAE,QAA6B;QAC1D,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACxE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,aAAa;YAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raised when a caption file yielded no cues at all and at least one
|
|
3
|
+
* of its blocks was unreadable.
|
|
4
|
+
*
|
|
5
|
+
* Skipping the odd broken block leaves a usable file behind; skipping
|
|
6
|
+
* every block does not, and handing back an empty transcript would
|
|
7
|
+
* read as "this file said nothing" rather than "this file could not
|
|
8
|
+
* be understood".
|
|
9
|
+
*
|
|
10
|
+
* A file that is genuinely empty is not this: it yields an empty
|
|
11
|
+
* document, because there is nothing to misread.
|
|
12
|
+
*
|
|
13
|
+
* The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
|
|
14
|
+
* the class, so consumers can recognise the failure across a Worker
|
|
15
|
+
* boundary (where structured cloning preserves the string fields but
|
|
16
|
+
* not the class identity) with a single source of truth.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SubtitleFileUnreadableError extends Error {
|
|
19
|
+
static readonly ERROR_NAME = "SubtitleFileUnreadableError";
|
|
20
|
+
readonly name = "SubtitleFileUnreadableError";
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=SubtitleFileUnreadableError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubtitleFileUnreadableError.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/SubtitleFileUnreadableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,MAAM,CAAC,QAAQ,CAAC,UAAU,iCAAiC;IAC3D,QAAQ,CAAC,IAAI,iCAA0C;CACxD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raised when a caption file yielded no cues at all and at least one
|
|
3
|
+
* of its blocks was unreadable.
|
|
4
|
+
*
|
|
5
|
+
* Skipping the odd broken block leaves a usable file behind; skipping
|
|
6
|
+
* every block does not, and handing back an empty transcript would
|
|
7
|
+
* read as "this file said nothing" rather than "this file could not
|
|
8
|
+
* be understood".
|
|
9
|
+
*
|
|
10
|
+
* A file that is genuinely empty is not this: it yields an empty
|
|
11
|
+
* document, because there is nothing to misread.
|
|
12
|
+
*
|
|
13
|
+
* The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
|
|
14
|
+
* the class, so consumers can recognise the failure across a Worker
|
|
15
|
+
* boundary (where structured cloning preserves the string fields but
|
|
16
|
+
* not the class identity) with a single source of truth.
|
|
17
|
+
*/
|
|
18
|
+
export class SubtitleFileUnreadableError extends Error {
|
|
19
|
+
static ERROR_NAME = 'SubtitleFileUnreadableError';
|
|
20
|
+
name = SubtitleFileUnreadableError.ERROR_NAME;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=SubtitleFileUnreadableError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubtitleFileUnreadableError.js","sourceRoot":"","sources":["../../../src/modules/transcription/SubtitleFileUnreadableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,MAAM,CAAU,UAAU,GAAG,6BAA6B,CAAC;IAClD,IAAI,GAAG,2BAA2B,CAAC,UAAU,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Word } from '../document/Word';
|
|
2
|
+
import type { CueTextTokenizer } from '../transcription/CueTextTokenizer';
|
|
3
|
+
import type { CueTimecodeReader } from '../transcription/CueTimecodeReader';
|
|
4
|
+
import type { CueWordReader } from '../transcription/CueWordReader';
|
|
5
|
+
import type { WordTimingEstimator } from '../transcription/WordTimingEstimator';
|
|
6
|
+
/**
|
|
7
|
+
* Reads a cue from a format that can mark, inside the cue's own text,
|
|
8
|
+
* when a word is spoken — WebVTT does this so a caption can be revealed
|
|
9
|
+
* word by word without being broken into an entry per word.
|
|
10
|
+
*
|
|
11
|
+
* Each mark cuts the cue into a stretch that runs until the next mark,
|
|
12
|
+
* and the words of a stretch share it out between them. A mark before
|
|
13
|
+
* every word therefore yields the timing the file recorded; a mark
|
|
14
|
+
* every few words yields those, with the words between them estimated.
|
|
15
|
+
* A cue carrying no marks at all is one stretch, which is the same
|
|
16
|
+
* answer a format without marks would give.
|
|
17
|
+
*/
|
|
18
|
+
export declare class TimestampedCueWordReader implements CueWordReader {
|
|
19
|
+
private readonly tokenizer;
|
|
20
|
+
private readonly timecodeReader;
|
|
21
|
+
private readonly estimator;
|
|
22
|
+
constructor(tokenizer: CueTextTokenizer, timecodeReader: CueTimecodeReader, estimator: WordTimingEstimator);
|
|
23
|
+
read(text: string, startSeconds: number, endSeconds: number): ReadonlyArray<Word>;
|
|
24
|
+
private cutIntoStretches;
|
|
25
|
+
private positionOf;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=TimestampedCueWordReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimestampedCueWordReader.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/TimestampedCueWordReader.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,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAYtF;;;;;;;;;;;GAWG;AACH,qBAAa,wBAAyB,YAAW,aAAa;IAE1D,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAFT,SAAS,EAAE,gBAAgB,EAC3B,cAAc,EAAE,iBAAiB,EACjC,SAAS,EAAE,mBAAmB;IAGjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;IAWjF,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,UAAU;CAGnB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** A cue timestamp: a position on its own inside the cue's text. */
|
|
2
|
+
const CUE_TIMESTAMP = /<(?:\d{1,3}:)?\d{2}:\d{2}[.,]\d{1,3}>/g;
|
|
3
|
+
/**
|
|
4
|
+
* Reads a cue from a format that can mark, inside the cue's own text,
|
|
5
|
+
* when a word is spoken — WebVTT does this so a caption can be revealed
|
|
6
|
+
* word by word without being broken into an entry per word.
|
|
7
|
+
*
|
|
8
|
+
* Each mark cuts the cue into a stretch that runs until the next mark,
|
|
9
|
+
* and the words of a stretch share it out between them. A mark before
|
|
10
|
+
* every word therefore yields the timing the file recorded; a mark
|
|
11
|
+
* every few words yields those, with the words between them estimated.
|
|
12
|
+
* A cue carrying no marks at all is one stretch, which is the same
|
|
13
|
+
* answer a format without marks would give.
|
|
14
|
+
*/
|
|
15
|
+
export class TimestampedCueWordReader {
|
|
16
|
+
tokenizer;
|
|
17
|
+
timecodeReader;
|
|
18
|
+
estimator;
|
|
19
|
+
constructor(tokenizer, timecodeReader, estimator) {
|
|
20
|
+
this.tokenizer = tokenizer;
|
|
21
|
+
this.timecodeReader = timecodeReader;
|
|
22
|
+
this.estimator = estimator;
|
|
23
|
+
}
|
|
24
|
+
read(text, startSeconds, endSeconds) {
|
|
25
|
+
return this.cutIntoStretches(text, startSeconds, endSeconds)
|
|
26
|
+
.flatMap((stretch) => [
|
|
27
|
+
...this.estimator.spread(this.tokenizer.tokenize(stretch.text), stretch.startSeconds, stretch.endSeconds),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
cutIntoStretches(text, startSeconds, endSeconds) {
|
|
31
|
+
const stretches = [];
|
|
32
|
+
let textFrom = 0;
|
|
33
|
+
let stretchStart = startSeconds;
|
|
34
|
+
for (const mark of text.matchAll(CUE_TIMESTAMP)) {
|
|
35
|
+
const markAt = this.positionOf(mark[0]);
|
|
36
|
+
const markFrom = mark.index ?? 0;
|
|
37
|
+
stretches.push({
|
|
38
|
+
text: text.slice(textFrom, markFrom),
|
|
39
|
+
startSeconds: stretchStart,
|
|
40
|
+
endSeconds: markAt,
|
|
41
|
+
});
|
|
42
|
+
textFrom = markFrom + mark[0].length;
|
|
43
|
+
stretchStart = markAt;
|
|
44
|
+
}
|
|
45
|
+
stretches.push({ text: text.slice(textFrom), startSeconds: stretchStart, endSeconds });
|
|
46
|
+
return stretches;
|
|
47
|
+
}
|
|
48
|
+
positionOf(mark) {
|
|
49
|
+
return this.timecodeReader.readPosition(mark.slice(1, -1));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=TimestampedCueWordReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimestampedCueWordReader.js","sourceRoot":"","sources":["../../../src/modules/transcription/TimestampedCueWordReader.ts"],"names":[],"mappings":"AAMA,oEAAoE;AACpE,MAAM,aAAa,GAAG,wCAAwC,CAAC;AAS/D;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,wBAAwB;IAEhB;IACA;IACA;IAHnB,YACmB,SAA2B,EAC3B,cAAiC,EACjC,SAA8B;QAF9B,cAAS,GAAT,SAAS,CAAkB;QAC3B,mBAAc,GAAd,cAAc,CAAmB;QACjC,cAAS,GAAT,SAAS,CAAqB;IAC9C,CAAC;IAEJ,IAAI,CAAC,IAAY,EAAE,YAAoB,EAAE,UAAkB;QACzD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,CAAC;aACzD,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACpB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CACtB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EACrC,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,UAAU,CACnB;SACF,CAAC,CAAC;IACP,CAAC;IAEO,gBAAgB,CACtB,IAAY,EACZ,YAAoB,EACpB,UAAkB;QAElB,MAAM,SAAS,GAAmB,EAAE,CAAC;QACrC,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,YAAY,GAAG,YAAY,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;YACjC,SAAS,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBACpC,YAAY,EAAE,YAAY;gBAC1B,UAAU,EAAE,MAAM;aACnB,CAAC,CAAC;YACH,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACrC,YAAY,GAAG,MAAM,CAAC;QACxB,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;QACvF,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -16,8 +16,21 @@ export type TranscriberProgressEvent = {
|
|
|
16
16
|
stage: 'inferring';
|
|
17
17
|
progress?: number;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* An audio region, in absolute seconds, that transcription deliberately
|
|
21
|
+
* left empty because decoding produced no trustworthy output for it.
|
|
22
|
+
*/
|
|
23
|
+
export interface UntranscribedRegion {
|
|
24
|
+
startSeconds: number;
|
|
25
|
+
endSeconds: number;
|
|
26
|
+
}
|
|
19
27
|
export interface Transcriber {
|
|
20
28
|
onProgress?: (event: TranscriberProgressEvent) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Fired at most once per region, before `transcribe` resolves.
|
|
31
|
+
* Implementations that always cover the full audio never fire it.
|
|
32
|
+
*/
|
|
33
|
+
onUntranscribedRegion?: (region: UntranscribedRegion) => void;
|
|
21
34
|
transcribe(audio: Blob, options?: TranscriberOptions): Promise<Document>;
|
|
22
35
|
}
|
|
23
36
|
//# sourceMappingURL=Transcriber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transcriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/Transcriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACvD,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC1E"}
|
|
1
|
+
{"version":3,"file":"Transcriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/Transcriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACvD;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC9D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC1E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type * as Transformers from '@huggingface/transformers';
|
|
2
|
+
import type { ModelFileCache } from '../transcription/ModelFileCache';
|
|
3
|
+
/**
|
|
4
|
+
* The inference library, loaded on first use and configured once.
|
|
5
|
+
*
|
|
6
|
+
* It is reached through a dynamic import because a static one makes the
|
|
7
|
+
* whole ONNX runtime a dependency of merely *naming* a transcriber: the
|
|
8
|
+
* package's entry point re-exports this module, so a consumer that
|
|
9
|
+
* imports a document node pulls the runtime with it. In a browser that
|
|
10
|
+
* is a large bundle nobody asked for; in Node it is a native binding
|
|
11
|
+
* loaded — and on musl, failed — for code that never runs inference.
|
|
12
|
+
*
|
|
13
|
+
* The environment settings live here rather than at the call site
|
|
14
|
+
* because they have to be applied before the first pipeline is built and
|
|
15
|
+
* exactly once. Holding the module and the settings together is what
|
|
16
|
+
* makes "loaded" and "configured" the same event.
|
|
17
|
+
*
|
|
18
|
+
* A failed load is not cached: the import can fail on a dead network the
|
|
19
|
+
* same way the weights can, and a caller retrying deserves to reach the
|
|
20
|
+
* network again.
|
|
21
|
+
*/
|
|
22
|
+
export declare class TransformersRuntime {
|
|
23
|
+
private readonly modelFileCache?;
|
|
24
|
+
private modulePromise;
|
|
25
|
+
constructor(modelFileCache?: ModelFileCache | undefined);
|
|
26
|
+
/**
|
|
27
|
+
* Resolves with the library, configured. Concurrent callers share one
|
|
28
|
+
* load, and the settings are applied before any of them sees it.
|
|
29
|
+
*/
|
|
30
|
+
load(): Promise<typeof Transformers>;
|
|
31
|
+
private configure;
|
|
32
|
+
/**
|
|
33
|
+
* Takes over where the downloaded model files are kept.
|
|
34
|
+
*
|
|
35
|
+
* Left to itself the library picks a store from the environment and
|
|
36
|
+
* discards a refused write with nothing but a console warning, so a
|
|
37
|
+
* caller that wants to know when the files did not survive the run
|
|
38
|
+
* has to own the store. Without one, that default stands.
|
|
39
|
+
*/
|
|
40
|
+
private installModelFileCache;
|
|
41
|
+
/**
|
|
42
|
+
* Raises the WASM thread count above ORT's built-in ceiling when the
|
|
43
|
+
* runtime supports it. ORT locks the count to 1 without cross-origin
|
|
44
|
+
* isolation, and even with isolation its own default caps at 4 no matter
|
|
45
|
+
* the machine — Whisper's encoder scales past that. On a WebGPU run this
|
|
46
|
+
* has no effect; the WASM backend is not touched.
|
|
47
|
+
*/
|
|
48
|
+
private configureWasmThreading;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=TransformersRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformersRuntime.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/TransformersRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAmB;IAGlB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAF5C,OAAO,CAAC,aAAa,CAA6C;gBAErC,cAAc,CAAC,EAAE,cAAc,YAAA;IAE5D;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,OAAO,YAAY,CAAC;IAcpC,OAAO,CAAC,SAAS;IAMjB;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;IAM7B;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;CAM/B"}
|