@omnimedia/omnitool 1.1.0-3 → 1.1.0-5
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 +11 -9
- package/s/context.ts +1 -1
- package/s/demo/demo.bundle.ts +6 -2
- package/s/demo/routines/filmstrip-test.ts +2 -2
- package/s/demo/routines/transcriber-test.ts +34 -0
- package/s/demo/routines/transitions-test.ts +43 -0
- package/s/driver/fns/host.ts +7 -6
- package/s/driver/fns/schematic.ts +1 -1
- package/s/driver/fns/work.ts +116 -119
- package/s/driver/utils/load-decoder-source.ts +3 -4
- 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/timeline/utils/checksum.ts +2 -1
- 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.js +1 -1
- package/x/context.js.map +1 -1
- package/x/demo/demo.bundle.js +6 -2
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +6 -6
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/routines/filmstrip-test.d.ts +1 -1
- package/x/demo/routines/filmstrip-test.js +2 -2
- package/x/demo/routines/filmstrip-test.js.map +1 -1
- 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/driver/driver.worker.bundle.min.js +80 -80
- package/x/driver/driver.worker.bundle.min.js.map +4 -4
- package/x/driver/fns/host.js +3 -3
- package/x/driver/fns/host.js.map +1 -1
- package/x/driver/fns/schematic.d.ts +1 -1
- package/x/driver/fns/work.js +8 -8
- package/x/driver/fns/work.js.map +1 -1
- package/x/driver/utils/load-decoder-source.d.ts +2 -1
- package/x/driver/utils/load-decoder-source.js +2 -3
- package/x/driver/utils/load-decoder-source.js.map +1 -1
- 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 +2 -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.html +2 -2
- package/x/timeline/utils/checksum.js +2 -1
- package/x/timeline/utils/checksum.js.map +1 -1
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fragment: (glsl: string) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const fragment = (glsl) => `
|
|
2
|
+
precision highp float;
|
|
3
|
+
varying vec2 vTextureCoord;
|
|
4
|
+
varying vec2 _uv;
|
|
5
|
+
uniform sampler2D from, to;
|
|
6
|
+
uniform float progress, ratio, _fromR, _toR;
|
|
7
|
+
uniform float customUniform;
|
|
8
|
+
|
|
9
|
+
vec4 getFromColor(vec2 uv){
|
|
10
|
+
return texture2D(from, .5+(uv-.5)*vec2(max(ratio/_fromR,1.), max(_fromR/ratio,1.)));
|
|
11
|
+
}
|
|
12
|
+
vec4 getToColor(vec2 uv){
|
|
13
|
+
return texture2D(to, .5+(uv-.5)*vec2(max(ratio/_toR,1.), max(_toR/ratio,1.)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// gl-transition code here
|
|
17
|
+
${glsl}
|
|
18
|
+
// gl-transition code end
|
|
19
|
+
|
|
20
|
+
void main(){
|
|
21
|
+
vec2 uv = vTextureCoord.xy;
|
|
22
|
+
gl_FragColor = transition(vTextureCoord);
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
//# sourceMappingURL=fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/fragment.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;GAgBvC,IAAI;;;;;;;CAON,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Renderer } from "pixi.js";
|
|
2
|
+
export interface TransitionOptions {
|
|
3
|
+
name: Transition;
|
|
4
|
+
renderer: Renderer;
|
|
5
|
+
}
|
|
6
|
+
export interface TransitionRendererOptions {
|
|
7
|
+
from: VideoFrame;
|
|
8
|
+
to: VideoFrame;
|
|
9
|
+
progress: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GLTransition {
|
|
14
|
+
author: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
glsl: string;
|
|
17
|
+
license: string;
|
|
18
|
+
name: Transition;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
defaultParams: any;
|
|
21
|
+
paramsTypes: any;
|
|
22
|
+
}
|
|
23
|
+
export type Transition = "Bounce" | "BowTieHorizontal" | "BowTieVertical" | "ButterflyWaveScrawler" | "CircleCrop" | "ColourDistance" | "CrazyParametricFun" | "CrossZoom" | "Directional" | "DoomScreenTransition" | "Dreamy" | "DreamyZoom" | "GlitchDisplace" | "GlitchMemories" | "GridFlip" | "InvertedPageCurl" | "LinearBlur" | "Mosaic" | "PolkaDotsCurtain" | "Radial" | "SimpleZoom" | "StereoViewer" | "Swirl" | "WaterDrop" | "ZoomInCircles" | "angular" | "burn" | "cannabisleaf" | "circle" | "circleopen" | "colorphase" | "crosshatch" | "crosswarp" | "cube" | "directionalwarp" | "directionalwipe" | "displacement" | "doorway" | "fade" | "fadecolor" | "fadegrayscale" | "flyeye" | "heart" | "hexagonalize" | "kaleidoscope" | "luma" | "luminance_melt" | "morph" | "multiply_blend" | "perlin" | "pinwheel" | "pixelize" | "polar_function" | "randomsquares" | "ripple" | "rotate_scale_fade" | "squareswire" | "squeeze" | "swap" | "undulatingBurnOut" | "wind" | "windowblinds" | "windowslice" | "wipeDown" | "wipeLeft" | "wipeRight" | "wipeUp";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GLTransition } from "./types.js";
|
|
2
|
+
export declare const uniforms: {
|
|
3
|
+
custom: (transition: GLTransition) => {
|
|
4
|
+
[k: string]: {
|
|
5
|
+
value: unknown;
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
basics: {
|
|
10
|
+
_fromR: {
|
|
11
|
+
value: number;
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
_toR: {
|
|
15
|
+
value: number;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
ratio: {
|
|
19
|
+
value: number;
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
progress: {
|
|
23
|
+
value: number;
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
customUniform: {
|
|
27
|
+
value: number;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const uniforms = {
|
|
2
|
+
custom: (transition) => Object.fromEntries(Object.entries(transition.defaultParams).map(([name, value]) => [
|
|
3
|
+
name,
|
|
4
|
+
{
|
|
5
|
+
value,
|
|
6
|
+
type: getUniformType(transition.paramsTypes[name])
|
|
7
|
+
}
|
|
8
|
+
])),
|
|
9
|
+
basics: {
|
|
10
|
+
_fromR: { value: 1, type: "f32" },
|
|
11
|
+
_toR: { value: 1, type: "f32" },
|
|
12
|
+
ratio: { value: 1, type: "f32" },
|
|
13
|
+
progress: { value: 0, type: "f32" },
|
|
14
|
+
customUniform: { value: 0, type: "f32" },
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getUniformType = (type) => {
|
|
18
|
+
if (type === "f32" || type === "i32") {
|
|
19
|
+
return type;
|
|
20
|
+
}
|
|
21
|
+
else if (type === "float") {
|
|
22
|
+
return "f32";
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
return `${type}<f32>`;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=uniforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniforms.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/uniforms.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,MAAM,EAAE,CAAC,UAAwB,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CACvD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC/D,IAAI;QACJ;YACC,KAAK;YACL,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAClD;KACD,CAAC,CACF;IACD,MAAM,EAAE;QACP,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QAC/B,IAAI,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QAC7B,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QAC9B,QAAQ,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QACjC,aAAa,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;KACtC;CACD,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE;IACvC,IAAG,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACrC,OAAO,IAAI,CAAA;IACZ,CAAC;SAAM,IAAG,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAA;IACb,CAAC;;QACI,OAAO,GAAG,IAAI,OAAO,CAAA;AAC3B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const vertex = "\n\tin vec2 aPosition;\n\tvarying vec2 _uv; // gl-transition\n\tuniform mat3 projectionMatrix;\n\tuniform vec4 uInputSize;\n\tuniform vec4 uOutputFrame;\n\tout vec2 vTextureCoord;\n\tuniform vec4 uOutputTexture;\n\n\tvec4 filterVertexPosition( void )\n\t{\n\t\t\tvec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n\n\t\t\tposition.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n\t\t\tposition.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n\t\t\treturn vec4(position, 0.0, 1.0);\n\t}\n\n\tvec2 filterTextureCoord( void )\n\t{\n\treturn aPosition * (uOutputFrame.zw * uInputSize.zw);\n\t}\n\n\tvoid main(void)\n\t{\n\tgl_Position = filterVertexPosition();\n\tvTextureCoord = filterTextureCoord();\n\t_uv = vec2(0.5, 0.5) * (aPosition +vec2(1.0, 1.0)); // gl-transition\n\t}\n";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const vertex = `
|
|
2
|
+
in vec2 aPosition;
|
|
3
|
+
varying vec2 _uv; // gl-transition
|
|
4
|
+
uniform mat3 projectionMatrix;
|
|
5
|
+
uniform vec4 uInputSize;
|
|
6
|
+
uniform vec4 uOutputFrame;
|
|
7
|
+
out vec2 vTextureCoord;
|
|
8
|
+
uniform vec4 uOutputTexture;
|
|
9
|
+
|
|
10
|
+
vec4 filterVertexPosition( void )
|
|
11
|
+
{
|
|
12
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
13
|
+
|
|
14
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
15
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
16
|
+
|
|
17
|
+
return vec4(position, 0.0, 1.0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
vec2 filterTextureCoord( void )
|
|
21
|
+
{
|
|
22
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void main(void)
|
|
26
|
+
{
|
|
27
|
+
gl_Position = filterVertexPosition();
|
|
28
|
+
vTextureCoord = filterTextureCoord();
|
|
29
|
+
_uv = vec2(0.5, 0.5) * (aPosition +vec2(1.0, 1.0)); // gl-transition
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
//# sourceMappingURL=vertex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertex.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/vertex.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Texture } from "pixi.js";
|
|
2
|
+
import { TransitionOptions, TransitionRendererOptions } from "./parts/types.js";
|
|
3
|
+
export declare function makeTransition({ name, renderer }: TransitionOptions): {
|
|
4
|
+
render({ width, height, from, to, progress }: TransitionRendererOptions): Texture<import("pixi.js").TextureSource<any>>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//@ts-ignore
|
|
2
|
+
import transitions from "gl-transitions";
|
|
3
|
+
import { Filter, GlProgram, Sprite, Texture, ImageSource } from "pixi.js";
|
|
4
|
+
import { vertex } from "./parts/vertex.js";
|
|
5
|
+
import { uniforms } from "./parts/uniforms.js";
|
|
6
|
+
import { fragment } from "./parts/fragment.js";
|
|
7
|
+
export function makeTransition({ name, renderer }) {
|
|
8
|
+
const transition = transitions.find((t) => t.name === name);
|
|
9
|
+
const transitionSprite = new Sprite();
|
|
10
|
+
const transitionTexture = new Texture();
|
|
11
|
+
const sourceFrom = new ImageSource({});
|
|
12
|
+
const sourceTo = new ImageSource({});
|
|
13
|
+
const filter = new Filter({
|
|
14
|
+
glProgram: new GlProgram({
|
|
15
|
+
vertex,
|
|
16
|
+
fragment: fragment(transition.glsl),
|
|
17
|
+
}),
|
|
18
|
+
resources: {
|
|
19
|
+
from: sourceFrom,
|
|
20
|
+
to: sourceTo,
|
|
21
|
+
uniforms: {
|
|
22
|
+
...uniforms.basics,
|
|
23
|
+
...uniforms.custom(transition)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
transitionSprite.filters = [filter];
|
|
28
|
+
return {
|
|
29
|
+
render({ width, height, from, to, progress }) {
|
|
30
|
+
if (transitionSprite.width !== width || transitionSprite.height !== height) {
|
|
31
|
+
transitionSprite.setSize({ width, height });
|
|
32
|
+
transitionTexture.source.resize(width, height);
|
|
33
|
+
}
|
|
34
|
+
sourceFrom.resource = from;
|
|
35
|
+
sourceTo.resource = to;
|
|
36
|
+
sourceFrom.update();
|
|
37
|
+
sourceTo.update();
|
|
38
|
+
filter.resources.uniforms.uniforms.progress = progress;
|
|
39
|
+
renderer.render({
|
|
40
|
+
container: transitionSprite,
|
|
41
|
+
target: transitionTexture,
|
|
42
|
+
clear: false,
|
|
43
|
+
width,
|
|
44
|
+
height
|
|
45
|
+
});
|
|
46
|
+
return transitionTexture;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.js","sourceRoot":"","sources":["../../../s/features/transition/transition.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,OAAO,WAAW,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AAEvE,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAG5C,MAAM,UAAU,cAAc,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAoB;IACjE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAe,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAiB,CAAA;IACzF,MAAM,gBAAgB,GAAG,IAAI,MAAM,EAAE,CAAA;IACrC,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAE,CAAA;IACvC,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAA;IACtC,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAA;IAEpC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACzB,SAAS,EAAE,IAAI,SAAS,CAAC;YACxB,MAAM;YACN,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;SACnC,CAAC;QACF,SAAS,EAAE;YACV,IAAI,EAAE,UAAU;YAChB,EAAE,EAAE,QAAQ;YACZ,QAAQ,EAAE;gBACT,GAAG,QAAQ,CAAC,MAAM;gBAClB,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;aAC9B;SACD;KACD,CAAC,CAAA;IAEF,gBAAgB,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAA;IAEnC,OAAO;QACN,MAAM,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAA4B;YACpE,IAAG,gBAAgB,CAAC,KAAK,KAAK,KAAK,IAAI,gBAAgB,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC3E,gBAAgB,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC,CAAA;gBACzC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;YAC/C,CAAC;YAED,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAA;YAC1B,QAAQ,CAAC,QAAQ,GAAG,EAAE,CAAA;YACtB,UAAU,CAAC,MAAM,EAAE,CAAA;YACnB,QAAQ,CAAC,MAAM,EAAE,CAAA;YAEjB,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAEtD,QAAQ,CAAC,MAAM,CAAC;gBACf,SAAS,EAAE,gBAAgB;gBAC3B,MAAM,EAAE,iBAAiB;gBACzB,KAAK,EAAE,KAAK;gBACZ,KAAK;gBACL,MAAM;aACN,CAAC,CAAA;YAEF,OAAO,iBAAiB,CAAA;QACzB,CAAC;KACD,CAAA;AACF,CAAC"}
|
package/x/index.html
CHANGED
|
@@ -60,7 +60,7 @@ body {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
</style>
|
|
63
|
-
<script type=module src="demo/demo.bundle.min.js?v=
|
|
63
|
+
<script type=module src="demo/demo.bundle.min.js?v=7ebfc5a6da44"></script>
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
<meta name="theme-color" content="#3cff9c">
|
|
@@ -80,7 +80,7 @@ body {
|
|
|
80
80
|
<body>
|
|
81
81
|
|
|
82
82
|
<section>
|
|
83
|
-
<h1>Omnitool <small>v1.1.0-
|
|
83
|
+
<h1>Omnitool <small>v1.1.0-5</small></h1>
|
|
84
84
|
<button class=fetch>fetch</button>
|
|
85
85
|
<button class="import">import</button>
|
|
86
86
|
<div class=results></div>
|
|
@@ -11,7 +11,8 @@ export class Checksum {
|
|
|
11
11
|
this.nickname = nickname;
|
|
12
12
|
}
|
|
13
13
|
static async make(data) {
|
|
14
|
-
const
|
|
14
|
+
const data2 = new Uint8Array(data);
|
|
15
|
+
const bytes = new Uint8Array(await crypto.subtle.digest("SHA-256", data2));
|
|
15
16
|
const hash = Hex.fromBytes(bytes);
|
|
16
17
|
const nickname = Thumbprint.sigil.fromBytes(bytes);
|
|
17
18
|
return new this(data, bytes, hash, nickname);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checksum.js","sourceRoot":"","sources":["../../../s/timeline/utils/checksum.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAE,UAAU,EAAC,MAAM,WAAW,CAAA;AAEzC,MAAM,OAAO,QAAQ;IAEZ;IACA;IACA;IACA;IAJR,YACQ,IAAgB,EAChB,KAAiB,EACjB,IAAY,EACZ,QAAgB;QAHhB,SAAI,GAAJ,IAAI,CAAY;QAChB,UAAK,GAAL,KAAK,CAAY;QACjB,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;IACrB,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAgB;QACjC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"checksum.js","sourceRoot":"","sources":["../../../s/timeline/utils/checksum.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAE,UAAU,EAAC,MAAM,WAAW,CAAA;AAEzC,MAAM,OAAO,QAAQ;IAEZ;IACA;IACA;IACA;IAJR,YACQ,IAAgB,EAChB,KAAiB,EACjB,IAAY,EACZ,QAAgB;QAHhB,SAAI,GAAJ,IAAI,CAAY;QAChB,UAAK,GAAL,KAAK,CAAY;QACjB,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;IACrB,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAgB;QACjC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA;QAC1E,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACjC,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QAClD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Comrade } from "@e280/comrade";
|
|
2
|
+
export const setupWhisperHost = (events) => (Comrade.host(_shell => ({
|
|
3
|
+
async updateModelLoadProgress(item) {
|
|
4
|
+
events.onModelLoadProgress.pub(item);
|
|
5
|
+
},
|
|
6
|
+
async deliverTranscriptionChunk(chunk) {
|
|
7
|
+
events.onTranscriptionChunk.pub({
|
|
8
|
+
text: chunk.text,
|
|
9
|
+
timestamp: chunk.timestamp
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
async updateTps(value) {
|
|
13
|
+
events.onTpsUpdate.pub(value);
|
|
14
|
+
},
|
|
15
|
+
async updateTranscribeProgress(value) {
|
|
16
|
+
events.onTranscribeProgress(value);
|
|
17
|
+
}
|
|
18
|
+
})));
|
|
19
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../../../s/tools/speech-recognition/whisper/fns/host.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAIrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAkC,EAAE,EAAE,CAAC,CACvE,OAAO,CAAC,IAAI,CAAmB,MAAM,CAAC,EAAE,CAAC,CAAC;IACzC,KAAK,CAAC,uBAAuB,CAAC,IAAI;QACjC,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IACD,KAAK,CAAC,yBAAyB,CAAC,KAAK;QACpC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC;YAC/B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,KAAK,CAAC,SAAS;SAC1B,CAAC,CAAA;IACH,CAAC;IACD,KAAK,CAAC,SAAS,CAAC,KAAK;QACpB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;IACD,KAAK,CAAC,wBAAwB,CAAC,KAAK;QACnC,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;CACD,CAAC,CAAC,CACH,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Pub } from "@e280/stz";
|
|
2
|
+
import { AsSchematic } from "@e280/comrade";
|
|
3
|
+
import { LoaderEvents } from "../../../common/loader.js";
|
|
4
|
+
import { ProgressItem, TranscriptionChunk, TranscriptionMessage, TranscriptionResult, Word } from "../parts/types.js";
|
|
5
|
+
export type WhisperSchematic = AsSchematic<{
|
|
6
|
+
work: {
|
|
7
|
+
transcribe(input: TranscriptionMessage): Promise<TranscriptionResult | null>;
|
|
8
|
+
};
|
|
9
|
+
host: {
|
|
10
|
+
updateModelLoadProgress(item: ProgressItem): Promise<void>;
|
|
11
|
+
deliverTranscriptionChunk(chunk: TranscriptionChunk): Promise<void>;
|
|
12
|
+
updateTps(value: number): Promise<void>;
|
|
13
|
+
updateTranscribeProgress(value: number): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
export interface SpeechRecognizerHostEvents extends LoaderEvents {
|
|
17
|
+
onTranscriptionChunk: Pub<Word[]>;
|
|
18
|
+
onTranscribeProgress: Pub<[number]>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schematic.js","sourceRoot":"","sources":["../../../../../s/tools/speech-recognition/whisper/fns/schematic.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TranscriptionChunk } from "../parts/types.js";
|
|
2
|
+
export declare const setupWhisperWork: import("@e280/comrade").SetupWork<{
|
|
3
|
+
work: {
|
|
4
|
+
transcribe(input: import("../parts/types.js").TranscriptionMessage): Promise<import("../parts/types.js").TranscriptionResult | null>;
|
|
5
|
+
};
|
|
6
|
+
host: {
|
|
7
|
+
updateModelLoadProgress(item: import("../parts/types.js").ProgressItem): Promise<void>;
|
|
8
|
+
deliverTranscriptionChunk(chunk: TranscriptionChunk): Promise<void>;
|
|
9
|
+
updateTps(value: number): Promise<void>;
|
|
10
|
+
updateTranscribeProgress(value: number): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Comrade } from "@e280/comrade";
|
|
2
|
+
//@ts-ignore
|
|
3
|
+
import { WhisperTextStreamer } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.0/dist/transformers.min.js";
|
|
4
|
+
import { PipelineFactory } from "../../../common/transformer-pipeline.js";
|
|
5
|
+
// TODO suspicious globals, probably bad
|
|
6
|
+
const pipeline = new PipelineFactory("automatic-speech-recognition");
|
|
7
|
+
let transcriber;
|
|
8
|
+
export const setupWhisperWork = Comrade.work(shell => ({
|
|
9
|
+
async transcribe({ audio, model, language, duration }) {
|
|
10
|
+
const isDistil = model.startsWith("distil-whisper/");
|
|
11
|
+
if (!pipeline.model || pipeline.model !== model) {
|
|
12
|
+
pipeline.instance?.dispose()?.();
|
|
13
|
+
pipeline.instance = null;
|
|
14
|
+
transcriber = await pipeline.createInstance(model, (data) => {
|
|
15
|
+
if (data.progress)
|
|
16
|
+
shell.host.updateModelLoadProgress({
|
|
17
|
+
id: data.file,
|
|
18
|
+
progress: data.progress
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const timePrecision = transcriber.processor.feature_extractor.config.chunk_length /
|
|
23
|
+
transcriber.model.config.max_source_positions;
|
|
24
|
+
const chunkLength = isDistil ? 20 : 30;
|
|
25
|
+
const strideLength = isDistil ? 3 : 5;
|
|
26
|
+
let chunkCount = 0;
|
|
27
|
+
let startTime = null;
|
|
28
|
+
let tokenCount = 0;
|
|
29
|
+
let tps = 0;
|
|
30
|
+
const chunkDuration = chunkLength - strideLength;
|
|
31
|
+
const estimateProgress = () => {
|
|
32
|
+
const audioProgressSeconds = chunkCount * chunkDuration;
|
|
33
|
+
return Math.min(audioProgressSeconds / duration, 1);
|
|
34
|
+
};
|
|
35
|
+
const streamer = new WhisperTextStreamer(transcriber.tokenizer, {
|
|
36
|
+
time_precision: timePrecision,
|
|
37
|
+
token_callback_function: () => {
|
|
38
|
+
startTime ??= performance.now();
|
|
39
|
+
if (++tokenCount > 1) {
|
|
40
|
+
tps = (tokenCount / (performance.now() - startTime)) * 1000;
|
|
41
|
+
shell.host.updateTps(tps);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
callback_function: (textChunk) => {
|
|
45
|
+
shell.host.deliverTranscriptionChunk(textChunk);
|
|
46
|
+
},
|
|
47
|
+
on_finalize: () => {
|
|
48
|
+
startTime = null;
|
|
49
|
+
tokenCount = 0;
|
|
50
|
+
chunkCount++;
|
|
51
|
+
const progress = estimateProgress();
|
|
52
|
+
shell.host.updateTranscribeProgress(progress);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const output = await transcriber(audio, {
|
|
56
|
+
top_k: 0,
|
|
57
|
+
do_sample: false,
|
|
58
|
+
chunk_length_s: chunkLength,
|
|
59
|
+
stride_length_s: strideLength,
|
|
60
|
+
language,
|
|
61
|
+
task: "transcribe",
|
|
62
|
+
return_timestamps: "word", // if using "word" the on_chunk_start & end is not called thus we cant retrieve timestamps, only after whole thing finishes
|
|
63
|
+
force_full_sequences: false,
|
|
64
|
+
streamer,
|
|
65
|
+
});
|
|
66
|
+
if (!output)
|
|
67
|
+
return null;
|
|
68
|
+
return {
|
|
69
|
+
tps,
|
|
70
|
+
...output,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
//# sourceMappingURL=work.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work.js","sourceRoot":"","sources":["../../../../../s/tools/speech-recognition/whisper/fns/work.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ProgressItem {
|
|
2
|
+
id: string;
|
|
3
|
+
progress: number;
|
|
4
|
+
}
|
|
5
|
+
export type Word = {
|
|
6
|
+
text: string;
|
|
7
|
+
timestamp: [start: number, end: number];
|
|
8
|
+
};
|
|
9
|
+
export type WordGroup = Word[];
|
|
10
|
+
export type Transcript = WordGroup[];
|
|
11
|
+
export interface TranscriptionChunk {
|
|
12
|
+
text: string;
|
|
13
|
+
offset: number;
|
|
14
|
+
timestamp: [number, number];
|
|
15
|
+
finalised: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TranscriptionMessage {
|
|
18
|
+
audio: Float32Array;
|
|
19
|
+
model: string;
|
|
20
|
+
subtask: string | null;
|
|
21
|
+
language: string | null;
|
|
22
|
+
duration: number;
|
|
23
|
+
}
|
|
24
|
+
export interface TranscriptionResult {
|
|
25
|
+
text: string;
|
|
26
|
+
chunks: TranscriptionChunk[];
|
|
27
|
+
tps: number;
|
|
28
|
+
}
|
|
29
|
+
export type ProgressCallback = (data: any) => void;
|
|
30
|
+
export type SpeechRecognizerModels = "onnx-community/whisper-tiny_timestamped";
|
|
31
|
+
export type SpeechRecognizerSubtasks = "transcribe";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../s/tools/speech-recognition/whisper/parts/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.bundle.js","sourceRoot":"","sources":["../../../../../s/tools/speech-recognition/whisper/parts/worker.bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAA;AAG/C,MAAM,OAAO,CAAC,MAAM,CAAmB,gBAAgB,CAAC,CAAA"}
|