@omnimedia/omnitool 1.1.0-10 → 1.1.0-11
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/package.json +1 -1
- package/s/context.ts +0 -7
- package/s/demo/demo.bundle.ts +30 -5
- package/s/demo/routines/waveform-test.ts +3 -2
- package/s/driver/driver.ts +2 -2
- package/s/timeline/parts/compositor/export.ts +5 -5
- package/s/timeline/parts/compositor/playback.ts +6 -7
- package/s/timeline/parts/compositor/samplers/webcodecs.ts +5 -4
- package/s/timeline/parts/waveform.ts +2 -3
- package/s/timeline/sugar/omni-test.ts +3 -1
- package/s/timeline/sugar/omni.ts +6 -1
- package/x/context.d.ts +1 -4
- package/x/context.js +1 -5
- package/x/context.js.map +1 -1
- package/x/demo/demo.bundle.js +18 -6
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +577 -9
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/routines/waveform-test.d.ts +2 -1
- package/x/demo/routines/waveform-test.js +2 -2
- package/x/demo/routines/waveform-test.js.map +1 -1
- package/x/driver/driver.d.ts +1 -1
- package/x/driver/driver.js +1 -1
- package/x/driver/driver.js.map +1 -1
- package/x/index.html +2 -2
- package/x/timeline/parts/compositor/export.d.ts +3 -1
- package/x/timeline/parts/compositor/export.js +6 -6
- package/x/timeline/parts/compositor/export.js.map +1 -1
- package/x/timeline/parts/compositor/playback.d.ts +4 -2
- package/x/timeline/parts/compositor/playback.js +7 -8
- package/x/timeline/parts/compositor/playback.js.map +1 -1
- package/x/timeline/parts/compositor/samplers/webcodecs.d.ts +2 -1
- package/x/timeline/parts/compositor/samplers/webcodecs.js +1 -4
- package/x/timeline/parts/compositor/samplers/webcodecs.js.map +1 -1
- package/x/timeline/parts/waveform.d.ts +2 -1
- package/x/timeline/parts/waveform.js +1 -3
- package/x/timeline/parts/waveform.js.map +1 -1
- package/x/timeline/sugar/omni-test.js +3 -1
- package/x/timeline/sugar/omni-test.js.map +1 -1
- package/x/timeline/sugar/omni.d.ts +3 -0
- package/x/timeline/sugar/omni.js +6 -1
- package/x/timeline/sugar/omni.js.map +1 -1
- package/s/tools/common/loader.ts +0 -26
- package/s/tools/common/transformer-pipeline.ts +0 -26
- package/s/tools/speech-recognition/common/model.ts +0 -26
- package/s/tools/speech-recognition/whisper/fns/host.ts +0 -25
- package/s/tools/speech-recognition/whisper/fns/schematic.ts +0 -23
- package/s/tools/speech-recognition/whisper/fns/work.ts +0 -91
- package/s/tools/speech-recognition/whisper/parts/types.ts +0 -38
- package/s/tools/speech-recognition/whisper/parts/worker.bundle.ts +0 -7
- package/s/tools/speech-recognition/whisper/tool.ts +0 -70
- package/x/tools/common/loader.d.ts +0 -19
- package/x/tools/common/loader.js +0 -18
- package/x/tools/common/loader.js.map +0 -1
- package/x/tools/common/transformer-pipeline.d.ts +0 -8
- package/x/tools/common/transformer-pipeline.js +0 -24
- package/x/tools/common/transformer-pipeline.js.map +0 -1
- package/x/tools/speech-recognition/common/model.d.ts +0 -14
- package/x/tools/speech-recognition/common/model.js +0 -16
- package/x/tools/speech-recognition/common/model.js.map +0 -1
- package/x/tools/speech-recognition/whisper/fns/host.d.ts +0 -13
- package/x/tools/speech-recognition/whisper/fns/host.js +0 -19
- package/x/tools/speech-recognition/whisper/fns/host.js.map +0 -1
- package/x/tools/speech-recognition/whisper/fns/schematic.d.ts +0 -19
- package/x/tools/speech-recognition/whisper/fns/schematic.js +0 -2
- package/x/tools/speech-recognition/whisper/fns/schematic.js.map +0 -1
- package/x/tools/speech-recognition/whisper/fns/work.d.ts +0 -12
- package/x/tools/speech-recognition/whisper/fns/work.js +0 -74
- package/x/tools/speech-recognition/whisper/fns/work.js.map +0 -1
- package/x/tools/speech-recognition/whisper/parts/types.d.ts +0 -31
- package/x/tools/speech-recognition/whisper/parts/types.js +0 -2
- package/x/tools/speech-recognition/whisper/parts/types.js.map +0 -1
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.d.ts +0 -1
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js +0 -4
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js.map +0 -1
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js +0 -8
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js.map +0 -7
- package/x/tools/speech-recognition/whisper/tool.d.ts +0 -12
- package/x/tools/speech-recognition/whisper/tool.js +0 -63
- package/x/tools/speech-recognition/whisper/tool.js.map +0 -1
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Driver } from "../../driver/driver.js";
|
|
2
|
+
export declare function waveformTest(driver: Driver): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Waveform } from "../../timeline/parts/waveform.js";
|
|
2
|
-
export async function waveformTest() {
|
|
2
|
+
export async function waveformTest(driver) {
|
|
3
3
|
const container = document.querySelector(".waveform-demo");
|
|
4
4
|
const widthSlider = document.querySelector(".width");
|
|
5
|
-
const waveform = await Waveform.init("/assets/temp/gl.mp4", container);
|
|
5
|
+
const waveform = await Waveform.init(driver, "/assets/temp/gl.mp4", container);
|
|
6
6
|
widthSlider.addEventListener("change", () => {
|
|
7
7
|
const width = +widthSlider.value;
|
|
8
8
|
waveform.width = width;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waveform-test.js","sourceRoot":"","sources":["../../../s/demo/routines/waveform-test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"waveform-test.js","sourceRoot":"","sources":["../../../s/demo/routines/waveform-test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,kCAAkC,CAAA;AAEzD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc;IAChD,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAgB,CAAA;IACzE,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAqB,CAAA;IACxE,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,qBAAqB,EAAE,SAAS,CAAC,CAAA;IAE9E,WAAW,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE;QAC3C,MAAM,KAAK,GAAG,CAAC,WAAW,CAAC,KAAK,CAAA;QAChC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAA;IACvB,CAAC,CAAC,CAAA;AACH,CAAC"}
|
package/x/driver/driver.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class Driver {
|
|
|
8
8
|
#private;
|
|
9
9
|
machina: Machina;
|
|
10
10
|
thread: Thread<DriverSchematic>;
|
|
11
|
-
static setup(options
|
|
11
|
+
static setup(options?: DriverOptions): Promise<Driver>;
|
|
12
12
|
constructor(machina: Machina, thread: Thread<DriverSchematic>);
|
|
13
13
|
hello(): Promise<void>;
|
|
14
14
|
getAudioDuration(source: DecoderSource): Promise<any>;
|
package/x/driver/driver.js
CHANGED
|
@@ -10,7 +10,7 @@ export class Driver {
|
|
|
10
10
|
const machina = new Machina();
|
|
11
11
|
const thread = await Comrade.thread({
|
|
12
12
|
label: "OmnitoolDriver",
|
|
13
|
-
workerUrl: options.
|
|
13
|
+
workerUrl: options?.workerUrl ?? "/node_modules/@omnimedia/omnitool/x/driver/driver.bundle.min.js",
|
|
14
14
|
setupHost: setupDriverHost(machina),
|
|
15
15
|
});
|
|
16
16
|
return new this(machina, thread);
|
package/x/driver/driver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../s/driver/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,IAAI,EAAS,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,WAAW,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AAErE,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAC,eAAe,EAAC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C,CAAC,WAAW,CAAC,CAAA;QACvE,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IACvE,CAAC;IAED,oCAAoC,CAAC,WAAwB;QAC5D,MAAM,aAAa,GAAmB,EAAE,CAAA;QAExC,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAE,EAAE;YACnC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,KAAK,MAAM,KAAK,IAAI,IAAI;oBACvB,KAAK,CAAC,KAAK,CAAC,CAAA;YACd,CAAC;iBACI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBAC7D,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,KAAK,YAAY,UAAU;oBAC5D,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAChC,CAAC;QACF,CAAC,CAAA;QAED,KAAK,CAAC,WAAW,CAAC,CAAA;QAClB,OAAO,aAAa,CAAA;IACrB,CAAC;CACD"}
|
package/x/index.html
CHANGED
|
@@ -65,7 +65,7 @@ canvas {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
</style>
|
|
68
|
-
<script type=module src="demo/demo.bundle.min.js?v=
|
|
68
|
+
<script type=module src="demo/demo.bundle.min.js?v=edf37f408a28"></script>
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
<meta name="theme-color" content="#3cff9c">
|
|
@@ -85,7 +85,7 @@ canvas {
|
|
|
85
85
|
<body>
|
|
86
86
|
|
|
87
87
|
<section>
|
|
88
|
-
<h1>Omnitool <small>v1.1.0-
|
|
88
|
+
<h1>Omnitool <small>v1.1.0-11</small></h1>
|
|
89
89
|
<button class=fetch>fetch</button>
|
|
90
90
|
<input type="file" class="file-input">
|
|
91
91
|
<div class=results></div>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { TimelineFile } from "../basics.js";
|
|
2
|
+
import { Driver } from "../../../driver/driver.js";
|
|
2
3
|
import { DecoderSource } from "../../../driver/fns/schematic.js";
|
|
3
4
|
export declare class Export {
|
|
4
5
|
#private;
|
|
6
|
+
private driver;
|
|
5
7
|
private framerate;
|
|
6
8
|
private resolveMedia;
|
|
7
|
-
constructor(framerate?: number, resolveMedia?: (hash: string) => DecoderSource);
|
|
9
|
+
constructor(driver: Driver, framerate?: number, resolveMedia?: (hash: string) => DecoderSource);
|
|
8
10
|
render(timeline: TimelineFile): Promise<void>;
|
|
9
11
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { context } from "../../../context.js";
|
|
2
1
|
import { fixedStep } from "./parts/schedulers.js";
|
|
3
2
|
import { makeWebCodecsSampler } from "./samplers/webcodecs.js";
|
|
4
3
|
import { buildWebCodecsNodeTree } from "./parts/webcodecs-tree.js";
|
|
5
4
|
export class Export {
|
|
5
|
+
driver;
|
|
6
6
|
framerate;
|
|
7
7
|
resolveMedia;
|
|
8
8
|
#sampler;
|
|
9
|
-
constructor(framerate = 30, resolveMedia = _hash => "/assets/temp/gl.mp4") {
|
|
9
|
+
constructor(driver, framerate = 30, resolveMedia = _hash => "/assets/temp/gl.mp4") {
|
|
10
|
+
this.driver = driver;
|
|
10
11
|
this.framerate = framerate;
|
|
11
12
|
this.resolveMedia = resolveMedia;
|
|
12
|
-
this.#sampler = makeWebCodecsSampler(this.resolveMedia);
|
|
13
|
+
this.#sampler = makeWebCodecsSampler(this.driver, this.resolveMedia);
|
|
13
14
|
}
|
|
14
15
|
async #build(timeline) {
|
|
15
16
|
const rootItem = new Map(timeline.items.map(i => [i.id, i])).get(timeline.rootId);
|
|
@@ -18,10 +19,9 @@ export class Export {
|
|
|
18
19
|
}
|
|
19
20
|
async render(timeline) {
|
|
20
21
|
const root = await this.#build(timeline);
|
|
21
|
-
const driver = await context.driver;
|
|
22
22
|
const videoStream = new TransformStream();
|
|
23
23
|
const audioStream = new TransformStream();
|
|
24
|
-
const encodePromise = driver.encode({
|
|
24
|
+
const encodePromise = this.driver.encode({
|
|
25
25
|
video: videoStream.readable,
|
|
26
26
|
audio: audioStream.readable,
|
|
27
27
|
config: {
|
|
@@ -44,7 +44,7 @@ export class Export {
|
|
|
44
44
|
const dt = 1 / this.framerate;
|
|
45
45
|
await fixedStep({ fps: this.framerate, duration: root.duration ?? 0 }, async (t) => {
|
|
46
46
|
const layers = await root.visuals?.sampleAt(t) ?? [];
|
|
47
|
-
const composed = await driver.composite(layers);
|
|
47
|
+
const composed = await this.driver.composite(layers);
|
|
48
48
|
const vf = new VideoFrame(composed, {
|
|
49
49
|
timestamp: Math.round(i * dt * 1_000_000),
|
|
50
50
|
duration: Math.round(dt * 1_000_000),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../../../s/timeline/parts/compositor/export.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../../../s/timeline/parts/compositor/export.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAE/C,OAAO,EAAC,oBAAoB,EAAC,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAAC,sBAAsB,EAAC,MAAM,2BAA2B,CAAA;AAEhE,MAAM,OAAO,MAAM;IAGT;IACA;IACA;IAJT,QAAQ,CAAA;IACR,YACS,MAAc,EACd,YAAY,EAAE,EACd,eAAgD,KAAK,CAAC,EAAE,CAAC,qBAAqB;QAF9E,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAK;QACd,iBAAY,GAAZ,YAAY,CAAkE;QAEtF,IAAI,CAAC,QAAQ,GAAG,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA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CAAA;QAClB,MAAM,YAAY,CAAA;QAClB,MAAM,aAAa,CAAA;QACnB,0BAA0B;IAC3B,CAAC;CACD"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { TimelineFile } from "../basics.js";
|
|
2
|
+
import { Driver } from "../../../driver/driver.js";
|
|
2
3
|
import { DecoderSource } from "../../../driver/fns/schematic.js";
|
|
3
4
|
import { AudioPlaybackComponent, HTMLSampler, Node } from "./parts/tree-builder.js";
|
|
4
5
|
type ResolveMedia = (hash: string) => DecoderSource;
|
|
5
6
|
export declare class VideoPlayer {
|
|
6
7
|
#private;
|
|
8
|
+
private driver;
|
|
7
9
|
canvas: HTMLCanvasElement;
|
|
8
10
|
private root;
|
|
9
11
|
private sampler;
|
|
10
12
|
private resolveMedia;
|
|
11
|
-
constructor(canvas: HTMLCanvasElement, root: Node<AudioPlaybackComponent>, sampler: HTMLSampler, resolveMedia?: ResolveMedia);
|
|
13
|
+
constructor(driver: Driver, canvas: HTMLCanvasElement, root: Node<AudioPlaybackComponent>, sampler: HTMLSampler, resolveMedia?: ResolveMedia);
|
|
12
14
|
get context(): CanvasRenderingContext2D;
|
|
13
|
-
static create(timeline: TimelineFile): Promise<VideoPlayer>;
|
|
15
|
+
static create(driver: Driver, timeline: TimelineFile): Promise<VideoPlayer>;
|
|
14
16
|
play(): Promise<void>;
|
|
15
17
|
pause(): void;
|
|
16
18
|
seek(time: number): Promise<void>;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { context } from "../../../context.js";
|
|
2
1
|
import { realtime } from "./parts/schedulers.js";
|
|
3
2
|
import { makeHtmlSampler } from "./samplers/html.js";
|
|
4
3
|
import { buildHTMLNodeTree } from "./parts/html-tree.js";
|
|
5
4
|
export class VideoPlayer {
|
|
5
|
+
driver;
|
|
6
6
|
canvas;
|
|
7
7
|
root;
|
|
8
8
|
sampler;
|
|
9
9
|
resolveMedia;
|
|
10
10
|
#controller = realtime(t => this.#tick(t));
|
|
11
|
-
constructor(canvas, root, sampler, resolveMedia = _hash => "/assets/temp/gl.mp4") {
|
|
11
|
+
constructor(driver, canvas, root, sampler, resolveMedia = _hash => "/assets/temp/gl.mp4") {
|
|
12
|
+
this.driver = driver;
|
|
12
13
|
this.canvas = canvas;
|
|
13
14
|
this.root = root;
|
|
14
15
|
this.sampler = sampler;
|
|
@@ -18,7 +19,7 @@ export class VideoPlayer {
|
|
|
18
19
|
get context() {
|
|
19
20
|
return this.canvas.getContext("2d");
|
|
20
21
|
}
|
|
21
|
-
static async create(timeline) {
|
|
22
|
+
static async create(driver, timeline) {
|
|
22
23
|
const rootItem = new Map(timeline.items.map(i => [i.id, i])).get(timeline.rootId);
|
|
23
24
|
const items = new Map(timeline.items.map(i => [i.id, i]));
|
|
24
25
|
const sampler = makeHtmlSampler(() => "/assets/temp/gl.mp4");
|
|
@@ -26,15 +27,14 @@ export class VideoPlayer {
|
|
|
26
27
|
const canvas = document.createElement("canvas");
|
|
27
28
|
canvas.width = 1920;
|
|
28
29
|
canvas.height = 1080;
|
|
29
|
-
return new this(canvas, root, sampler);
|
|
30
|
+
return new this(driver, canvas, root, sampler);
|
|
30
31
|
}
|
|
31
32
|
async #tick(t) {
|
|
32
|
-
const driver = await context.driver;
|
|
33
33
|
const dur = this.root.duration;
|
|
34
34
|
const tt = t > dur ? dur : t;
|
|
35
35
|
this.root.audio?.onTimeUpdate(tt);
|
|
36
36
|
for (const layer of await this.root.visuals?.sampleAt(tt) ?? []) {
|
|
37
|
-
const frame = await driver.composite(layer);
|
|
37
|
+
const frame = await this.driver.composite(layer);
|
|
38
38
|
this.context.drawImage(frame, 0, 0);
|
|
39
39
|
frame.close();
|
|
40
40
|
}
|
|
@@ -54,12 +54,11 @@ export class VideoPlayer {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
async seek(time) {
|
|
57
|
-
const driver = await context.driver;
|
|
58
57
|
this.pause();
|
|
59
58
|
this.#controller.seek(time);
|
|
60
59
|
this.root.audio?.onTimeUpdate(time);
|
|
61
60
|
for (const draw of await this.root.visuals?.sampleAt(time) ?? []) {
|
|
62
|
-
const frame = await driver.composite(draw);
|
|
61
|
+
const frame = await this.driver.composite(draw);
|
|
63
62
|
this.context.drawImage(frame, 0, 0);
|
|
64
63
|
frame.close();
|
|
65
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playback.js","sourceRoot":"","sources":["../../../../s/timeline/parts/compositor/playback.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"playback.js","sourceRoot":"","sources":["../../../../s/timeline/parts/compositor/playback.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAA;AAMtD,MAAM,OAAO,WAAW;IAId;IACD;IACC;IACA;IACA;IAPT,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAE1C,YACS,MAAc,EACf,MAAyB,EACxB,IAAkC,EAClC,OAAoB,EACpB,eAA6B,KAAK,CAAC,EAAE,CAAC,qBAAqB;QAJ3D,WAAM,GAAN,MAAM,CAAQ;QACf,WAAM,GAAN,MAAM,CAAmB;QACxB,SAAI,GAAJ,IAAI,CAA8B;QAClC,YAAO,GAAP,OAAO,CAAa;QACpB,iBAAY,GAAZ,YAAY,CAA+C;QAEnE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAE,CAAA;IACrC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,QAAsB;QACzD,MAAM,QAAQ,GAAG,IAAI,GAAG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MAAM,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;CACD"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { Driver } from "../../../../driver/driver.js";
|
|
1
2
|
import { WebcodecsSampler } from "../parts/tree-builder.js";
|
|
2
|
-
export declare function makeWebCodecsSampler(resolveMedia: (hash: string) => any): WebcodecsSampler;
|
|
3
|
+
export declare function makeWebCodecsSampler(driver: Driver, resolveMedia: (hash: string) => any): WebcodecsSampler;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { context } from "../../../../context.js";
|
|
2
1
|
import { VideoCursor } from "../../../utils/video-cursor.js";
|
|
3
2
|
import { AudioStream } from "../../../utils/audio-stream.js";
|
|
4
3
|
const toUs = (seconds) => Math.round(seconds * 1_000_000);
|
|
5
|
-
export function makeWebCodecsSampler(resolveMedia) {
|
|
4
|
+
export function makeWebCodecsSampler(driver, resolveMedia) {
|
|
6
5
|
const videoCursors = new Map();
|
|
7
6
|
async function getCursorForVideo(videoItem) {
|
|
8
7
|
const existing = videoCursors.get(videoItem.id);
|
|
9
8
|
if (existing)
|
|
10
9
|
return existing;
|
|
11
|
-
const driver = await context.driver;
|
|
12
10
|
const source = resolveMedia(videoItem.mediaHash);
|
|
13
11
|
const video = driver.decodeVideo({ source });
|
|
14
12
|
const cursor = new VideoCursor(video.getReader());
|
|
@@ -34,7 +32,6 @@ export function makeWebCodecsSampler(resolveMedia) {
|
|
|
34
32
|
duration: item.duration,
|
|
35
33
|
audio: {
|
|
36
34
|
getStream: async function* () {
|
|
37
|
-
const driver = await context.driver;
|
|
38
35
|
const source = resolveMedia(item.mediaHash);
|
|
39
36
|
const startUs = item.start;
|
|
40
37
|
const endUs = (item.start + item.duration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webcodecs.js","sourceRoot":"","sources":["../../../../../s/timeline/parts/compositor/samplers/webcodecs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webcodecs.js","sourceRoot":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import WaveSurfer from "wavesurfer.js";
|
|
2
|
+
import { Driver } from "../../driver/driver.js";
|
|
2
3
|
import { DecoderSource } from "../../driver/fns/schematic.js";
|
|
3
4
|
export declare class Waveform {
|
|
4
5
|
wavesurfer: WaveSurfer;
|
|
5
6
|
constructor(peaks: number[], container: HTMLElement, duration: number);
|
|
6
|
-
static init(source: DecoderSource, container: HTMLElement): Promise<Waveform>;
|
|
7
|
+
static init(driver: Driver, source: DecoderSource, container: HTMLElement): Promise<Waveform>;
|
|
7
8
|
set width(value: number);
|
|
8
9
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import WaveSurfer from "wavesurfer.js";
|
|
2
|
-
import { context } from "../../context.js";
|
|
3
2
|
export class Waveform {
|
|
4
3
|
wavesurfer;
|
|
5
4
|
constructor(peaks, container, duration) {
|
|
@@ -14,8 +13,7 @@ export class Waveform {
|
|
|
14
13
|
duration
|
|
15
14
|
});
|
|
16
15
|
}
|
|
17
|
-
static async init(source, container) {
|
|
18
|
-
const driver = await context.driver;
|
|
16
|
+
static async init(driver, source, container) {
|
|
19
17
|
const reader = driver.decodeAudio({ source }).getReader();
|
|
20
18
|
const peaks = [];
|
|
21
19
|
let buffer = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waveform.js","sourceRoot":"","sources":["../../../s/timeline/parts/waveform.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"waveform.js","sourceRoot":"","sources":["../../../s/timeline/parts/waveform.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAA;AAKtC,MAAM,OAAO,QAAQ;IACpB,UAAU,CAAY;IAEtB,YAAY,KAAe,EAAE,SAAsB,EAAE,QAAgB;QACpE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;YAClC,SAAS;YACT,SAAS,EAAE,kBAAkB;YAC7B,aAAa,EAAE,kBAAkB;YACjC,QA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AC,CAAA;oBAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;oBAC9B,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;gBACrB,CAAC;YACF,CAAC;YAED,SAAS,CAAC,KAAK,EAAE,CAAA;QAClB,CAAC;QAED,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAA;IACrD,CAAC;IAED,4BAA4B;IAC5B,+BAA+B;IAC/B,IAAI;IAEJ,IAAI,KAAK,CAAC,KAAa;QACtB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAA;IAC3C,CAAC;CACD"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Omni } from "./omni.js";
|
|
2
|
+
import { Driver } from "../../driver/driver.js";
|
|
2
3
|
import { dummyData } from "../utils/dummy-data.js";
|
|
4
|
+
const driver = await Driver.setup();
|
|
3
5
|
//
|
|
4
6
|
// create an omni context
|
|
5
7
|
//
|
|
6
|
-
const omni = new Omni();
|
|
8
|
+
const omni = new Omni(driver);
|
|
7
9
|
//
|
|
8
10
|
// load in some media resources
|
|
9
11
|
//
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omni-test.js","sourceRoot":"","sources":["../../../s/timeline/sugar/omni-test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAEhD,EAAE;AACF,yBAAyB;AACzB,EAAE;AAEF,MAAM,IAAI,GAAG,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"omni-test.js","sourceRoot":"","sources":["../../../s/timeline/sugar/omni-test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAEhD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;AACnC,EAAE;AACF,yBAAyB;AACzB,EAAE;AAEF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAA;AAE7B,EAAE;AACF,+BAA+B;AAC/B,EAAE;AAEF,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;IACxC,MAAM,EAAE,SAAS,EAAE;IACnB,MAAM,EAAE,SAAS,EAAE;CACnB,CAAC,CAAA;AAEF,EAAE;AACF,oBAAoB;AACpB,EAAE;AAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAC7C,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EACf,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,EAC3B,CAAC,CAAC,KAAK,CACN,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EACf,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CACrB,CACD,CAAC,CAAA;AAEF,EAAE;AACF,mBAAmB;AACnB,EAAE;AAEF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAA"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { O } from "./o.js";
|
|
2
2
|
import { Item } from "../parts/item.js";
|
|
3
3
|
import { Media } from "../parts/media.js";
|
|
4
|
+
import { Driver } from "../../driver/driver.js";
|
|
4
5
|
import { Datafile } from "../utils/datafile.js";
|
|
5
6
|
import { TimelineFile } from "../parts/basics.js";
|
|
6
7
|
import { ResourcePool } from "../parts/resource-pool.js";
|
|
7
8
|
import { RenderConfig } from "../../driver/fns/schematic.js";
|
|
8
9
|
export declare class Omni {
|
|
9
10
|
#private;
|
|
11
|
+
private driver;
|
|
10
12
|
resources: ResourcePool;
|
|
13
|
+
constructor(driver: Driver);
|
|
11
14
|
load: <S extends Record<string, Promise<Datafile>>>(spec: S) => Promise<{ [K in keyof S]: Media; }>;
|
|
12
15
|
timeline: (fn: (o: O) => Item.Any) => TimelineFile;
|
|
13
16
|
render: (timeline: TimelineFile, config: RenderConfig) => Promise<void>;
|
package/x/timeline/sugar/omni.js
CHANGED
|
@@ -2,8 +2,13 @@ import { O } from "./o.js";
|
|
|
2
2
|
import { Export } from "../parts/compositor/export.js";
|
|
3
3
|
import { ResourcePool } from "../parts/resource-pool.js";
|
|
4
4
|
export class Omni {
|
|
5
|
+
driver;
|
|
5
6
|
resources = new ResourcePool();
|
|
6
|
-
#export
|
|
7
|
+
#export;
|
|
8
|
+
constructor(driver) {
|
|
9
|
+
this.driver = driver;
|
|
10
|
+
this.#export = new Export(driver);
|
|
11
|
+
}
|
|
7
12
|
load = async (spec) => {
|
|
8
13
|
return Object.fromEntries(await Promise.all(Object.entries(spec).map(async ([key, value]) => [key, await this.resources.store(await value)])));
|
|
9
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omni.js","sourceRoot":"","sources":["../../../s/timeline/sugar/omni.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"omni.js","sourceRoot":"","sources":["../../../s/timeline/sugar/omni.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,QAAQ,CAAA;AAMxB,OAAO,EAAC,MAAM,EAAC,MAAM,+BAA+B,CAAA;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAA;AAGtD,MAAM,OAAO,IAAI;IAII;IAHpB,SAAS,GAAG,IAAI,YAAY,EAAE,CAAA;IAC9B,OAAO,CAAQ;I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
-
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
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
|
-
}))
|