@omnimedia/omnitool 1.0.0 → 1.1.0-10
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/LICENSE +21 -0
- package/README.md +120 -2
- package/package.json +59 -27
- package/s/_archive/types.ts +107 -0
- package/s/context.ts +7 -0
- package/s/demo/demo.bundle.ts +68 -0
- package/s/demo/demo.css +59 -0
- package/s/demo/routines/filmstrip-test.ts +68 -0
- package/s/demo/routines/load-video.ts +7 -0
- package/s/demo/routines/transcode-test.ts +46 -0
- package/s/demo/routines/transcriber-test.ts +34 -0
- package/s/demo/routines/transitions-test.ts +43 -0
- package/s/demo/routines/waveform-test.ts +12 -0
- package/s/driver/driver.test.ts +15 -0
- package/s/driver/driver.ts +124 -0
- package/s/driver/driver.worker.bundle.ts +7 -0
- package/s/driver/fns/host.ts +13 -0
- package/s/driver/fns/schematic.ts +106 -0
- package/s/driver/fns/work.ts +249 -0
- package/s/driver/parts/constants.ts +17 -0
- package/s/driver/parts/machina.ts +27 -0
- package/s/driver/utils/load-decoder-source.ts +12 -0
- package/s/driver/utils/sleep.ts +3 -0
- package/s/features/speech/transcribe/default-spec.ts +11 -0
- package/s/features/speech/transcribe/parts/load-pipe.ts +19 -0
- package/s/features/speech/transcribe/parts/prep-audio.ts +23 -0
- package/s/features/speech/transcribe/parts/transcribe.ts +70 -0
- package/s/features/speech/transcribe/transcriber.ts +46 -0
- package/s/features/speech/transcribe/types.ts +82 -0
- package/s/features/speech/transcribe/worker.bundle.ts +40 -0
- package/s/features/transition/parts/fragment.ts +24 -0
- package/s/features/transition/parts/types.ts +94 -0
- package/s/features/transition/parts/uniforms.ts +29 -0
- package/s/features/transition/parts/vertex.ts +31 -0
- package/s/features/transition/transition.ts +60 -0
- package/s/index.html.ts +58 -0
- package/s/index.ts +2 -39
- package/s/tests.test.ts +8 -0
- package/s/timeline/index.ts +15 -0
- package/s/timeline/parts/basics.ts +17 -0
- package/s/timeline/parts/compositor/export.ts +77 -0
- package/s/timeline/parts/compositor/parts/html-tree.ts +37 -0
- package/s/timeline/parts/compositor/parts/schedulers.ts +85 -0
- package/s/timeline/parts/compositor/parts/tree-builder.ts +184 -0
- package/s/timeline/parts/compositor/parts/webcodecs-tree.ts +30 -0
- package/s/timeline/parts/compositor/playback.ts +81 -0
- package/s/timeline/parts/compositor/samplers/html.ts +115 -0
- package/s/timeline/parts/compositor/samplers/webcodecs.ts +60 -0
- package/s/timeline/parts/filmstrip.ts +159 -0
- package/s/timeline/parts/item.ts +90 -0
- package/s/timeline/parts/media.ts +35 -0
- package/s/timeline/parts/resource-pool.ts +27 -0
- package/s/timeline/parts/resource.ts +11 -0
- package/s/timeline/parts/waveform.ts +62 -0
- package/s/timeline/sugar/builders.ts +102 -0
- package/s/timeline/sugar/o.ts +150 -0
- package/s/timeline/sugar/omni-test.ts +38 -0
- package/s/timeline/sugar/omni.ts +40 -0
- package/s/timeline/types.ts +29 -0
- package/s/timeline/utils/audio-stream.ts +15 -0
- package/s/timeline/utils/checksum.ts +20 -0
- package/s/timeline/utils/datafile.ts +21 -0
- package/s/timeline/utils/dummy-data.ts +7 -0
- package/s/timeline/utils/matrix.ts +33 -0
- package/s/timeline/utils/video-cursor.ts +40 -0
- package/s/tools/common/loader.ts +26 -0
- package/s/tools/common/transformer-pipeline.ts +26 -0
- package/s/tools/speech-recognition/common/model.ts +26 -0
- package/s/tools/speech-recognition/whisper/fns/host.ts +25 -0
- package/s/tools/speech-recognition/whisper/fns/schematic.ts +23 -0
- package/s/tools/speech-recognition/whisper/fns/work.ts +91 -0
- package/s/tools/speech-recognition/whisper/parts/types.ts +38 -0
- package/s/tools/speech-recognition/whisper/parts/worker.bundle.ts +7 -0
- package/s/tools/speech-recognition/whisper/tool.ts +70 -0
- package/x/context.d.ts +4 -0
- package/x/context.js +6 -0
- package/x/context.js.map +1 -0
- package/x/demo/demo.bundle.d.ts +1 -0
- package/x/demo/demo.bundle.js +55 -0
- package/x/demo/demo.bundle.js.map +1 -0
- package/x/demo/demo.bundle.min.js +120 -0
- package/x/demo/demo.bundle.min.js.map +7 -0
- package/x/demo/demo.css +59 -0
- package/x/demo/routines/filmstrip-test.d.ts +1 -0
- package/x/demo/routines/filmstrip-test.js +62 -0
- package/x/demo/routines/filmstrip-test.js.map +1 -0
- package/x/demo/routines/load-video.d.ts +1 -0
- package/x/demo/routines/load-video.js +6 -0
- package/x/demo/routines/load-video.js.map +1 -0
- package/x/demo/routines/transcode-test.d.ts +6 -0
- package/x/demo/routines/transcode-test.js +40 -0
- package/x/demo/routines/transcode-test.js.map +1 -0
- package/x/demo/routines/transcriber-test.d.ts +4 -0
- package/x/demo/routines/transcriber-test.js +33 -0
- package/x/demo/routines/transcriber-test.js.map +1 -0
- package/x/demo/routines/transitions-test.d.ts +5 -0
- package/x/demo/routines/transitions-test.js +35 -0
- package/x/demo/routines/transitions-test.js.map +1 -0
- package/x/demo/routines/waveform-test.d.ts +1 -0
- package/x/demo/routines/waveform-test.js +11 -0
- package/x/demo/routines/waveform-test.js.map +1 -0
- package/x/driver/driver.d.ts +20 -0
- package/x/driver/driver.js +104 -0
- package/x/driver/driver.js.map +1 -0
- package/x/driver/driver.test.d.ts +5 -0
- package/x/driver/driver.test.js +12 -0
- package/x/driver/driver.test.js.map +1 -0
- package/x/driver/driver.worker.bundle.d.ts +1 -0
- package/x/driver/driver.worker.bundle.js +4 -0
- package/x/driver/driver.worker.bundle.js.map +1 -0
- package/x/driver/driver.worker.bundle.min.js +3537 -0
- package/x/driver/driver.worker.bundle.min.js.map +7 -0
- package/x/driver/fns/host.d.ts +25 -0
- package/x/driver/fns/host.js +7 -0
- package/x/driver/fns/host.js.map +1 -0
- package/x/driver/fns/schematic.d.ts +84 -0
- package/x/driver/fns/schematic.js +2 -0
- package/x/driver/fns/schematic.js.map +1 -0
- package/x/driver/fns/work.d.ts +26 -0
- package/x/driver/fns/work.js +201 -0
- package/x/driver/fns/work.js.map +1 -0
- package/x/driver/parts/constants.d.ts +2 -0
- package/x/driver/parts/constants.js +17 -0
- package/x/driver/parts/constants.js.map +1 -0
- package/x/driver/parts/machina.d.ts +23 -0
- package/x/driver/parts/machina.js +14 -0
- package/x/driver/parts/machina.js.map +1 -0
- package/x/driver/utils/load-decoder-source.d.ts +3 -0
- package/x/driver/utils/load-decoder-source.js +11 -0
- package/x/driver/utils/load-decoder-source.js.map +1 -0
- package/x/driver/utils/sleep.d.ts +1 -0
- package/x/driver/utils/sleep.js +4 -0
- package/x/driver/utils/sleep.js.map +1 -0
- package/x/features/speech/transcribe/default-spec.d.ts +2 -0
- package/x/features/speech/transcribe/default-spec.js +8 -0
- package/x/features/speech/transcribe/default-spec.js.map +1 -0
- package/x/features/speech/transcribe/parts/load-pipe.d.ts +2 -0
- package/x/features/speech/transcribe/parts/load-pipe.js +13 -0
- package/x/features/speech/transcribe/parts/load-pipe.js.map +1 -0
- package/x/features/speech/transcribe/parts/prep-audio.d.ts +5 -0
- package/x/features/speech/transcribe/parts/prep-audio.js +21 -0
- package/x/features/speech/transcribe/parts/prep-audio.js.map +1 -0
- package/x/features/speech/transcribe/parts/transcribe.d.ts +5 -0
- package/x/features/speech/transcribe/parts/transcribe.js +56 -0
- package/x/features/speech/transcribe/parts/transcribe.js.map +1 -0
- package/x/features/speech/transcribe/transcriber.d.ts +5 -0
- package/x/features/speech/transcribe/transcriber.js +33 -0
- package/x/features/speech/transcribe/transcriber.js.map +1 -0
- package/x/features/speech/transcribe/types.d.ts +66 -0
- package/x/features/speech/transcribe/types.js.map +1 -0
- package/x/features/speech/transcribe/worker.bundle.d.ts +1 -0
- package/x/features/speech/transcribe/worker.bundle.js +33 -0
- package/x/features/speech/transcribe/worker.bundle.js.map +1 -0
- package/x/features/speech/transcribe/worker.bundle.min.js +2916 -0
- package/x/features/speech/transcribe/worker.bundle.min.js.map +7 -0
- package/x/features/transition/parts/fragment.d.ts +1 -0
- package/x/features/transition/parts/fragment.js +25 -0
- package/x/features/transition/parts/fragment.js.map +1 -0
- package/x/features/transition/parts/types.d.ts +23 -0
- package/x/features/transition/parts/types.js +2 -0
- package/x/features/transition/parts/types.js.map +1 -0
- package/x/features/transition/parts/uniforms.d.ts +31 -0
- package/x/features/transition/parts/uniforms.js +27 -0
- package/x/features/transition/parts/uniforms.js.map +1 -0
- package/x/features/transition/parts/vertex.d.ts +1 -0
- package/x/features/transition/parts/vertex.js +32 -0
- package/x/features/transition/parts/vertex.js.map +1 -0
- package/x/features/transition/transition.d.ts +5 -0
- package/x/features/transition/transition.js +50 -0
- package/x/features/transition/transition.js.map +1 -0
- package/x/index.d.ts +2 -9
- package/x/index.html +115 -0
- package/x/index.html.d.ts +2 -0
- package/x/index.html.js +52 -0
- package/x/index.html.js.map +1 -0
- package/x/index.js +2 -29
- package/x/index.js.map +1 -1
- package/x/tests.test.d.ts +1 -0
- package/x/tests.test.js +6 -0
- package/x/tests.test.js.map +1 -0
- package/x/timeline/index.d.ts +11 -0
- package/x/timeline/index.js +12 -0
- package/x/timeline/index.js.map +1 -0
- package/x/timeline/parts/basics.d.ts +12 -0
- package/x/timeline/parts/basics.js +2 -0
- package/x/timeline/parts/basics.js.map +1 -0
- package/x/timeline/parts/compositor/export.d.ts +9 -0
- package/x/timeline/parts/compositor/export.js +64 -0
- package/x/timeline/parts/compositor/export.js.map +1 -0
- package/x/timeline/parts/compositor/parts/html-tree.d.ts +3 -0
- package/x/timeline/parts/compositor/parts/html-tree.js +40 -0
- package/x/timeline/parts/compositor/parts/html-tree.js.map +1 -0
- package/x/timeline/parts/compositor/parts/schedulers.d.ts +15 -0
- package/x/timeline/parts/compositor/parts/schedulers.js +64 -0
- package/x/timeline/parts/compositor/parts/schedulers.js.map +1 -0
- package/x/timeline/parts/compositor/parts/tree-builder.d.ts +37 -0
- package/x/timeline/parts/compositor/parts/tree-builder.js +147 -0
- package/x/timeline/parts/compositor/parts/tree-builder.js.map +1 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.d.ts +3 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.js +28 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.js.map +1 -0
- package/x/timeline/parts/compositor/playback.d.ts +19 -0
- package/x/timeline/parts/compositor/playback.js +71 -0
- package/x/timeline/parts/compositor/playback.js.map +1 -0
- package/x/timeline/parts/compositor/samplers/html.d.ts +3 -0
- package/x/timeline/parts/compositor/samplers/html.js +106 -0
- package/x/timeline/parts/compositor/samplers/html.js.map +1 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.d.ts +2 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js +55 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js.map +1 -0
- package/x/timeline/parts/filmstrip.d.ts +39 -0
- package/x/timeline/parts/filmstrip.js +117 -0
- package/x/timeline/parts/filmstrip.js.map +1 -0
- package/x/timeline/parts/item.d.ts +68 -0
- package/x/timeline/parts/item.js +16 -0
- package/x/timeline/parts/item.js.map +1 -0
- package/x/timeline/parts/media.d.ts +10 -0
- package/x/timeline/parts/media.js +30 -0
- package/x/timeline/parts/media.js.map +1 -0
- package/x/timeline/parts/resource-pool.d.ts +7 -0
- package/x/timeline/parts/resource-pool.js +19 -0
- package/x/timeline/parts/resource-pool.js.map +1 -0
- package/x/timeline/parts/resource.d.ts +8 -0
- package/x/timeline/parts/resource.js +2 -0
- package/x/timeline/parts/resource.js.map +1 -0
- package/x/timeline/parts/waveform.d.ts +8 -0
- package/x/timeline/parts/waveform.js +51 -0
- package/x/timeline/parts/waveform.js.map +1 -0
- package/x/timeline/sugar/builders.d.ts +1 -0
- package/x/timeline/sugar/builders.js +104 -0
- package/x/timeline/sugar/builders.js.map +1 -0
- package/x/timeline/sugar/o.d.ts +32 -0
- package/x/timeline/sugar/o.js +114 -0
- package/x/timeline/sugar/o.js.map +1 -0
- package/x/timeline/sugar/omni-test.d.ts +1 -0
- package/x/timeline/sugar/omni-test.js +22 -0
- package/x/timeline/sugar/omni-test.js.map +1 -0
- package/x/timeline/sugar/omni.d.ts +14 -0
- package/x/timeline/sugar/omni.js +28 -0
- package/x/timeline/sugar/omni.js.map +1 -0
- package/x/timeline/types.d.ts +24 -0
- package/x/timeline/types.js +2 -0
- package/x/timeline/types.js.map +1 -0
- package/x/timeline/utils/audio-stream.d.ts +6 -0
- package/x/timeline/utils/audio-stream.js +17 -0
- package/x/timeline/utils/audio-stream.js.map +1 -0
- package/x/timeline/utils/checksum.d.ts +8 -0
- package/x/timeline/utils/checksum.js +21 -0
- package/x/timeline/utils/checksum.js.map +1 -0
- package/x/timeline/utils/datafile.d.ts +9 -0
- package/x/timeline/utils/datafile.js +20 -0
- package/x/timeline/utils/datafile.js.map +1 -0
- package/x/timeline/utils/dummy-data.d.ts +2 -0
- package/x/timeline/utils/dummy-data.js +3 -0
- package/x/timeline/utils/dummy-data.js.map +1 -0
- package/x/timeline/utils/matrix.d.ts +8 -0
- package/x/timeline/utils/matrix.js +26 -0
- package/x/timeline/utils/matrix.js.map +1 -0
- package/x/timeline/utils/video-cursor.d.ts +10 -0
- package/x/timeline/utils/video-cursor.js +36 -0
- package/x/timeline/utils/video-cursor.js.map +1 -0
- package/x/tools/common/loader.d.ts +19 -0
- package/x/tools/common/loader.js +18 -0
- package/x/tools/common/loader.js.map +1 -0
- package/x/tools/common/transformer-pipeline.d.ts +8 -0
- package/x/tools/common/transformer-pipeline.js +24 -0
- package/x/tools/common/transformer-pipeline.js.map +1 -0
- package/x/tools/speech-recognition/common/model.d.ts +14 -0
- package/x/tools/speech-recognition/common/model.js +16 -0
- package/x/tools/speech-recognition/common/model.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/host.d.ts +13 -0
- package/x/tools/speech-recognition/whisper/fns/host.js +19 -0
- package/x/tools/speech-recognition/whisper/fns/host.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.d.ts +19 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.js +2 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/work.d.ts +12 -0
- package/x/tools/speech-recognition/whisper/fns/work.js +74 -0
- package/x/tools/speech-recognition/whisper/fns/work.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/types.d.ts +31 -0
- package/x/tools/speech-recognition/whisper/parts/types.js +2 -0
- package/x/tools/speech-recognition/whisper/parts/types.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.d.ts +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js +4 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js +8 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js.map +7 -0
- package/x/tools/speech-recognition/whisper/tool.d.ts +12 -0
- package/x/tools/speech-recognition/whisper/tool.js +63 -0
- package/x/tools/speech-recognition/whisper/tool.js.map +1 -0
- package/s/parts/compositor.ts +0 -5
- package/s/parts/export.ts +0 -5
- package/s/parts/video-decoder.ts +0 -27
- package/s/parts/video-encoder.ts +0 -15
- package/s/tools/generate-id.ts +0 -7
- package/s/tools/mp4boxjs/LICENSE.md +0 -24
- package/s/tools/mp4boxjs/demuxer.ts +0 -106
- package/s/tools/mp4boxjs/mp4box.adapter.ts +0 -148
- package/s/tools/mp4boxjs/mp4box.js +0 -8206
- package/s/types.ts +0 -10
- package/x/parts/compositor.d.ts +0 -4
- package/x/parts/compositor.js +0 -5
- package/x/parts/compositor.js.map +0 -1
- package/x/parts/export.d.ts +0 -7
- package/x/parts/export.js +0 -5
- package/x/parts/export.js.map +0 -1
- package/x/parts/video-decoder.d.ts +0 -8
- package/x/parts/video-decoder.js +0 -20
- package/x/parts/video-decoder.js.map +0 -1
- package/x/parts/video-encoder.d.ts +0 -6
- package/x/parts/video-encoder.js +0 -12
- package/x/parts/video-encoder.js.map +0 -1
- package/x/tools/generate-id.d.ts +0 -1
- package/x/tools/generate-id.js +0 -8
- package/x/tools/generate-id.js.map +0 -1
- package/x/tools/mp4boxjs/demuxer.d.ts +0 -24
- package/x/tools/mp4boxjs/demuxer.js +0 -88
- package/x/tools/mp4boxjs/demuxer.js.map +0 -1
- package/x/tools/mp4boxjs/mp4box.adapter.d.ts +0 -128
- package/x/tools/mp4boxjs/mp4box.adapter.js +0 -11
- package/x/tools/mp4boxjs/mp4box.adapter.js.map +0 -1
- package/x/types.d.ts +0 -7
- package/x/types.js.map +0 -1
- /package/x/{types.js → features/speech/transcribe/types.js} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
import {O} from "./o.js"
|
|
3
|
+
import {Item} from "../parts/item.js"
|
|
4
|
+
import {Media} from "../parts/media.js"
|
|
5
|
+
import {Datafile} from "../utils/datafile.js"
|
|
6
|
+
import {TimelineFile} from "../parts/basics.js"
|
|
7
|
+
import {Export} from "../parts/compositor/export.js"
|
|
8
|
+
import {ResourcePool} from "../parts/resource-pool.js"
|
|
9
|
+
import {RenderConfig} from "../../driver/fns/schematic.js"
|
|
10
|
+
|
|
11
|
+
export class Omni {
|
|
12
|
+
resources = new ResourcePool()
|
|
13
|
+
#export = new Export()
|
|
14
|
+
|
|
15
|
+
load = async<S extends Record<string, Promise<Datafile>>>(spec: S) => {
|
|
16
|
+
return Object.fromEntries(await Promise.all(Object.entries(spec).map(
|
|
17
|
+
async([key, value]) => [key, await this.resources.store(await value)]
|
|
18
|
+
))) as {[K in keyof S]: Media}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
timeline = (fn: (o: O) => Item.Any): TimelineFile => {
|
|
22
|
+
const o = new O({
|
|
23
|
+
project: {
|
|
24
|
+
format: "timeline",
|
|
25
|
+
info: "https://omniclip.app/",
|
|
26
|
+
version: 0,
|
|
27
|
+
items: [],
|
|
28
|
+
rootId: 0
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
const root = fn(o)
|
|
32
|
+
o.state.project.rootId = root.id
|
|
33
|
+
return o.state.project
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
render = async (timeline: TimelineFile, config: RenderConfig) => {
|
|
37
|
+
await this.#export.render(timeline)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type Interpolation = "linear" | "catmullRom"
|
|
2
|
+
export type Keyframe<Value = number> = [time: number, value: Value]
|
|
3
|
+
export type Keyframes<Value = number> = Keyframe<Value>[]
|
|
4
|
+
export type Vec2 = [x: number, y: number]
|
|
5
|
+
export type Transform = [position: Vec2, scale: Vec2, rotation: number]
|
|
6
|
+
|
|
7
|
+
export type TrackVec2 = {
|
|
8
|
+
x: Keyframes
|
|
9
|
+
y: Keyframes
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type Anim<T> = {
|
|
13
|
+
terp: Interpolation
|
|
14
|
+
track: T
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Animations = Anim<TrackTransform>
|
|
18
|
+
|
|
19
|
+
export type TrackTransform = {
|
|
20
|
+
position: TrackVec2
|
|
21
|
+
scale: TrackVec2
|
|
22
|
+
rotation: Keyframes
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type TransformOptions = {
|
|
26
|
+
position?: Vec2
|
|
27
|
+
scale?: Vec2
|
|
28
|
+
rotation?: number
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class AudioStream {
|
|
2
|
+
constructor(private reader: ReadableStreamDefaultReader<AudioData>) {}
|
|
3
|
+
|
|
4
|
+
async *stream(): AsyncGenerator<AudioData> {
|
|
5
|
+
while (true) {
|
|
6
|
+
const {done, value: hit} = await this.reader.read()
|
|
7
|
+
if (done) {
|
|
8
|
+
break
|
|
9
|
+
}
|
|
10
|
+
yield hit
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
cancel = async () => await this.reader.cancel()
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import {Hex, Thumbprint} from "@e280/stz"
|
|
3
|
+
|
|
4
|
+
export class Checksum {
|
|
5
|
+
constructor(
|
|
6
|
+
public data: Uint8Array,
|
|
7
|
+
public bytes: Uint8Array,
|
|
8
|
+
public hash: string,
|
|
9
|
+
public nickname: string,
|
|
10
|
+
) {}
|
|
11
|
+
|
|
12
|
+
static async make(data: Uint8Array) {
|
|
13
|
+
const data2 = new Uint8Array(data)
|
|
14
|
+
const bytes = new Uint8Array(await crypto.subtle.digest("SHA-256", data2))
|
|
15
|
+
const hash = Hex.fromBytes(bytes)
|
|
16
|
+
const nickname = Thumbprint.sigil.fromBytes(bytes)
|
|
17
|
+
return new this(data, bytes, hash, nickname)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
import {Checksum} from "./checksum.js"
|
|
3
|
+
|
|
4
|
+
export class Datafile {
|
|
5
|
+
constructor(
|
|
6
|
+
public bytes: Uint8Array,
|
|
7
|
+
public filename: string,
|
|
8
|
+
public checksum: Checksum,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
static async make(bytes: Uint8Array, name?: string) {
|
|
12
|
+
const checksum = await Checksum.make(bytes)
|
|
13
|
+
const filename = name ?? checksum.nickname
|
|
14
|
+
return new this(bytes, filename, checksum)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static async load(_path: string): Promise<Datafile> {
|
|
18
|
+
throw new Error("TODO implement")
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {Matrix} from "pixi.js"
|
|
2
|
+
import {Transform} from "../types.js"
|
|
3
|
+
|
|
4
|
+
export const transformToMat6 = (t: Transform): Mat6 => {
|
|
5
|
+
const [pos, scl, rotDeg] = t
|
|
6
|
+
const [x, y] = pos
|
|
7
|
+
const [sx, sy] = scl
|
|
8
|
+
const r = rotDeg * Math.PI / 180
|
|
9
|
+
const cos = Math.cos(r)
|
|
10
|
+
const sin = Math.sin(r)
|
|
11
|
+
return [cos * sx, sin * sx, -sin * sy, cos * sy, x, y]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const mat6ToMatrix = ([a, b, c, d, tx, ty]: Mat6): Matrix =>
|
|
15
|
+
new Matrix(a, b, c, d, tx, ty)
|
|
16
|
+
|
|
17
|
+
export const transformToMatrix = (t: Transform) => mat6ToMatrix(transformToMat6(t))
|
|
18
|
+
|
|
19
|
+
export const mul6 = (local: Mat6, parent: Mat6): Mat6 => {
|
|
20
|
+
const [a1, b1, c1, d1, tx1, ty1] = local
|
|
21
|
+
const [a2, b2, c2, d2, tx2, ty2] = parent
|
|
22
|
+
return [
|
|
23
|
+
a1 * a2 + c1 * b2,
|
|
24
|
+
b1 * a2 + d1 * b2,
|
|
25
|
+
a1 * c2 + c1 * d2,
|
|
26
|
+
b1 * c2 + d1 * d2,
|
|
27
|
+
a1 * tx2 + c1 * ty2 + tx1,
|
|
28
|
+
b1 * tx2 + d1 * ty2 + ty1
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const I6: Mat6 = [1, 0, 0, 1, 0, 0]
|
|
33
|
+
export type Mat6 = [a: number, b: number, c: number, d: number, tx: number, ty: number]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stateful, forward-only frame cursor for a single clip instance.
|
|
3
|
+
* It efficiently reads a video stream to find the frame nearest to a target timestamp.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export class VideoCursor {
|
|
7
|
+
constructor(private reader: ReadableStreamDefaultReader<VideoFrame>) {}
|
|
8
|
+
|
|
9
|
+
async atOrNear(targetUs: number): Promise<VideoFrame | undefined> {
|
|
10
|
+
let prev: VideoFrame | null = null
|
|
11
|
+
while (true) {
|
|
12
|
+
const {done, value: hit} = await this.reader.read()
|
|
13
|
+
|
|
14
|
+
if (done) {
|
|
15
|
+
const out = prev ? new VideoFrame(prev) : undefined
|
|
16
|
+
prev?.close()
|
|
17
|
+
return out
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const hitUs = hit.timestamp ?? 0
|
|
21
|
+
if (hitUs >= targetUs) {
|
|
22
|
+
const prevUs = prev?.timestamp ?? Number.NEGATIVE_INFINITY
|
|
23
|
+
const usePrev = !!prev && Math.abs(prevUs - targetUs) < Math.abs(hitUs - targetUs)
|
|
24
|
+
|
|
25
|
+
const chosen = usePrev ? prev! : hit
|
|
26
|
+
const other = usePrev ? hit : prev
|
|
27
|
+
|
|
28
|
+
const copy = new VideoFrame(chosen)
|
|
29
|
+
chosen.close()
|
|
30
|
+
other?.close()
|
|
31
|
+
return copy
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
prev?.close()
|
|
35
|
+
prev = hit
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
cancel = async () => await this.reader.cancel()
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {pub, Pub} from "@e280/stz"
|
|
2
|
+
import {ProgressItem} from "../speech-recognition/whisper/parts/types.js"
|
|
3
|
+
|
|
4
|
+
export interface LoaderEvents {
|
|
5
|
+
onModelLoadProgress: Pub<ProgressItem[]>
|
|
6
|
+
onTpsUpdate: Pub<[number]>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export abstract class Loader {
|
|
10
|
+
tps = 0
|
|
11
|
+
|
|
12
|
+
static loaderEvents = {
|
|
13
|
+
onModelLoadProgress: pub<ProgressItem[]>(),
|
|
14
|
+
onTpsUpdate: pub<[number]>()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor(public readonly name: string, public model: string) {}
|
|
18
|
+
|
|
19
|
+
abstract init(): Promise<void>
|
|
20
|
+
|
|
21
|
+
abstract setModel(model: string): void
|
|
22
|
+
|
|
23
|
+
setTps(value: number) {
|
|
24
|
+
this.tps = value
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//@ts-ignore
|
|
2
|
+
import {pipeline} from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0/dist/transformers.min.js"
|
|
3
|
+
|
|
4
|
+
import {ProgressCallback} from "../speech-recognition/whisper/parts/types.js"
|
|
5
|
+
|
|
6
|
+
export class PipelineFactory {
|
|
7
|
+
instance: any = null
|
|
8
|
+
model: string | null = null
|
|
9
|
+
|
|
10
|
+
constructor(public task: string) {}
|
|
11
|
+
|
|
12
|
+
async createInstance(model: string, progressCallback?: ProgressCallback) {
|
|
13
|
+
this.model = model
|
|
14
|
+
return this.instance = await pipeline(this.task, this.model, {
|
|
15
|
+
dtype: {
|
|
16
|
+
encoder_model:
|
|
17
|
+
this.model === "onnx-community/whisper-large-v3-turbo"
|
|
18
|
+
? "fp16"
|
|
19
|
+
: "fp32",
|
|
20
|
+
decoder_model_merged: "q4",
|
|
21
|
+
},
|
|
22
|
+
device: "webgpu",
|
|
23
|
+
progress_callback: progressCallback,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {pub} from "@e280/stz"
|
|
2
|
+
|
|
3
|
+
import {Loader} from "../../common/loader.js"
|
|
4
|
+
import {DecoderSource} from "../../../driver/fns/schematic.js"
|
|
5
|
+
import {SpeechRecognizerModels, Word, WordGroup} from "../whisper/parts/types.js"
|
|
6
|
+
|
|
7
|
+
export abstract class SpeechRecognizer extends Loader {
|
|
8
|
+
multilingual = true
|
|
9
|
+
|
|
10
|
+
static speechRecognizerEvents = {
|
|
11
|
+
onTranscriptionChunk: pub<Word[]>(),
|
|
12
|
+
onTranscribeProgress: pub<[number]>()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
abstract transcribe(input: DecoderSource): Promise<WordGroup>
|
|
16
|
+
|
|
17
|
+
setMultilingual(value: boolean) {
|
|
18
|
+
this.multilingual = value
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
detectLanguage?(input: Blob | AudioBuffer): Promise<string>
|
|
22
|
+
|
|
23
|
+
setModel(value: SpeechRecognizerModels) {
|
|
24
|
+
this.model = value
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import {Comrade} from "@e280/comrade"
|
|
3
|
+
import {ProgressItem} from "../parts/types.js"
|
|
4
|
+
import {SpeechRecognizerHostEvents, WhisperSchematic} from "./schematic.js"
|
|
5
|
+
|
|
6
|
+
export const setupWhisperHost = (events: SpeechRecognizerHostEvents) => (
|
|
7
|
+
Comrade.host<WhisperSchematic>(_shell => ({
|
|
8
|
+
async updateModelLoadProgress(item) {
|
|
9
|
+
events.onModelLoadProgress.pub(item)
|
|
10
|
+
},
|
|
11
|
+
async deliverTranscriptionChunk(chunk) {
|
|
12
|
+
events.onTranscriptionChunk.pub({
|
|
13
|
+
text: chunk.text,
|
|
14
|
+
timestamp: chunk.timestamp
|
|
15
|
+
})
|
|
16
|
+
},
|
|
17
|
+
async updateTps(value) {
|
|
18
|
+
events.onTpsUpdate.pub(value)
|
|
19
|
+
},
|
|
20
|
+
async updateTranscribeProgress(value) {
|
|
21
|
+
events.onTranscribeProgress(value)
|
|
22
|
+
}
|
|
23
|
+
}))
|
|
24
|
+
)
|
|
25
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {Pub} from "@e280/stz"
|
|
2
|
+
import {AsSchematic} from "@e280/comrade"
|
|
3
|
+
|
|
4
|
+
import {LoaderEvents} from "../../../common/loader.js"
|
|
5
|
+
import {ProgressItem, TranscriptionChunk, TranscriptionMessage, TranscriptionResult, Word} from "../parts/types.js"
|
|
6
|
+
|
|
7
|
+
export type WhisperSchematic = AsSchematic<{
|
|
8
|
+
work: {
|
|
9
|
+
transcribe(input: TranscriptionMessage): Promise<TranscriptionResult | null>
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
host: {
|
|
13
|
+
updateModelLoadProgress(item: ProgressItem): Promise<void>
|
|
14
|
+
deliverTranscriptionChunk(chunk: TranscriptionChunk): Promise<void>
|
|
15
|
+
updateTps(value: number): Promise<void>
|
|
16
|
+
updateTranscribeProgress(value: number): Promise<void>
|
|
17
|
+
}
|
|
18
|
+
}>
|
|
19
|
+
|
|
20
|
+
export interface SpeechRecognizerHostEvents extends LoaderEvents {
|
|
21
|
+
onTranscriptionChunk: Pub<Word[]>
|
|
22
|
+
onTranscribeProgress: Pub<[number]>
|
|
23
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {Comrade} from "@e280/comrade"
|
|
2
|
+
//@ts-ignore
|
|
3
|
+
import {pipeline, WhisperTextStreamer} from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0/dist/transformers.min.js"
|
|
4
|
+
|
|
5
|
+
import {WhisperSchematic} from "./schematic.js"
|
|
6
|
+
import {TranscriptionChunk} from "../parts/types.js"
|
|
7
|
+
import {PipelineFactory} from "../../../common/transformer-pipeline.js"
|
|
8
|
+
|
|
9
|
+
// TODO suspicious globals, probably bad
|
|
10
|
+
const pipeline = new PipelineFactory("automatic-speech-recognition")
|
|
11
|
+
let transcriber: any
|
|
12
|
+
|
|
13
|
+
export const setupWhisperWork = Comrade.work<WhisperSchematic>(shell => ({
|
|
14
|
+
async transcribe({audio, model, language, duration}) {
|
|
15
|
+
const isDistil = model.startsWith("distil-whisper/")
|
|
16
|
+
|
|
17
|
+
if(!pipeline.model || pipeline.model !== model) {
|
|
18
|
+
pipeline.instance?.dispose()?.()
|
|
19
|
+
pipeline.instance = null
|
|
20
|
+
transcriber = await pipeline.createInstance(
|
|
21
|
+
model,
|
|
22
|
+
(data) => {
|
|
23
|
+
if(data.progress)
|
|
24
|
+
shell.host.updateModelLoadProgress({
|
|
25
|
+
id: data.file,
|
|
26
|
+
progress: data.progress
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const timePrecision =
|
|
33
|
+
transcriber.processor.feature_extractor.config.chunk_length /
|
|
34
|
+
transcriber.model.config.max_source_positions
|
|
35
|
+
|
|
36
|
+
const chunkLength = isDistil ? 20 : 30
|
|
37
|
+
const strideLength = isDistil ? 3 : 5
|
|
38
|
+
|
|
39
|
+
let chunkCount = 0
|
|
40
|
+
let startTime: number | null = null
|
|
41
|
+
let tokenCount = 0
|
|
42
|
+
let tps = 0
|
|
43
|
+
|
|
44
|
+
const chunkDuration = chunkLength - strideLength
|
|
45
|
+
|
|
46
|
+
const estimateProgress = () => {
|
|
47
|
+
const audioProgressSeconds = chunkCount * chunkDuration
|
|
48
|
+
return Math.min(audioProgressSeconds / duration, 1)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const streamer = new WhisperTextStreamer(transcriber.tokenizer, {
|
|
52
|
+
time_precision: timePrecision,
|
|
53
|
+
token_callback_function: () => {
|
|
54
|
+
startTime ??= performance.now()
|
|
55
|
+
if (++tokenCount > 1) {
|
|
56
|
+
tps = (tokenCount / (performance.now() - startTime)) * 1000
|
|
57
|
+
shell.host.updateTps(tps)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
callback_function: (textChunk: any) => {
|
|
61
|
+
shell.host.deliverTranscriptionChunk(textChunk)
|
|
62
|
+
},
|
|
63
|
+
on_finalize: () => {
|
|
64
|
+
startTime = null
|
|
65
|
+
tokenCount = 0
|
|
66
|
+
chunkCount++
|
|
67
|
+
const progress = estimateProgress()
|
|
68
|
+
shell.host.updateTranscribeProgress(progress)
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const output = await transcriber(audio, {
|
|
73
|
+
top_k: 0,
|
|
74
|
+
do_sample: false,
|
|
75
|
+
chunk_length_s: chunkLength,
|
|
76
|
+
stride_length_s: strideLength,
|
|
77
|
+
language,
|
|
78
|
+
task: "transcribe",
|
|
79
|
+
return_timestamps: "word", // if using "word" the on_chunk_start & end is not called thus we cant retrieve timestamps, only after whole thing finishes
|
|
80
|
+
force_full_sequences: false,
|
|
81
|
+
streamer,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
if (!output) return null
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
tps,
|
|
88
|
+
...output,
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}))
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface ProgressItem {
|
|
2
|
+
id: string
|
|
3
|
+
progress: number
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type Word = {
|
|
7
|
+
text: string
|
|
8
|
+
timestamp: [start: number, end: number]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type WordGroup = Word[]
|
|
12
|
+
export type Transcript = WordGroup[]
|
|
13
|
+
|
|
14
|
+
export interface TranscriptionChunk {
|
|
15
|
+
text: string
|
|
16
|
+
offset: number
|
|
17
|
+
timestamp: [number, number]
|
|
18
|
+
finalised: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TranscriptionMessage {
|
|
22
|
+
audio: Float32Array
|
|
23
|
+
model: string
|
|
24
|
+
subtask: string | null
|
|
25
|
+
language: string | null
|
|
26
|
+
duration: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TranscriptionResult {
|
|
30
|
+
text: string
|
|
31
|
+
chunks: TranscriptionChunk[]
|
|
32
|
+
tps: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ProgressCallback = (data: any) => void
|
|
36
|
+
|
|
37
|
+
export type SpeechRecognizerModels = "onnx-community/whisper-tiny_timestamped"
|
|
38
|
+
export type SpeechRecognizerSubtasks = "transcribe"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {Comrade, Thread} from "@e280/comrade"
|
|
2
|
+
|
|
3
|
+
import {WordGroup} from "./parts/types.js"
|
|
4
|
+
import {context} from "../../../context.js"
|
|
5
|
+
import {setupWhisperHost} from "./fns/host.js"
|
|
6
|
+
import {SpeechRecognizer} from "../common/model.js"
|
|
7
|
+
import {WhisperSchematic} from "./fns/schematic.js"
|
|
8
|
+
|
|
9
|
+
export class Whisper extends SpeechRecognizer {
|
|
10
|
+
constructor(public thread: Thread<WhisperSchematic>) {
|
|
11
|
+
super('whisper', "onnx-community/whisper-tiny_timestamped")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static async setup() {
|
|
15
|
+
const thread = await Comrade.thread<WhisperSchematic>({
|
|
16
|
+
label: "OmnitoolDriver",
|
|
17
|
+
workerUrl: new URL("/tools/speech-recognition/whisper/parts/worker.bundle.min.js", import.meta.url),
|
|
18
|
+
setupHost: setupWhisperHost({
|
|
19
|
+
...this.loaderEvents,
|
|
20
|
+
...this.speechRecognizerEvents
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
return new this(thread)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async init() {
|
|
27
|
+
// there should be called loading of the model in worker instead when transcribe is called ..
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async #transcribe(source: Blob, options?: {multilingual?: boolean, language?: string}) {
|
|
31
|
+
const arrayBuffer = await source.arrayBuffer()
|
|
32
|
+
const audioCTX = new AudioContext({sampleRate: 16000})
|
|
33
|
+
const audioData = await audioCTX.decodeAudioData(arrayBuffer)
|
|
34
|
+
let audio
|
|
35
|
+
if (audioData.numberOfChannels === 2) {
|
|
36
|
+
const SCALING_FACTOR = Math.sqrt(2)
|
|
37
|
+
const left = audioData.getChannelData(0)
|
|
38
|
+
const right = audioData.getChannelData(1)
|
|
39
|
+
audio = new Float32Array(left.length)
|
|
40
|
+
for (let i = 0; i < audioData.length; ++i) {
|
|
41
|
+
audio[i] = (SCALING_FACTOR * (left[i] + right[i])) / 2
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
audio = audioData.getChannelData(0)
|
|
45
|
+
}
|
|
46
|
+
const driver = await context.driver
|
|
47
|
+
const duration = await driver.getAudioDuration(source)
|
|
48
|
+
return await this.thread.work.transcribe({
|
|
49
|
+
audio,
|
|
50
|
+
duration,
|
|
51
|
+
model: this.model,
|
|
52
|
+
subtask: this.multilingual ? "transcribe" : null,
|
|
53
|
+
language:
|
|
54
|
+
this.multilingual && options?.language !== "auto"
|
|
55
|
+
? options?.language ?? "english"
|
|
56
|
+
: null
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async transcribe(source: Blob): Promise<WordGroup> {
|
|
61
|
+
const result = await this.#transcribe(source)
|
|
62
|
+
|
|
63
|
+
const words = result?.chunks.map((chunk: any) => ({
|
|
64
|
+
text: chunk.text.trim(),
|
|
65
|
+
timestamp: chunk.timestamp,
|
|
66
|
+
})) as WordGroup
|
|
67
|
+
|
|
68
|
+
return words
|
|
69
|
+
}
|
|
70
|
+
}
|
package/x/context.d.ts
ADDED
package/x/context.js
ADDED
package/x/context.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../s/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AAEzC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,uCAAuC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEnF,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EAAC,SAAS,EAAC,CAAC;CACjC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { context } from "../context.js";
|
|
2
|
+
import { waveformTest } from "./routines/waveform-test.js";
|
|
3
|
+
import { filmstripTest } from "./routines/filmstrip-test.js";
|
|
4
|
+
import { transcriberTest } from "./routines/transcriber-test.js";
|
|
5
|
+
import { setupTranscodeTest } from "./routines/transcode-test.js";
|
|
6
|
+
const driver = await context.driver;
|
|
7
|
+
const results = document.querySelector(".results");
|
|
8
|
+
const fetchButton = document.querySelector(".fetch");
|
|
9
|
+
const importButton = document.querySelector(".import");
|
|
10
|
+
fetchButton?.addEventListener("click", startDemoFetch);
|
|
11
|
+
importButton?.addEventListener("click", startDemoImport);
|
|
12
|
+
waveformTest();
|
|
13
|
+
const transcriber = await transcriberTest(driver);
|
|
14
|
+
// hello world test
|
|
15
|
+
{
|
|
16
|
+
await driver.thread.work.hello();
|
|
17
|
+
if (driver.machina.count === 1)
|
|
18
|
+
console.log("✅ driver works");
|
|
19
|
+
else
|
|
20
|
+
console.error("❌ FAIL driver call didn't work");
|
|
21
|
+
}
|
|
22
|
+
// transcoding tests
|
|
23
|
+
async function startDemoImport() {
|
|
24
|
+
const [fileHandle] = await window.showOpenFilePicker();
|
|
25
|
+
const file = await fileHandle.getFile();
|
|
26
|
+
const transcode = setupTranscodeTest(driver, file);
|
|
27
|
+
await filmstripTest(file);
|
|
28
|
+
run(transcode, fileHandle.name);
|
|
29
|
+
await transcriber.transcribe(file);
|
|
30
|
+
}
|
|
31
|
+
async function startDemoFetch() {
|
|
32
|
+
// which videos to run tests on
|
|
33
|
+
const videos = [
|
|
34
|
+
"/assets/temp/gl.mp4",
|
|
35
|
+
];
|
|
36
|
+
// running each test in sequence
|
|
37
|
+
for (const url of videos) {
|
|
38
|
+
const transcode = setupTranscodeTest(driver, "/assets/temp/gl.mp4");
|
|
39
|
+
run(transcode, url);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function run(transcode, label) {
|
|
43
|
+
// create result div
|
|
44
|
+
const div = document.createElement("div");
|
|
45
|
+
results.append(div);
|
|
46
|
+
// add video label
|
|
47
|
+
const p = document.createElement("p");
|
|
48
|
+
p.textContent = label;
|
|
49
|
+
div.append(p);
|
|
50
|
+
// add the canvas to dom
|
|
51
|
+
div.append(transcode.canvas);
|
|
52
|
+
// run the test
|
|
53
|
+
await transcode.run();
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=demo.bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.bundle.js","sourceRoot":"","sources":["../../s/demo/demo.bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAA;AAC9D,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAA;AAE/D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAA;AACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAE,CAAA;AAEnD,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;AACpD,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAsB,CAAA;AAE3E,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;AACtD,YAAY,EAAE,gBAAgB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AAExD,YAAY,EAAE,CAAA;AACd,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,CAAA;AAEjD,mBAAmB;AACnB,CAAC;IACA,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;IAChC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;;QACxD,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;AACrD,CAAC;AAED,oBAAoB;AACpB,KAAK,UAAU,eAAe;IAE7B,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAA;IACtD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;IACvC,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAClD,MAAM,aAAa,CAAC,IAAI,CAAC,CAAA;IACzB,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AACnC,CAAC;AAED,KAAK,UAAU,cAAc;IAG5B,+BAA+B;IAC/B,MAAM,MAAM,GAAG;QACd,qBAAqB;KACrB,CAAA;IAED,gCAAgC;IAChC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;QACnE,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IACpB,CAAC;AACF,CAAC;AAED,KAAK,UAAU,GAAG,CAAC,SAAgD,EAAE,KAAa;IACjF,oBAAoB;IACpB,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IACzC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAEnB,kBAAkB;IAClB,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC,CAAC,WAAW,GAAG,KAAK,CAAA;IACrB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAEb,wBAAwB;IACxB,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAE5B,eAAe;IACf,MAAM,SAAS,CAAC,GAAG,EAAE,CAAA;AACtB,CAAC"}
|