@qvac/inference 0.20.1 → 0.21.1
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/NOTICE +102 -40
- package/README.md +8 -5
- package/dist/api/bci-transcribe.d.ts +4 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/rpc-server.d.ts +19 -0
- package/dist/api/rpc-server.js +44 -0
- package/dist/api/text-to-speech.d.ts +9 -0
- package/dist/api/text-to-speech.js +9 -0
- package/dist/api/transcribe.d.ts +11 -7
- package/dist/api/transcribe.js +47 -15
- package/dist/api/video-request.d.ts +5 -5
- package/dist/dispatch.js +39 -7
- package/dist/errors/index.d.ts +7 -0
- package/dist/errors/index.js +15 -0
- package/dist/handlers/assess-model-fit.d.ts +8 -20
- package/dist/handlers/assess-model-fit.js +195 -77
- package/dist/handlers/completion-orchestrate.js +17 -0
- package/dist/handlers/get-loaded-model-info.js +4 -1
- package/dist/handlers/get-model-info.js +29 -1
- package/dist/handlers/load-model/coreml-sidecars.d.ts +25 -0
- package/dist/handlers/load-model/coreml-sidecars.js +274 -0
- package/dist/handlers/load-model/hyperdrive.js +2 -2
- package/dist/handlers/load-model/registry.js +59 -0
- package/dist/handlers/rpc-server.d.ts +23 -0
- package/dist/handlers/rpc-server.js +141 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/models/registry/models.d.ts +7731 -5672
- package/dist/models/registry/models.js +4652 -2526
- package/dist/models/registry/resource-profiles.js +481 -94
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +8 -6
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +2 -1
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +73 -1
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +37 -19
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +1 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +9 -5
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +1 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +16 -7
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +22 -11
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +9 -3
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +5 -3
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +2 -1
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +121 -0
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +56 -27
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +8 -2
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +7 -2
- package/dist/plugins/builtin/tts-ggml/ops/parler-options.d.ts +2 -0
- package/dist/plugins/builtin/tts-ggml/ops/parler-options.js +5 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +27 -10
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +181 -0
- package/dist/plugins/builtin/tts-ggml/plugin.js +84 -2
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +136 -0
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +18 -7
- package/dist/plugins/ops/bci-transcribe.d.ts +6 -2
- package/dist/plugins/ops/bci-transcribe.js +18 -13
- package/dist/plugins/ops/load-model.js +2 -2
- package/dist/plugins/ops/transcribe.d.ts +4 -2
- package/dist/plugins/ops/transcribe.js +39 -2
- package/dist/plugins/ops/translate-stats.d.ts +2 -1
- package/dist/plugins/ops/translate-stats.js +64 -7
- package/dist/plugins/ops/translate.js +20 -4
- package/dist/profiling/operation-metrics.js +56 -0
- package/dist/registry.js +4 -0
- package/dist/resources/model-fit/assess.d.ts +37 -2
- package/dist/resources/model-fit/assess.js +24 -3
- package/dist/resources/model-fit/estimators/llm.js +2 -2
- package/dist/resources/model-fit/estimators/whisper.js +3 -4
- package/dist/resources/model-fit/fit-stub/fetch-fit-stub.d.ts +20 -1
- package/dist/resources/model-fit/fit-stub/fetch-fit-stub.js +126 -47
- package/dist/resources/model-fit/fit-stub/project-fit-from-load.d.ts +27 -0
- package/dist/resources/model-fit/fit-stub/project-fit-from-load.js +31 -0
- package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts +38 -0
- package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.js +138 -0
- package/dist/resources/model-fit/floor.js +2 -2
- package/dist/resources/model-fit/native-probe/advisory-fit.d.ts +9 -6
- package/dist/resources/model-fit/native-probe/advisory-fit.js +129 -80
- package/dist/resources/model-fit/native-probe/child-engine-fit.d.ts +2 -0
- package/dist/resources/model-fit/native-probe/child-engine-fit.js +41 -0
- package/dist/resources/model-fit/native-probe/classify-fit.d.ts +6 -0
- package/dist/resources/model-fit/native-probe/classify-fit.js +135 -0
- package/dist/resources/model-fit/native-probe/create-fit-request.d.ts +28 -0
- package/dist/resources/model-fit/native-probe/create-fit-request.js +51 -0
- package/dist/resources/model-fit/native-probe/engine-fit.d.ts +59 -0
- package/dist/resources/model-fit/native-probe/engine-fit.js +13 -0
- package/dist/resources/model-fit/native-probe/engines/asr.d.ts +10 -0
- package/dist/resources/model-fit/native-probe/engines/asr.js +103 -0
- package/dist/resources/model-fit/native-probe/engines/audiogen.d.ts +8 -0
- package/dist/resources/model-fit/native-probe/engines/audiogen.js +35 -0
- package/dist/resources/model-fit/native-probe/engines/diffusion.d.ts +7 -0
- package/dist/resources/model-fit/native-probe/engines/diffusion.js +55 -0
- package/dist/resources/model-fit/native-probe/engines/gpu.d.ts +10 -0
- package/dist/resources/model-fit/native-probe/engines/gpu.js +21 -0
- package/dist/resources/model-fit/native-probe/engines/llama.d.ts +13 -0
- package/dist/resources/model-fit/native-probe/engines/llama.js +145 -0
- package/dist/resources/model-fit/native-probe/engines/tts.d.ts +8 -0
- package/dist/resources/model-fit/native-probe/engines/tts.js +106 -0
- package/dist/resources/model-fit/native-probe/fit-outcome.d.ts +16 -0
- package/dist/resources/model-fit/native-probe/fit-outcome.js +1 -0
- package/dist/resources/model-fit/native-probe/fit-process.d.ts +27 -0
- package/dist/resources/model-fit/native-probe/fit-process.js +55 -0
- package/dist/resources/model-fit/native-probe/fit-runner.d.ts +1 -0
- package/dist/resources/model-fit/native-probe/fit-runner.js +58 -0
- package/dist/resources/model-fit/native-probe/run-fit.d.ts +24 -0
- package/dist/resources/model-fit/native-probe/run-fit.js +20 -0
- package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +14 -34
- package/dist/resources/model-fit/native-probe/run-in-process-fit.js +55 -139
- package/dist/resources/model-fit/native-probe/run-isolated-fit.d.ts +5 -12
- package/dist/resources/model-fit/native-probe/run-isolated-fit.js +13 -8
- package/dist/resources/model-fit/platform.d.ts +9 -0
- package/dist/resources/model-fit/platform.js +28 -0
- package/dist/rpc/device-map.d.ts +13 -0
- package/dist/rpc/device-map.js +22 -0
- package/dist/rpc/discovery.d.ts +12 -0
- package/dist/rpc/discovery.js +225 -0
- package/dist/rpc/ggml-provider.d.ts +4 -0
- package/dist/rpc/ggml-provider.js +25 -0
- package/dist/rpc/index.d.ts +2 -0
- package/dist/rpc/index.js +1 -0
- package/dist/rpc/instance.d.ts +6 -0
- package/dist/rpc/instance.js +21 -0
- package/dist/rpc/inventory.d.ts +5 -0
- package/dist/rpc/inventory.js +144 -0
- package/dist/rpc/manager.d.ts +14 -0
- package/dist/rpc/manager.js +174 -0
- package/dist/rpc/network.d.ts +11 -0
- package/dist/rpc/network.js +85 -0
- package/dist/rpc/provider.d.ts +6 -0
- package/dist/rpc/provider.js +24 -0
- package/dist/runtime/lifecycle.js +31 -13
- package/dist/runtime/request-context.d.ts +1 -1
- package/dist/runtime/state.js +5 -0
- package/dist/schemas/assess-model-fit.d.ts +269 -85
- package/dist/schemas/assess-model-fit.js +78 -54
- package/dist/schemas/audio-gen.d.ts +6 -6
- package/dist/schemas/audio-gen.js +2 -2
- package/dist/schemas/batch-completion-stream.d.ts +13 -5
- package/dist/schemas/batch-completion-stream.js +5 -3
- package/dist/schemas/bci-config.js +1 -1
- package/dist/schemas/bci.d.ts +86 -1
- package/dist/schemas/bci.js +21 -2
- package/dist/schemas/cancel.d.ts +10 -0
- package/dist/schemas/cancel.js +2 -0
- package/dist/schemas/common.d.ts +708 -66
- package/dist/schemas/common.js +7 -0
- package/dist/schemas/completion-event.d.ts +6 -6
- package/dist/schemas/completion-stream.d.ts +27 -8
- package/dist/schemas/completion-stream.js +41 -4
- package/dist/schemas/config.d.ts +104 -36
- package/dist/schemas/config.js +10 -0
- package/dist/schemas/embed.d.ts +2 -2
- package/dist/schemas/error.js +13 -0
- package/dist/schemas/errors.d.ts +1 -0
- package/dist/schemas/errors.js +5 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/llamacpp-config.d.ts +25 -18
- package/dist/schemas/llamacpp-config.js +26 -16
- package/dist/schemas/load-model.d.ts +2608 -469
- package/dist/schemas/load-model.js +2 -2
- package/dist/schemas/mcp-adapter.d.ts +4 -0
- package/dist/schemas/model-config-schemas.d.ts +183 -6
- package/dist/schemas/model-info.d.ts +56 -0
- package/dist/schemas/model-info.js +5 -1
- package/dist/schemas/plugin.d.ts +8 -2
- package/dist/schemas/profiling.d.ts +4 -4
- package/dist/schemas/reload-config.d.ts +30 -0
- package/dist/schemas/rpc-server.d.ts +101 -0
- package/dist/schemas/rpc-server.js +87 -0
- package/dist/schemas/sdcpp-config.d.ts +7 -3
- package/dist/schemas/sdcpp-config.js +37 -2
- package/dist/schemas/system-resources.d.ts +4 -4
- package/dist/schemas/text-to-speech.d.ts +529 -1
- package/dist/schemas/text-to-speech.js +122 -12
- package/dist/schemas/tools.d.ts +2 -0
- package/dist/schemas/tools.js +8 -0
- package/dist/schemas/transcription-config.d.ts +5 -0
- package/dist/schemas/transcription-config.js +20 -2
- package/dist/schemas/transcription.d.ts +164 -0
- package/dist/schemas/transcription.js +71 -4
- package/dist/schemas/vla.d.ts +1 -1
- package/dist/surface.d.ts +4 -1
- package/dist/surface.js +3 -1
- package/dist/utils/addon-responses.d.ts +5 -1
- package/dist/utils/archive.js +5 -1
- package/dist/utils/asr-diagnostics.d.ts +12 -0
- package/dist/utils/asr-diagnostics.js +42 -0
- package/dist/utils/asr-events.d.ts +1 -0
- package/dist/utils/asr-events.js +3 -2
- package/dist/utils/cache/paths.js +3 -2
- package/dist/utils/mcp-adapter.js +7 -1
- package/dist/utils/multi-gpu-mobile.d.ts +1 -1
- package/dist/utils/multi-gpu-mobile.js +8 -6
- package/dist/utils/path-security.d.ts +5 -0
- package/dist/utils/path-security.js +14 -0
- package/dist/utils/tool-helpers.d.ts +4 -0
- package/dist/utils/tool-helpers.js +2 -0
- package/dist/utils/tools/defer.d.ts +93 -0
- package/dist/utils/tools/defer.js +290 -0
- package/dist/utils/tools/index.d.ts +1 -0
- package/dist/utils/tools/index.js +1 -0
- package/dist/utils/transcribe-metadata.d.ts +21 -7
- package/dist/utils/transcribe-metadata.js +24 -8
- package/dist/utils/tts-stats.d.ts +6 -0
- package/dist/utils/tts-stats.js +14 -1
- package/package.json +43 -29
- package/dist/resources/model-fit/fit-stub/index.d.ts +0 -2
- package/dist/resources/model-fit/fit-stub/index.js +0 -2
- package/dist/resources/model-fit/fit-stub/project-fit-from-stub.d.ts +0 -31
- package/dist/resources/model-fit/fit-stub/project-fit-from-stub.js +0 -36
- package/dist/resources/model-fit/native-probe/create-llama-fit-request.d.ts +0 -26
- package/dist/resources/model-fit/native-probe/create-llama-fit-request.js +0 -191
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assessFit as embedAssessFit } from '@qvac/embed-llamacpp';
|
|
1
2
|
import type { TurboVecIndexProvider } from '@qvac/rag';
|
|
2
3
|
import { type CreateModelParams, type PluginModelResult } from '../../../schemas/index.js';
|
|
3
4
|
export declare const embeddingsPlugin: {
|
|
@@ -7,8 +8,8 @@ export declare const embeddingsPlugin: {
|
|
|
7
8
|
loadConfigSchema: import("zod").ZodObject<{
|
|
8
9
|
gpuLayers: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
9
10
|
device: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
10
|
-
gpu: "gpu";
|
|
11
11
|
cpu: "cpu";
|
|
12
|
+
gpu: "gpu";
|
|
12
13
|
}>>;
|
|
13
14
|
batchSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
14
15
|
pooling: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
@@ -24,9 +25,9 @@ export declare const embeddingsPlugin: {
|
|
|
24
25
|
}>>;
|
|
25
26
|
embdNormalize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
26
27
|
flashAttention: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
28
|
+
auto: "auto";
|
|
27
29
|
on: "on";
|
|
28
30
|
off: "off";
|
|
29
|
-
auto: "auto";
|
|
30
31
|
}>>;
|
|
31
32
|
mainGpu: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodEnum<{
|
|
32
33
|
integrated: "integrated";
|
|
@@ -45,6 +46,7 @@ export declare const embeddingsPlugin: {
|
|
|
45
46
|
}>>;
|
|
46
47
|
openclCacheDir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
47
48
|
}, import("zod/v4/core").$strip>;
|
|
49
|
+
assessFit: typeof embedAssessFit;
|
|
48
50
|
createModel(params: CreateModelParams): PluginModelResult;
|
|
49
51
|
handlers: {
|
|
50
52
|
embed: import("../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
@@ -61,8 +63,8 @@ export declare const embeddingsPlugin: {
|
|
|
61
63
|
tokensPerSecond: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
62
64
|
totalTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
63
65
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
64
|
-
gpu: "gpu";
|
|
65
66
|
cpu: "cpu";
|
|
67
|
+
gpu: "gpu";
|
|
66
68
|
}>>;
|
|
67
69
|
contextSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
68
70
|
}, import("zod/v4/core").$strip>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import EmbedLlamacpp, { IdMapIndex } from '@qvac/embed-llamacpp';
|
|
1
|
+
import EmbedLlamacpp, { IdMapIndex, assessFit as embedAssessFit } from '@qvac/embed-llamacpp';
|
|
2
2
|
import { definePlugin, defineHandler, embedRequestSchema, embedResponseSchema, ModelType, embedConfigBaseSchema, ADDON_EMBEDDING } from '../../../schemas/index.js';
|
|
3
3
|
import { createStreamLogger, registerAddonLogger, getEngineLogger } from '../../../logging/index.js';
|
|
4
4
|
import { getFirstShardPath } from '../../../utils/index.js';
|
|
@@ -38,6 +38,7 @@ export const embeddingsPlugin = definePlugin({
|
|
|
38
38
|
displayName: 'Embeddings (llama.cpp)',
|
|
39
39
|
addonPackage: ADDON_EMBEDDING,
|
|
40
40
|
loadConfigSchema: embedConfigBaseSchema,
|
|
41
|
+
assessFit: embedAssessFit,
|
|
41
42
|
createModel(params) {
|
|
42
43
|
const embedConfig = (params.modelConfig ?? {});
|
|
43
44
|
const { model } = createEmbeddingsModel(params.modelId, params.modelPath, embedConfig);
|
|
@@ -6,6 +6,7 @@ export declare const parakeetPlugin: {
|
|
|
6
6
|
loadConfigSchema: import("zod").ZodObject<{
|
|
7
7
|
[x: string]: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
8
8
|
}, import("zod/v4/core").$strict>;
|
|
9
|
+
assessFit: typeof import("node_modules/@qvac/asr-ggml/lib/fit").assessFit;
|
|
9
10
|
resolveConfig(cfg: ParakeetConfig): Promise<ResolveResult<ParakeetConfig>>;
|
|
10
11
|
createModel(params: CreateModelParams): PluginModelResult;
|
|
11
12
|
handlers: {
|
|
@@ -41,6 +42,18 @@ export declare const parakeetPlugin: {
|
|
|
41
42
|
gpuUnsupported: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
42
43
|
gpuMemTotalMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
43
44
|
gpuMemFreeMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
45
|
+
totalTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
46
|
+
totalWallMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
47
|
+
totalSamples: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
48
|
+
processCalls: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
49
|
+
whisperSampleMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
50
|
+
whisperBatchdMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
51
|
+
whisperPromptMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
52
|
+
totalTranscriptions: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
53
|
+
modelLoadMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
54
|
+
totalEncodedFrames: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
55
|
+
encoderOnCoreml: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
56
|
+
encoderUsedCoreml: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
44
57
|
}, import("zod/v4/core").$strip>>;
|
|
45
58
|
error: import("zod").ZodOptional<import("zod").ZodString>;
|
|
46
59
|
segment: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -49,10 +62,17 @@ export declare const parakeetPlugin: {
|
|
|
49
62
|
endMs: import("zod").ZodNumber;
|
|
50
63
|
append: import("zod").ZodBoolean;
|
|
51
64
|
id: import("zod").ZodNumber;
|
|
65
|
+
isEndOfTurn: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
66
|
+
startsWord: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
52
67
|
}, import("zod/v4/core").$strip>>;
|
|
53
68
|
vad: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
54
69
|
speaking: import("zod").ZodBoolean;
|
|
55
70
|
probability: import("zod").ZodNumber;
|
|
71
|
+
source: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
72
|
+
silero: "silero";
|
|
73
|
+
energy: "energy";
|
|
74
|
+
sortformer: "sortformer";
|
|
75
|
+
}>>;
|
|
56
76
|
}, import("zod/v4/core").$strip>>;
|
|
57
77
|
endOfTurn: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
58
78
|
source: import("zod").ZodLiteral<"whisper">;
|
|
@@ -60,6 +80,47 @@ export declare const parakeetPlugin: {
|
|
|
60
80
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
61
81
|
source: import("zod").ZodLiteral<"parakeet">;
|
|
62
82
|
}, import("zod/v4/core").$strip>], "source">, unknown>>;
|
|
83
|
+
diagnostics: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
84
|
+
selectedBackend: import("zod").ZodString;
|
|
85
|
+
selectedDevice: import("zod").ZodEnum<{
|
|
86
|
+
cpu: "cpu";
|
|
87
|
+
gpu: "gpu";
|
|
88
|
+
}>;
|
|
89
|
+
graphicsApi: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
90
|
+
vulkan: "vulkan";
|
|
91
|
+
metal: "metal";
|
|
92
|
+
opencl: "opencl";
|
|
93
|
+
cuda: "cuda";
|
|
94
|
+
opengl: "opengl";
|
|
95
|
+
webgpu: "webgpu";
|
|
96
|
+
direct3d11: "direct3d11";
|
|
97
|
+
direct3d12: "direct3d12";
|
|
98
|
+
levelZero: "levelZero";
|
|
99
|
+
rocm: "rocm";
|
|
100
|
+
}>>;
|
|
101
|
+
driver: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
102
|
+
name: import("zod").ZodString;
|
|
103
|
+
version: import("zod").ZodOptional<import("zod").ZodString>;
|
|
104
|
+
}, import("zod/v4/core").$strip>>;
|
|
105
|
+
gpuId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
106
|
+
fallback: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
107
|
+
requestedBackend: import("zod").ZodOptional<import("zod").ZodString>;
|
|
108
|
+
requestedDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
109
|
+
cpu: "cpu";
|
|
110
|
+
gpu: "gpu";
|
|
111
|
+
}>>;
|
|
112
|
+
reason: import("zod").ZodString;
|
|
113
|
+
}, import("zod/v4/core").$strip>>;
|
|
114
|
+
probe: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
115
|
+
status: import("zod").ZodEnum<{
|
|
116
|
+
unknown: "unknown";
|
|
117
|
+
compatible: "compatible";
|
|
118
|
+
incompatible: "incompatible";
|
|
119
|
+
}>;
|
|
120
|
+
backend: import("zod").ZodString;
|
|
121
|
+
reason: import("zod").ZodOptional<import("zod").ZodString>;
|
|
122
|
+
}, import("zod/v4/core").$strip>>;
|
|
123
|
+
}, import("zod/v4/core").$strip>>;
|
|
63
124
|
type: import("zod").ZodLiteral<"transcribe">;
|
|
64
125
|
}, import("zod/v4/core").$strip>>;
|
|
65
126
|
transcribeStream: import("../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
@@ -104,6 +165,18 @@ export declare const parakeetPlugin: {
|
|
|
104
165
|
gpuUnsupported: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
105
166
|
gpuMemTotalMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
106
167
|
gpuMemFreeMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
168
|
+
totalTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
169
|
+
totalWallMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
170
|
+
totalSamples: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
171
|
+
processCalls: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
172
|
+
whisperSampleMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
173
|
+
whisperBatchdMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
174
|
+
whisperPromptMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
175
|
+
totalTranscriptions: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
176
|
+
modelLoadMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
177
|
+
totalEncodedFrames: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
178
|
+
encoderOnCoreml: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
179
|
+
encoderUsedCoreml: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
107
180
|
}, import("zod/v4/core").$strip>>;
|
|
108
181
|
error: import("zod").ZodOptional<import("zod").ZodString>;
|
|
109
182
|
segment: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -112,10 +185,17 @@ export declare const parakeetPlugin: {
|
|
|
112
185
|
endMs: import("zod").ZodNumber;
|
|
113
186
|
append: import("zod").ZodBoolean;
|
|
114
187
|
id: import("zod").ZodNumber;
|
|
188
|
+
isEndOfTurn: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
189
|
+
startsWord: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
115
190
|
}, import("zod/v4/core").$strip>>;
|
|
116
191
|
vad: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
117
192
|
speaking: import("zod").ZodBoolean;
|
|
118
193
|
probability: import("zod").ZodNumber;
|
|
194
|
+
source: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
195
|
+
silero: "silero";
|
|
196
|
+
energy: "energy";
|
|
197
|
+
sortformer: "sortformer";
|
|
198
|
+
}>>;
|
|
119
199
|
}, import("zod/v4/core").$strip>>;
|
|
120
200
|
endOfTurn: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
121
201
|
source: import("zod").ZodLiteral<"whisper">;
|
|
@@ -123,6 +203,47 @@ export declare const parakeetPlugin: {
|
|
|
123
203
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
124
204
|
source: import("zod").ZodLiteral<"parakeet">;
|
|
125
205
|
}, import("zod/v4/core").$strip>], "source">, unknown>>;
|
|
206
|
+
diagnostics: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
207
|
+
selectedBackend: import("zod").ZodString;
|
|
208
|
+
selectedDevice: import("zod").ZodEnum<{
|
|
209
|
+
cpu: "cpu";
|
|
210
|
+
gpu: "gpu";
|
|
211
|
+
}>;
|
|
212
|
+
graphicsApi: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
213
|
+
vulkan: "vulkan";
|
|
214
|
+
metal: "metal";
|
|
215
|
+
opencl: "opencl";
|
|
216
|
+
cuda: "cuda";
|
|
217
|
+
opengl: "opengl";
|
|
218
|
+
webgpu: "webgpu";
|
|
219
|
+
direct3d11: "direct3d11";
|
|
220
|
+
direct3d12: "direct3d12";
|
|
221
|
+
levelZero: "levelZero";
|
|
222
|
+
rocm: "rocm";
|
|
223
|
+
}>>;
|
|
224
|
+
driver: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
225
|
+
name: import("zod").ZodString;
|
|
226
|
+
version: import("zod").ZodOptional<import("zod").ZodString>;
|
|
227
|
+
}, import("zod/v4/core").$strip>>;
|
|
228
|
+
gpuId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
229
|
+
fallback: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
230
|
+
requestedBackend: import("zod").ZodOptional<import("zod").ZodString>;
|
|
231
|
+
requestedDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
232
|
+
cpu: "cpu";
|
|
233
|
+
gpu: "gpu";
|
|
234
|
+
}>>;
|
|
235
|
+
reason: import("zod").ZodString;
|
|
236
|
+
}, import("zod/v4/core").$strip>>;
|
|
237
|
+
probe: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
238
|
+
status: import("zod").ZodEnum<{
|
|
239
|
+
unknown: "unknown";
|
|
240
|
+
compatible: "compatible";
|
|
241
|
+
incompatible: "incompatible";
|
|
242
|
+
}>;
|
|
243
|
+
backend: import("zod").ZodString;
|
|
244
|
+
reason: import("zod").ZodOptional<import("zod").ZodString>;
|
|
245
|
+
}, import("zod/v4/core").$strip>>;
|
|
246
|
+
}, import("zod/v4/core").$strip>>;
|
|
126
247
|
type: import("zod").ZodLiteral<"transcribeStream">;
|
|
127
248
|
}, import("zod/v4/core").$strip>>;
|
|
128
249
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import ASRGgml from '@qvac/asr-ggml';
|
|
2
2
|
import { definePlugin, defineHandler, defineDuplexHandler, transcribeRequestSchema, transcribeResponseSchema, transcribeStreamRequestSchema, transcribeStreamResponseSchema, ModelType, parakeetLoadConfigSchema, LEGACY_PARAKEET_ONNX_MODEL_CONFIG_FIELDS, ADDON_ASR } from '../../../schemas/index.js';
|
|
3
|
-
import { ModelLoadFailedError,
|
|
3
|
+
import { ModelLoadFailedError, LegacyParakeetModelDeprecatedError } from '../../../errors/index.js';
|
|
4
4
|
import { transcribe, transcribeStream } from '../../ops/transcribe.js';
|
|
5
5
|
import { attachModelExecutionMs } from '../../../profiling/model-execution.js';
|
|
6
|
+
import { attachBackendDiagnostics } from '../../../profiling/backend-diagnostics.js';
|
|
6
7
|
import { buildParakeetEngineConfig } from '../asr-ggml/config.js';
|
|
7
8
|
import { createAsrModelLogger } from '../asr-ggml/logging.js';
|
|
8
9
|
function resolveParakeetConfig(cfg) {
|
|
@@ -33,6 +34,7 @@ export const parakeetPlugin = definePlugin({
|
|
|
33
34
|
displayName: 'Parakeet (NVIDIA NeMo GGML)',
|
|
34
35
|
addonPackage: ADDON_ASR,
|
|
35
36
|
loadConfigSchema: parakeetLoadConfigSchema,
|
|
37
|
+
assessFit: ASRGgml.assessFit,
|
|
36
38
|
resolveConfig(cfg) {
|
|
37
39
|
return resolveParakeetConfig(cfg);
|
|
38
40
|
},
|
|
@@ -46,30 +48,48 @@ export const parakeetPlugin = definePlugin({
|
|
|
46
48
|
streaming: true,
|
|
47
49
|
cancel: { scope: 'model', hard: true },
|
|
48
50
|
handler: async function* (request) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
// The native serializer emits start/end/id/toAppend/isEndOfTurn/
|
|
52
|
+
// startsWord on every segment, so metadata mode is forwarded exactly
|
|
53
|
+
// as the whisper plugin does. Branching the call keeps the op's
|
|
54
|
+
// `metadata: true` overload, which is what types results as segments.
|
|
55
|
+
const metadata = request.metadata === true;
|
|
56
|
+
const stream = metadata
|
|
57
|
+
? transcribe({
|
|
58
|
+
modelId: request.modelId,
|
|
59
|
+
audioChunk: request.audioChunk,
|
|
60
|
+
prompt: request.prompt,
|
|
61
|
+
metadata: true
|
|
62
|
+
}, request.requestId)
|
|
63
|
+
: transcribe({
|
|
64
|
+
modelId: request.modelId,
|
|
65
|
+
audioChunk: request.audioChunk,
|
|
66
|
+
prompt: request.prompt
|
|
67
|
+
}, request.requestId);
|
|
57
68
|
try {
|
|
58
69
|
let result = await stream.next();
|
|
59
70
|
while (!result.done) {
|
|
60
|
-
yield
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
yield metadata
|
|
72
|
+
? {
|
|
73
|
+
type: 'transcribe',
|
|
74
|
+
segment: result.value
|
|
75
|
+
}
|
|
76
|
+
: {
|
|
77
|
+
type: 'transcribe',
|
|
78
|
+
text: result.value
|
|
79
|
+
};
|
|
64
80
|
result = await stream.next();
|
|
65
81
|
}
|
|
66
|
-
const { modelExecutionMs, stats } = result.value;
|
|
67
|
-
|
|
82
|
+
const { modelExecutionMs, stats, diagnostics } = result.value;
|
|
83
|
+
// The field is what reaches an RPC client; the symbol is what the
|
|
84
|
+
// profiling layer reads to set `event.backend`, as audiogen does.
|
|
85
|
+
const terminal = attachModelExecutionMs({
|
|
68
86
|
type: 'transcribe',
|
|
69
87
|
text: '',
|
|
70
88
|
done: true,
|
|
71
|
-
...(stats && { stats })
|
|
89
|
+
...(stats && { stats }),
|
|
90
|
+
...(diagnostics && { diagnostics })
|
|
72
91
|
}, modelExecutionMs);
|
|
92
|
+
yield diagnostics ? attachBackendDiagnostics(terminal, diagnostics) : terminal;
|
|
73
93
|
}
|
|
74
94
|
finally {
|
|
75
95
|
await stream.return?.(undefined);
|
|
@@ -90,15 +110,15 @@ export const parakeetPlugin = definePlugin({
|
|
|
90
110
|
// the duplex RPC writer — backpressure is not yet characterised. Pair
|
|
91
111
|
// the fix with request-lifecycle `cancel({ requestId })` routing.
|
|
92
112
|
handler: async function* (request, inputStream) {
|
|
93
|
-
|
|
94
|
-
throw new TranscriptionFailedError(`Parakeet transcribeStream does not support metadata: true; only the whisper engine emits per-segment metadata.`);
|
|
95
|
-
}
|
|
113
|
+
const metadata = request.metadata === true;
|
|
96
114
|
const streamOpts = {
|
|
97
115
|
...(request.parakeetStreamingConfig && {
|
|
98
116
|
parakeetStreamingConfig: request.parakeetStreamingConfig
|
|
99
117
|
})
|
|
100
118
|
};
|
|
101
|
-
const iterator =
|
|
119
|
+
const iterator = metadata
|
|
120
|
+
? transcribeStream(request.modelId, inputStream, undefined, true, streamOpts, request.requestId)
|
|
121
|
+
: transcribeStream(request.modelId, inputStream, undefined, false, streamOpts, request.requestId);
|
|
102
122
|
try {
|
|
103
123
|
let result = await iterator.next();
|
|
104
124
|
while (!result.done) {
|
|
@@ -113,19 +133,28 @@ export const parakeetPlugin = definePlugin({
|
|
|
113
133
|
result = await iterator.next();
|
|
114
134
|
continue;
|
|
115
135
|
}
|
|
116
|
-
yield
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
136
|
+
yield metadata
|
|
137
|
+
? {
|
|
138
|
+
type: 'transcribeStream',
|
|
139
|
+
segment: value
|
|
140
|
+
}
|
|
141
|
+
: {
|
|
142
|
+
type: 'transcribeStream',
|
|
143
|
+
text: value
|
|
144
|
+
};
|
|
120
145
|
result = await iterator.next();
|
|
121
146
|
}
|
|
122
|
-
const { modelExecutionMs, stats } = result.value;
|
|
123
|
-
|
|
147
|
+
const { modelExecutionMs, stats, diagnostics } = result.value;
|
|
148
|
+
// The field is what reaches an RPC client; the symbol is what the
|
|
149
|
+
// profiling layer reads to set `event.backend`, as audiogen does.
|
|
150
|
+
const terminal = attachModelExecutionMs({
|
|
124
151
|
type: 'transcribeStream',
|
|
125
152
|
text: '',
|
|
126
153
|
done: true,
|
|
127
|
-
...(stats && { stats })
|
|
154
|
+
...(stats && { stats }),
|
|
155
|
+
...(diagnostics && { diagnostics })
|
|
128
156
|
}, modelExecutionMs);
|
|
157
|
+
yield diagnostics ? attachBackendDiagnostics(terminal, diagnostics) : terminal;
|
|
129
158
|
}
|
|
130
159
|
finally {
|
|
131
160
|
await iterator.return?.(undefined);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assessFit as diffusionAssessFit } from '@qvac/diffusion-cpp';
|
|
1
2
|
import { type CreateModelParams, type PluginModelResult, type ResolveContext, type ResolveResult, type SdcppConfig } from '../../../schemas/index.js';
|
|
2
3
|
type DiffusionArtifactKey = 'clipLModelPath' | 'clipGModelPath' | 'clipVisionModelPath' | 't5XxlModelPath' | 'llmModelPath' | 'vaeModelPath' | 'highNoiseDiffusionModelPath' | 'uncondModelPath' | 'audioVaeModelPath' | 'embeddingsConnectorsModelPath' | 'esrganModelPath' | 'taehvModelPath' | 'seedScenePath';
|
|
3
4
|
/**
|
|
@@ -19,8 +20,8 @@ export declare const diffusionPlugin: {
|
|
|
19
20
|
}>>;
|
|
20
21
|
threads: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
21
22
|
device: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
22
|
-
gpu: "gpu";
|
|
23
23
|
cpu: "cpu";
|
|
24
|
+
gpu: "gpu";
|
|
24
25
|
}>>;
|
|
25
26
|
'main-gpu': import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodEnum<{
|
|
26
27
|
integrated: "integrated";
|
|
@@ -554,6 +555,10 @@ export declare const diffusionPlugin: {
|
|
|
554
555
|
numFramePerBlock: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
555
556
|
localAttnSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
556
557
|
offloadParamsToCpu: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
558
|
+
paramsBackend: import("zod").ZodOptional<import("zod").ZodString>;
|
|
559
|
+
maxVram: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString]>>;
|
|
560
|
+
streamLayers: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
561
|
+
verbosity: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<0>, import("zod").ZodLiteral<1>, import("zod").ZodLiteral<2>, import("zod").ZodLiteral<3>]>>;
|
|
557
562
|
frameJpegQuality: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
558
563
|
kvCache: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
559
564
|
profile: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -605,6 +610,7 @@ export declare const diffusionPlugin: {
|
|
|
605
610
|
threads: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<-1>, import("zod").ZodNumber]>>;
|
|
606
611
|
}, import("zod/v4/core").$strict>>;
|
|
607
612
|
}, import("zod/v4/core").$strip>;
|
|
613
|
+
assessFit: typeof diffusionAssessFit;
|
|
608
614
|
resolveConfig(cfg: SdcppConfig, ctx: ResolveContext): Promise<ResolveResult<SdcppConfig, DiffusionArtifactKey>>;
|
|
609
615
|
createModel(params: CreateModelParams): PluginModelResult;
|
|
610
616
|
handlers: {
|
|
@@ -846,8 +852,8 @@ export declare const diffusionPlugin: {
|
|
|
846
852
|
height: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
847
853
|
repeats: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
848
854
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
849
|
-
gpu: "gpu";
|
|
850
855
|
cpu: "cpu";
|
|
856
|
+
gpu: "gpu";
|
|
851
857
|
}>>;
|
|
852
858
|
}, import("zod/v4/core").$strip>>;
|
|
853
859
|
}, import("zod/v4/core").$strip>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ImgStableDiffusion, { EsrganUpscaler, VideoStableDiffusion } from '@qvac/diffusion-cpp';
|
|
1
|
+
import ImgStableDiffusion, { EsrganUpscaler, VideoStableDiffusion, assessFit as diffusionAssessFit } from '@qvac/diffusion-cpp';
|
|
2
2
|
import { definePlugin, defineHandler, sdcppConfigSchema, diffusionRequestSchema, diffusionStreamResponseSchema, videoRequestSchema, videoStreamResponseSchema, upscaleRequestSchema, upscaleStreamResponseSchema, worldSceneRequestSchema, worldSceneStreamResponseSchema, worldStepRequestSchema, worldStepStreamResponseSchema, ModelType, ADDON_DIFFUSION } from '../../../schemas/index.js';
|
|
3
3
|
import { createStreamLogger, registerAddonLogger, getEngineLogger } from '../../../logging/index.js';
|
|
4
4
|
import { ModelLoadFailedError } from '../../../errors/index.js';
|
|
@@ -51,6 +51,7 @@ export const diffusionPlugin = definePlugin({
|
|
|
51
51
|
displayName: 'Image Generation & Upscaling (stable-diffusion.cpp)',
|
|
52
52
|
addonPackage: ADDON_DIFFUSION,
|
|
53
53
|
loadConfigSchema: sdcppConfigSchema,
|
|
54
|
+
assessFit: diffusionAssessFit,
|
|
54
55
|
async resolveConfig(cfg, ctx) {
|
|
55
56
|
if (cfg.uncondModelSrc && cfg.mode !== 'diffusion') {
|
|
56
57
|
throw new ModelLoadFailedError('modelConfig.uncondModelSrc is Ideogram 4 diffusion only. ' +
|
|
@@ -112,7 +113,11 @@ export const diffusionPlugin = definePlugin({
|
|
|
112
113
|
'main-gpu': 'world.backend',
|
|
113
114
|
backend: 'world.backend',
|
|
114
115
|
threads: 'world.threads',
|
|
115
|
-
offload_to_cpu: 'world.offloadParamsToCpu'
|
|
116
|
+
offload_to_cpu: 'world.offloadParamsToCpu',
|
|
117
|
+
params_backend: 'world.paramsBackend',
|
|
118
|
+
max_vram: 'world.maxVram',
|
|
119
|
+
stream_layers: 'world.streamLayers',
|
|
120
|
+
verbosity: 'world.verbosity'
|
|
116
121
|
};
|
|
117
122
|
const unsupported = Object.keys(cfg).filter((key) => !worldSupported.has(key) && cfg[key] !== undefined);
|
|
118
123
|
if (unsupported.length > 0) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { TextToSpeechStreamRequest, TtsRequest } from '../../../../schemas/index.js';
|
|
2
2
|
export type ParlerJobOptions = Pick<TtsRequest, 'description' | 'voiceDescription' | 'voice' | 'emotion' | 'pitch' | 'pace' | 'expressivity' | 'noise' | 'reverb' | 'quality'>;
|
|
3
3
|
type ParlerJobOptionsRequest = TtsRequest | TextToSpeechStreamRequest;
|
|
4
|
+
/** The loaded addon's engine (`TTSGgml#getEngineType()`), when it reports one. */
|
|
5
|
+
export declare function getTtsEngineType(model: unknown): string | undefined;
|
|
4
6
|
export declare function getParlerJobOptions(request: ParlerJobOptionsRequest): ParlerJobOptions;
|
|
5
7
|
export declare function assertParlerJobOptionsSupported(model: unknown, options: ParlerJobOptions, handlerName: 'textToSpeech' | 'textToSpeechStream'): void;
|
|
6
8
|
export {};
|
|
@@ -6,6 +6,10 @@ function hasEngineType(model) {
|
|
|
6
6
|
'getEngineType' in model &&
|
|
7
7
|
typeof model.getEngineType === 'function');
|
|
8
8
|
}
|
|
9
|
+
/** The loaded addon's engine (`TTSGgml#getEngineType()`), when it reports one. */
|
|
10
|
+
export function getTtsEngineType(model) {
|
|
11
|
+
return hasEngineType(model) ? model.getEngineType() : undefined;
|
|
12
|
+
}
|
|
9
13
|
export function getParlerJobOptions(request) {
|
|
10
14
|
return {
|
|
11
15
|
...(request.description !== undefined ? { description: request.description } : {}),
|
|
@@ -30,7 +34,7 @@ export function assertParlerJobOptionsSupported(model, options, handlerName) {
|
|
|
30
34
|
const setKeys = Object.keys(options);
|
|
31
35
|
if (setKeys.length === 0)
|
|
32
36
|
return;
|
|
33
|
-
const engine =
|
|
37
|
+
const engine = getTtsEngineType(model);
|
|
34
38
|
if (engine === 'parler')
|
|
35
39
|
return;
|
|
36
40
|
if (engine === 'cosyvoice3') {
|
|
@@ -54,9 +54,9 @@ import { getModel } from '../../../../runtime/model-registry.js';
|
|
|
54
54
|
import { ttsRequestSchema } from '../../../../schemas/index.js';
|
|
55
55
|
import { nowMs } from '../../../../profiling/index.js';
|
|
56
56
|
import { buildStreamResult, hasDefinedValues } from '../../../../profiling/model-execution.js';
|
|
57
|
-
import { TextToSpeechFailedError } from '../../../../errors/index.js';
|
|
58
|
-
import { collectTtsStats, chunkMetadata } from '../../../../utils/tts-stats.js';
|
|
59
|
-
import { assertParlerJobOptionsSupported, getParlerJobOptions } from './parler-options.js';
|
|
57
|
+
import { PluginRequestValidationFailedError, TextToSpeechFailedError } from '../../../../errors/index.js';
|
|
58
|
+
import { appendPcm, collectTtsStats, chunkMetadata } from '../../../../utils/tts-stats.js';
|
|
59
|
+
import { assertParlerJobOptionsSupported, getParlerJobOptions, getTtsEngineType } from './parler-options.js';
|
|
60
60
|
import { bindTtsCancel, cancelIfAborted } from './cancel-binding.js';
|
|
61
61
|
function hasRunStream(model) {
|
|
62
62
|
return (typeof model === 'object' &&
|
|
@@ -86,6 +86,20 @@ export async function* textToSpeech(params) {
|
|
|
86
86
|
const parlerJobOptions = getParlerJobOptions(request);
|
|
87
87
|
const model = getModel(modelId);
|
|
88
88
|
assertParlerJobOptionsSupported(model, parlerJobOptions, 'textToSpeech');
|
|
89
|
+
// MOSS streams natively: one job over the whole text, emitting a chunk every
|
|
90
|
+
// `streamChunkTokens` codec frames while the backbone is still generating.
|
|
91
|
+
// The sentence chunker behind `streamOutput` would restart the prompt per
|
|
92
|
+
// sentence, which a MOSS-TTSD dialogue cannot do (every job has to open
|
|
93
|
+
// with the reference transcripts, so the addon rejects it) and which would
|
|
94
|
+
// apply `durationTokens` to each sentence rather than to the text.
|
|
95
|
+
// `sentenceStream: true` still asks for the chunker explicitly.
|
|
96
|
+
const nativeStream = stream && !sentenceStream && getTtsEngineType(model) === 'moss';
|
|
97
|
+
// The chunker is what reads these, so on the native path they would be
|
|
98
|
+
// dropped without a trace.
|
|
99
|
+
if (nativeStream &&
|
|
100
|
+
(sentenceStreamLocale !== undefined || sentenceStreamMaxChunkScalars !== undefined)) {
|
|
101
|
+
throw new PluginRequestValidationFailedError('textToSpeech', 'sentenceStreamLocale and sentenceStreamMaxChunkScalars need the sentence chunker; MOSS streams the whole text natively, so they only apply with sentenceStream: true');
|
|
102
|
+
}
|
|
89
103
|
const ctx = __addDisposableResource(env_1, await bindTtsCancel(model, modelId, request.requestId), true);
|
|
90
104
|
if (ctx.signal.aborted)
|
|
91
105
|
return { ...buildStreamResult(0), cancelled: true };
|
|
@@ -107,7 +121,7 @@ export async function* textToSpeech(params) {
|
|
|
107
121
|
: undefined;
|
|
108
122
|
const response = await model.runStream(text, streamOpts);
|
|
109
123
|
if (!stream) {
|
|
110
|
-
|
|
124
|
+
const completeBuffer = [];
|
|
111
125
|
let sampleRate;
|
|
112
126
|
try {
|
|
113
127
|
for await (const data of response.iterate()) {
|
|
@@ -116,7 +130,7 @@ export async function* textToSpeech(params) {
|
|
|
116
130
|
// lunte-disable-next-line eqeqeq -- `!= null` intentionally matches null and undefined
|
|
117
131
|
if (data.outputArray != null) {
|
|
118
132
|
sampleRate ??= data.sampleRate;
|
|
119
|
-
completeBuffer
|
|
133
|
+
appendPcm(completeBuffer, data.outputArray);
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
136
|
}
|
|
@@ -147,6 +161,7 @@ export async function* textToSpeech(params) {
|
|
|
147
161
|
}
|
|
148
162
|
return finish(modelStart, response, ctx.signal.aborted);
|
|
149
163
|
}
|
|
164
|
+
const sentenceChunked = stream && !nativeStream;
|
|
150
165
|
const response = (await model.run({
|
|
151
166
|
input: text,
|
|
152
167
|
// The addon's job field is `type`, and its native layer accepts only
|
|
@@ -154,25 +169,27 @@ export async function* textToSpeech(params) {
|
|
|
154
169
|
// it. Pin it here too, so the request's `inputType` (which the schema
|
|
155
170
|
// does not constrain) behaves the same on every path.
|
|
156
171
|
type: 'text',
|
|
157
|
-
...(
|
|
172
|
+
...(sentenceChunked ? { streamOutput: true } : {}),
|
|
158
173
|
// `run({ streamOutput: true })` runs the same chunker as `runStream()`, so
|
|
159
174
|
// the chunking knobs apply here too — they used to be honoured only on the
|
|
160
175
|
// sentenceStream path.
|
|
161
|
-
...(
|
|
162
|
-
|
|
176
|
+
...(sentenceChunked && sentenceStreamLocale !== undefined
|
|
177
|
+
? { locale: sentenceStreamLocale }
|
|
178
|
+
: {}),
|
|
179
|
+
...(sentenceChunked && sentenceStreamMaxChunkScalars !== undefined
|
|
163
180
|
? { maxChunkScalars: sentenceStreamMaxChunkScalars }
|
|
164
181
|
: {}),
|
|
165
182
|
...parlerJobOptions
|
|
166
183
|
}));
|
|
167
184
|
if (!stream) {
|
|
168
|
-
|
|
185
|
+
const completeBuffer = [];
|
|
169
186
|
let sampleRate;
|
|
170
187
|
try {
|
|
171
188
|
for await (const data of response.iterate()) {
|
|
172
189
|
if (await cancelIfAborted(model, ctx.signal))
|
|
173
190
|
continue;
|
|
174
191
|
sampleRate ??= data.sampleRate;
|
|
175
|
-
completeBuffer
|
|
192
|
+
appendPcm(completeBuffer, data.outputArray);
|
|
176
193
|
}
|
|
177
194
|
}
|
|
178
195
|
catch (error) {
|