@omnimedia/omnitool 1.1.0-4 → 1.1.0-41
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 +8 -4
- package/s/context.ts +0 -7
- package/s/demo/demo.bundle.ts +35 -5
- package/s/demo/demo.css +5 -0
- package/s/demo/routines/transcode-test.ts +8 -4
- package/s/demo/routines/transitions-test.ts +43 -0
- package/s/demo/routines/waveform-test.ts +3 -2
- package/s/driver/driver.ts +19 -11
- package/s/driver/fns/schematic.ts +46 -23
- package/s/driver/fns/work.ts +114 -102
- 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 +6 -1
- package/s/timeline/index.ts +2 -0
- package/s/timeline/parts/basics.ts +1 -1
- 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 +95 -0
- package/s/timeline/parts/compositor/parts/tree-builder.ts +196 -0
- package/s/timeline/parts/compositor/parts/webcodecs-tree.ts +30 -0
- package/s/timeline/parts/compositor/playback.ts +94 -0
- package/s/timeline/parts/compositor/samplers/html.ts +115 -0
- package/s/timeline/parts/compositor/samplers/webcodecs.ts +61 -0
- package/s/timeline/parts/filmstrip.ts +42 -15
- package/s/timeline/parts/item.ts +48 -6
- package/s/timeline/parts/media.ts +21 -0
- package/s/timeline/parts/waveform.ts +3 -4
- package/s/timeline/sugar/builders.ts +102 -0
- package/s/timeline/sugar/o.ts +163 -38
- package/s/timeline/sugar/omni-test.ts +5 -3
- package/s/timeline/sugar/omni.ts +26 -11
- package/s/timeline/types.ts +29 -0
- package/s/timeline/utils/audio-stream.ts +15 -0
- package/s/timeline/utils/matrix.ts +33 -0
- package/s/timeline/utils/video-cursor.ts +40 -0
- 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 +23 -6
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +606 -36
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/demo.css +5 -0
- package/x/demo/routines/transcode-test.js +8 -4
- package/x/demo/routines/transcode-test.js.map +1 -1
- 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 +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 +4 -6
- package/x/driver/driver.js +17 -10
- package/x/driver/driver.js.map +1 -1
- package/x/driver/driver.worker.bundle.min.js +2537 -148
- package/x/driver/driver.worker.bundle.min.js.map +4 -4
- package/x/driver/fns/host.d.ts +9 -2
- package/x/driver/fns/schematic.d.ts +40 -22
- package/x/driver/fns/work.d.ts +11 -4
- package/x/driver/fns/work.js +107 -101
- package/x/driver/fns/work.js.map +1 -1
- package/x/features/speech/transcribe/worker.bundle.min.js +542 -542
- package/x/features/speech/transcribe/worker.bundle.min.js.map +4 -4
- 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.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.html +13 -3
- package/x/index.html.js +6 -1
- package/x/index.html.js.map +1 -1
- package/x/timeline/index.d.ts +2 -0
- package/x/timeline/index.js +2 -0
- package/x/timeline/index.js.map +1 -1
- package/x/timeline/parts/basics.d.ts +1 -1
- package/x/timeline/parts/compositor/export.d.ts +11 -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 +70 -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 +160 -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 +26 -0
- package/x/timeline/parts/compositor/playback.js +79 -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 +3 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js +52 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js.map +1 -0
- package/x/timeline/parts/filmstrip.d.ts +2 -1
- package/x/timeline/parts/filmstrip.js +29 -10
- package/x/timeline/parts/filmstrip.js.map +1 -1
- package/x/timeline/parts/item.d.ts +42 -8
- package/x/timeline/parts/item.js +7 -3
- package/x/timeline/parts/item.js.map +1 -1
- package/x/timeline/parts/media.d.ts +3 -0
- package/x/timeline/parts/media.js +17 -0
- package/x/timeline/parts/media.js.map +1 -1
- package/x/timeline/parts/waveform.d.ts +2 -1
- package/x/timeline/parts/waveform.js +2 -4
- package/x/timeline/parts/waveform.js.map +1 -1
- package/x/timeline/sugar/builders.js +104 -0
- package/x/timeline/sugar/builders.js.map +1 -0
- package/x/timeline/sugar/o.d.ts +27 -5
- package/x/timeline/sugar/o.js +137 -38
- package/x/timeline/sugar/o.js.map +1 -1
- package/x/timeline/sugar/omni-test.js +4 -2
- package/x/timeline/sugar/omni-test.js.map +1 -1
- package/x/timeline/sugar/omni.d.ts +8 -2
- package/x/timeline/sugar/omni.js +22 -9
- package/x/timeline/sugar/omni.js.map +1 -1
- 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/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/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.map +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
- /package/x/{tools/speech-recognition/whisper → features/transition}/parts/types.js +0 -0
- /package/x/{tools/speech-recognition/whisper/parts/worker.bundle.d.ts → timeline/sugar/builders.d.ts} +0 -0
|
@@ -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;IAEf,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,GAAG,KAAK,EAA8C,IAAO,EAAE,EAAE;QACpE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CACnE,KAAK,EAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CACrE,CAAC,CAA4B,CAAA;IAC/B,CAAC,CAAA;IAED,QAAQ,GAAG,CAAC,EAAsB,EAAgB,EAAE;QACnD,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,OAAO,EAAE;gBACR,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,CAAC;aACT;SACD,CAAC,CAAA;QACF,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;QAChC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAA;IACvB,CAAC,CAAA;IAED,MAAM,GAAG,KAAK,EAAE,QAAsB,EAAE,MAAoB,EAAE,EAAE;QAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC,CAAA;CACD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
export type TrackVec2 = {
|
|
7
|
+
x: Keyframes;
|
|
8
|
+
y: Keyframes;
|
|
9
|
+
};
|
|
10
|
+
export type Anim<T> = {
|
|
11
|
+
terp: Interpolation;
|
|
12
|
+
track: T;
|
|
13
|
+
};
|
|
14
|
+
export type Animations = Anim<TrackTransform>;
|
|
15
|
+
export type TrackTransform = {
|
|
16
|
+
position: TrackVec2;
|
|
17
|
+
scale: TrackVec2;
|
|
18
|
+
rotation: Keyframes;
|
|
19
|
+
};
|
|
20
|
+
export type TransformOptions = {
|
|
21
|
+
position?: Vec2;
|
|
22
|
+
scale?: Vec2;
|
|
23
|
+
rotation?: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../s/timeline/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class AudioStream {
|
|
2
|
+
reader;
|
|
3
|
+
constructor(reader) {
|
|
4
|
+
this.reader = reader;
|
|
5
|
+
}
|
|
6
|
+
async *stream() {
|
|
7
|
+
while (true) {
|
|
8
|
+
const { done, value: hit } = await this.reader.read();
|
|
9
|
+
if (done) {
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
yield hit;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
cancel = async () => await this.reader.cancel();
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=audio-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-stream.js","sourceRoot":"","sources":["../../../s/timeline/utils/audio-stream.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;IACH;IAApB,YAAoB,MAA8C;QAA9C,WAAM,GAAN,MAAM,CAAwC;IAAG,CAAC;IAEtE,KAAK,CAAC,CAAC,MAAM;QACZ,OAAO,IAAI,EAAE,CAAC;YACb,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;YACnD,IAAI,IAAI,EAAE,CAAC;gBACV,MAAK;YACN,CAAC;YACD,MAAM,GAAG,CAAA;QACV,CAAC;IACF,CAAC;IAED,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;CAC/C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Matrix } from "pixi.js";
|
|
2
|
+
import { Transform } from "../types.js";
|
|
3
|
+
export declare const transformToMat6: (t: Transform) => Mat6;
|
|
4
|
+
export declare const mat6ToMatrix: ([a, b, c, d, tx, ty]: Mat6) => Matrix;
|
|
5
|
+
export declare const transformToMatrix: (t: Transform) => Matrix;
|
|
6
|
+
export declare const mul6: (local: Mat6, parent: Mat6) => Mat6;
|
|
7
|
+
export declare const I6: Mat6;
|
|
8
|
+
export type Mat6 = [a: number, b: number, c: number, d: number, tx: number, ty: number];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Matrix } from "pixi.js";
|
|
2
|
+
export const transformToMat6 = (t) => {
|
|
3
|
+
const [pos, scl, rotDeg] = t;
|
|
4
|
+
const [x, y] = pos;
|
|
5
|
+
const [sx, sy] = scl;
|
|
6
|
+
const r = rotDeg * Math.PI / 180;
|
|
7
|
+
const cos = Math.cos(r);
|
|
8
|
+
const sin = Math.sin(r);
|
|
9
|
+
return [cos * sx, sin * sx, -sin * sy, cos * sy, x, y];
|
|
10
|
+
};
|
|
11
|
+
export const mat6ToMatrix = ([a, b, c, d, tx, ty]) => new Matrix(a, b, c, d, tx, ty);
|
|
12
|
+
export const transformToMatrix = (t) => mat6ToMatrix(transformToMat6(t));
|
|
13
|
+
export const mul6 = (local, parent) => {
|
|
14
|
+
const [a1, b1, c1, d1, tx1, ty1] = local;
|
|
15
|
+
const [a2, b2, c2, d2, tx2, ty2] = parent;
|
|
16
|
+
return [
|
|
17
|
+
a1 * a2 + c1 * b2,
|
|
18
|
+
b1 * a2 + d1 * b2,
|
|
19
|
+
a1 * c2 + c1 * d2,
|
|
20
|
+
b1 * c2 + d1 * d2,
|
|
21
|
+
a1 * tx2 + c1 * ty2 + tx1,
|
|
22
|
+
b1 * tx2 + d1 * ty2 + ty1
|
|
23
|
+
];
|
|
24
|
+
};
|
|
25
|
+
export const I6 = [1, 0, 0, 1, 0, 0];
|
|
26
|
+
//# sourceMappingURL=matrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../../s/timeline/utils/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAA;AAG9B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAY,EAAQ,EAAE;IACrD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAA;IAClB,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,CAAA;IACpB,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAA;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACvB,OAAO,CAAC,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACvD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAO,EAAU,EAAE,CAClE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAE/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAY,EAAE,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;AAEnF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAW,EAAE,MAAY,EAAQ,EAAE;IACvD,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;IACxC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAA;IACzC,OAAO;QACN,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;QACjB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;QACjB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;QACjB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;QACjB,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG;QACzB,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG;KACzB,CAAA;AACF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,EAAE,GAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export declare class VideoCursor {
|
|
6
|
+
private reader;
|
|
7
|
+
constructor(reader: ReadableStreamDefaultReader<VideoFrame>);
|
|
8
|
+
atOrNear(targetUs: number): Promise<VideoFrame | undefined>;
|
|
9
|
+
cancel: () => Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
export class VideoCursor {
|
|
6
|
+
reader;
|
|
7
|
+
constructor(reader) {
|
|
8
|
+
this.reader = reader;
|
|
9
|
+
}
|
|
10
|
+
async atOrNear(targetUs) {
|
|
11
|
+
let prev = null;
|
|
12
|
+
while (true) {
|
|
13
|
+
const { done, value: hit } = await this.reader.read();
|
|
14
|
+
if (done) {
|
|
15
|
+
const out = prev ? new VideoFrame(prev) : undefined;
|
|
16
|
+
prev?.close();
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
const hitUs = hit.timestamp ?? 0;
|
|
20
|
+
if (hitUs >= targetUs) {
|
|
21
|
+
const prevUs = prev?.timestamp ?? Number.NEGATIVE_INFINITY;
|
|
22
|
+
const usePrev = !!prev && Math.abs(prevUs - targetUs) < Math.abs(hitUs - targetUs);
|
|
23
|
+
const chosen = usePrev ? prev : hit;
|
|
24
|
+
const other = usePrev ? hit : prev;
|
|
25
|
+
const copy = new VideoFrame(chosen);
|
|
26
|
+
chosen.close();
|
|
27
|
+
other?.close();
|
|
28
|
+
return copy;
|
|
29
|
+
}
|
|
30
|
+
prev?.close();
|
|
31
|
+
prev = hit;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
cancel = async () => await this.reader.cancel();
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=video-cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-cursor.js","sourceRoot":"","sources":["../../../s/timeline/utils/video-cursor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,OAAO,WAAW;IACF;IAApB,YAAoB,MAA+C;QAA/C,WAAM,GAAN,MAAM,CAAyC;IAAG,CAAC;IAEvE,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC7B,IAAI,IAAI,GAAsB,IAAI,CAAA;QAClC,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;YAEnD,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;gBACnD,IAAI,EAAE,KAAK,EAAE,CAAA;gBACb,OAAO,GAAG,CAAA;YACZ,CAAC;YAED,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,IAAI,CAAC,CAAA;YAChC,IAAI,KAAK,IAAI,QAAQ,EAAE,CAAC;gBACtB,MAAM,MAAM,GAAG,IAAI,EAAE,SAAS,IAAI,MAAM,CAAC,iBAAiB,CAAA;gBAC1D,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAA;gBAElF,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAK,CAAC,CAAC,CAAC,GAAG,CAAA;gBACpC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;gBAElC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;gBACnC,MAAM,CAAC,KAAK,EAAE,CAAA;gBACd,KAAK,EAAE,KAAK,EAAE,CAAA;gBACd,OAAO,IAAI,CAAA;YACb,CAAC;YAED,IAAI,EAAE,KAAK,EAAE,CAAA;YACb,IAAI,GAAG,GAAG,CAAA;QACZ,CAAC;IACH,CAAC;IAED,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;CAChD"}
|
package/s/tools/common/loader.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -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
|
-
}))
|
|
@@ -1,38 +0,0 @@
|
|
|
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"
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Pub } from "@e280/stz";
|
|
2
|
-
import { ProgressItem } from "../speech-recognition/whisper/parts/types.js";
|
|
3
|
-
export interface LoaderEvents {
|
|
4
|
-
onModelLoadProgress: Pub<ProgressItem[]>;
|
|
5
|
-
onTpsUpdate: Pub<[number]>;
|
|
6
|
-
}
|
|
7
|
-
export declare abstract class Loader {
|
|
8
|
-
readonly name: string;
|
|
9
|
-
model: string;
|
|
10
|
-
tps: number;
|
|
11
|
-
static loaderEvents: {
|
|
12
|
-
onModelLoadProgress: Pub<ProgressItem[]>;
|
|
13
|
-
onTpsUpdate: Pub<[number]>;
|
|
14
|
-
};
|
|
15
|
-
constructor(name: string, model: string);
|
|
16
|
-
abstract init(): Promise<void>;
|
|
17
|
-
abstract setModel(model: string): void;
|
|
18
|
-
setTps(value: number): void;
|
|
19
|
-
}
|
package/x/tools/common/loader.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { pub } from "@e280/stz";
|
|
2
|
-
export class Loader {
|
|
3
|
-
name;
|
|
4
|
-
model;
|
|
5
|
-
tps = 0;
|
|
6
|
-
static loaderEvents = {
|
|
7
|
-
onModelLoadProgress: pub(),
|
|
8
|
-
onTpsUpdate: pub()
|
|
9
|
-
};
|
|
10
|
-
constructor(name, model) {
|
|
11
|
-
this.name = name;
|
|
12
|
-
this.model = model;
|
|
13
|
-
}
|
|
14
|
-
setTps(value) {
|
|
15
|
-
this.tps = value;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../s/tools/common/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAM,MAAM,WAAW,CAAA;AAQlC,MAAM,OAAgB,MAAM;IAQC;IAAqB;IAPjD,GAAG,GAAG,CAAC,CAAA;IAEP,MAAM,CAAC,YAAY,GAAG;QACrB,mBAAmB,EAAE,GAAG,EAAkB;QAC1C,WAAW,EAAE,GAAG,EAAY;KAC5B,CAAA;IAED,YAA4B,IAAY,EAAS,KAAa;QAAlC,SAAI,GAAJ,IAAI,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAMlE,MAAM,CAAC,KAAa;QACnB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAA;IACjB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ProgressCallback } from "../speech-recognition/whisper/parts/types.js";
|
|
2
|
-
export declare class PipelineFactory {
|
|
3
|
-
task: string;
|
|
4
|
-
instance: any;
|
|
5
|
-
model: string | null;
|
|
6
|
-
constructor(task: string);
|
|
7
|
-
createInstance(model: string, progressCallback?: ProgressCallback): Promise<any>;
|
|
8
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//@ts-ignore
|
|
2
|
-
import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0/dist/transformers.min.js";
|
|
3
|
-
export class PipelineFactory {
|
|
4
|
-
task;
|
|
5
|
-
instance = null;
|
|
6
|
-
model = null;
|
|
7
|
-
constructor(task) {
|
|
8
|
-
this.task = task;
|
|
9
|
-
}
|
|
10
|
-
async createInstance(model, progressCallback) {
|
|
11
|
-
this.model = model;
|
|
12
|
-
return this.instance = await pipeline(this.task, this.model, {
|
|
13
|
-
dtype: {
|
|
14
|
-
encoder_model: this.model === "onnx-community/whisper-large-v3-turbo"
|
|
15
|
-
? "fp16"
|
|
16
|
-
: "fp32",
|
|
17
|
-
decoder_model_merged: "q4",
|
|
18
|
-
},
|
|
19
|
-
device: "webgpu",
|
|
20
|
-
progress_callback: progressCallback,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=transformer-pipeline.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformer-pipeline.js","sourceRoot":"","sources":["../../../s/tools/common/transformer-pipeline.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,OAAO,EAAC,QAAQ,EAAC,MAAM,uFAAuF,CAAA;AAI9G,MAAM,OAAO,eAAe;IAIR;IAHnB,QAAQ,GAAQ,IAAI,CAAA;IACpB,KAAK,GAAkB,IAAI,CAAA;IAE3B,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEnC,KAAK,CAAC,cAAc,CAAC,KAAa,EAAE,gBAAmC;QACtE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,OAAO,IAAI,CAAC,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE;YAC5D,KAAK,EAAE;gBACN,aAAa,EACZ,IAAI,CAAC,KAAK,KAAK,uCAAuC;oBACrD,CAAC,CAAC,MAAM;oBACR,CAAC,CAAC,MAAM;gBACV,oBAAoB,EAAE,IAAI;aAC1B;YACD,MAAM,EAAE,QAAQ;YAChB,iBAAiB,EAAE,gBAAgB;SACnC,CAAC,CAAA;IACH,CAAC;CACD"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Loader } from "../../common/loader.js";
|
|
2
|
-
import { DecoderSource } from "../../../driver/fns/schematic.js";
|
|
3
|
-
import { SpeechRecognizerModels, Word, WordGroup } from "../whisper/parts/types.js";
|
|
4
|
-
export declare abstract class SpeechRecognizer extends Loader {
|
|
5
|
-
multilingual: boolean;
|
|
6
|
-
static speechRecognizerEvents: {
|
|
7
|
-
onTranscriptionChunk: import("@e280/stz").Pub<Word[]>;
|
|
8
|
-
onTranscribeProgress: import("@e280/stz").Pub<[number]>;
|
|
9
|
-
};
|
|
10
|
-
abstract transcribe(input: DecoderSource): Promise<WordGroup>;
|
|
11
|
-
setMultilingual(value: boolean): void;
|
|
12
|
-
detectLanguage?(input: Blob | AudioBuffer): Promise<string>;
|
|
13
|
-
setModel(value: SpeechRecognizerModels): void;
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { pub } from "@e280/stz";
|
|
2
|
-
import { Loader } from "../../common/loader.js";
|
|
3
|
-
export class SpeechRecognizer extends Loader {
|
|
4
|
-
multilingual = true;
|
|
5
|
-
static speechRecognizerEvents = {
|
|
6
|
-
onTranscriptionChunk: pub(),
|
|
7
|
-
onTranscribeProgress: pub()
|
|
8
|
-
};
|
|
9
|
-
setMultilingual(value) {
|
|
10
|
-
this.multilingual = value;
|
|
11
|
-
}
|
|
12
|
-
setModel(value) {
|
|
13
|
-
this.model = value;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../s/tools/speech-recognition/common/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAE7B,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAI7C,MAAM,OAAgB,gBAAiB,SAAQ,MAAM;IACpD,YAAY,GAAG,IAAI,CAAA;IAEnB,MAAM,CAAC,sBAAsB,GAAG;QAC/B,oBAAoB,EAAE,GAAG,EAAU;QACnC,oBAAoB,EAAE,GAAG,EAAY;KACrC,CAAA;IAID,eAAe,CAAC,KAAc;QAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;IAC1B,CAAC;IAID,QAAQ,CAAC,KAA6B;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACnB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ProgressItem } from "../parts/types.js";
|
|
2
|
-
import { SpeechRecognizerHostEvents } from "./schematic.js";
|
|
3
|
-
export declare const setupWhisperHost: (events: SpeechRecognizerHostEvents) => import("@e280/comrade").SetupHost<{
|
|
4
|
-
work: {
|
|
5
|
-
transcribe(input: import("../parts/types.js").TranscriptionMessage): Promise<import("../parts/types.js").TranscriptionResult | null>;
|
|
6
|
-
};
|
|
7
|
-
host: {
|
|
8
|
-
updateModelLoadProgress(item: ProgressItem): Promise<void>;
|
|
9
|
-
deliverTranscriptionChunk(chunk: import("../parts/types.js").TranscriptionChunk): Promise<void>;
|
|
10
|
-
updateTps(value: number): Promise<void>;
|
|
11
|
-
updateTranscribeProgress(value: number): Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
}>;
|