@qvac/sdk 0.9.2 → 0.10.0
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 +15 -68
- package/dist/client/api/cancel.d.ts +1 -1
- package/dist/client/api/cancel.js +1 -1
- package/dist/client/api/completion-stream.d.ts +51 -12
- package/dist/client/api/completion-stream.js +129 -56
- package/dist/client/api/delete-cache.d.ts +1 -0
- package/dist/client/api/delete-cache.js +1 -0
- package/dist/client/api/diffusion.d.ts +17 -2
- package/dist/client/api/diffusion.js +21 -4
- package/dist/client/api/embed.d.ts +4 -0
- package/dist/client/api/finetune.d.ts +21 -0
- package/dist/client/api/get-loaded-model-info.d.ts +25 -0
- package/dist/client/api/get-loaded-model-info.js +36 -0
- package/dist/client/api/get-model-info.d.ts +9 -1
- package/dist/client/api/get-model-info.js +8 -0
- package/dist/client/api/heartbeat.d.ts +2 -2
- package/dist/client/api/heartbeat.js +2 -2
- package/dist/client/api/index.d.ts +3 -1
- package/dist/client/api/index.js +3 -1
- package/dist/client/api/invoke-plugin.d.ts +16 -0
- package/dist/client/api/invoke-plugin.js +16 -0
- package/dist/client/api/load-model.d.ts +36 -3
- package/dist/client/api/load-model.js +31 -10
- package/dist/client/api/provide.d.ts +11 -5
- package/dist/client/api/provide.js +11 -6
- package/dist/client/api/rag.d.ts +9 -0
- package/dist/client/api/rag.js +9 -0
- package/dist/client/api/registry.d.ts +26 -0
- package/dist/client/api/registry.js +26 -0
- package/dist/client/api/resume.d.ts +20 -4
- package/dist/client/api/resume.js +20 -4
- package/dist/client/api/state.d.ts +23 -0
- package/dist/client/api/state.js +29 -0
- package/dist/client/api/stop-provider.d.ts +11 -5
- package/dist/client/api/stop-provider.js +11 -5
- package/dist/client/api/suspend.d.ts +21 -3
- package/dist/client/api/suspend.js +21 -3
- package/dist/client/api/text-to-speech.d.ts +64 -6
- package/dist/client/api/text-to-speech.js +423 -47
- package/dist/client/api/transcribe.d.ts +29 -4
- package/dist/client/api/transcribe.js +86 -28
- package/dist/client/api/translate.d.ts +1 -0
- package/dist/client/api/translate.js +1 -0
- package/dist/client/rpc/bare-client.js +22 -1
- package/dist/client/rpc/expo-rpc-client.d.ts +1 -1
- package/dist/client/rpc/expo-rpc-client.js +96 -4
- package/dist/client/rpc/node-rpc-client.js +36 -0
- package/dist/examples/audio/mic-input.d.ts +9 -0
- package/dist/examples/audio/mic-input.js +111 -0
- package/dist/examples/completion-events.d.ts +18 -0
- package/dist/examples/completion-events.js +79 -0
- package/dist/examples/delegated-inference/composite.js +12 -18
- package/dist/examples/delegated-inference/consumer-profiled.js +4 -11
- package/dist/examples/delegated-inference/consumer.js +8 -13
- package/dist/examples/delegated-inference/provider.js +11 -16
- package/dist/examples/diffusion-flux2-klein-img2img.d.ts +2 -0
- package/dist/examples/diffusion-flux2-klein-img2img.js +60 -0
- package/dist/examples/diffusion-flux2-klein.js +1 -0
- package/dist/examples/diffusion-img2img.d.ts +2 -0
- package/dist/examples/diffusion-img2img.js +49 -0
- package/dist/examples/diffusion-txt2img.js +2 -1
- package/dist/examples/kv-cache-example.js +11 -12
- package/dist/examples/llamacpp-cache.d.ts +2 -0
- package/dist/examples/llamacpp-cache.js +107 -0
- package/dist/examples/llamacpp-dynamic-tools.d.ts +2 -0
- package/dist/examples/llamacpp-dynamic-tools.js +144 -0
- package/dist/examples/llamacpp-native-tools.js +2 -8
- package/dist/examples/llamacpp-structured-output.d.ts +2 -0
- package/dist/examples/llamacpp-structured-output.js +106 -0
- package/dist/examples/llamacpp-tools-pythonic.d.ts +2 -0
- package/dist/examples/llamacpp-tools-pythonic.js +69 -0
- package/dist/examples/plugins.js +4 -4
- package/dist/examples/suspend-resume.js +21 -4
- package/dist/examples/transcription/parakeet-microphone-record.js +6 -33
- package/dist/examples/transcription/whispercpp-filesystem-streaming.js +7 -5
- package/dist/examples/transcription/whispercpp-filesystem.js +12 -3
- package/dist/examples/transcription/whispercpp-microphone-record.js +6 -29
- package/dist/examples/translation/translation-stream.js +5 -5
- package/dist/examples/tts/llm-to-tts-streaming.d.ts +16 -0
- package/dist/examples/tts/llm-to-tts-streaming.js +143 -0
- package/dist/examples/tts/supertonic-multilingual.js +3 -3
- package/dist/examples/tts/supertonic.js +3 -3
- package/dist/examples/tts/utils.d.ts +11 -1
- package/dist/examples/tts/utils.js +70 -17
- package/dist/examples/voice-assistant/voice-assistant.d.ts +2 -0
- package/dist/examples/voice-assistant/voice-assistant.js +207 -0
- package/dist/expo/plugins/withMobileBundle.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/logging/logger.d.ts +11 -0
- package/dist/logging/logger.js +11 -0
- package/dist/logging/types.d.ts +18 -0
- package/dist/models/registry/models.d.ts +6620 -6185
- package/dist/models/registry/models.js +6296 -5318
- package/dist/models/update-models/codegen.js +84 -23
- package/dist/models/update-models/companions.d.ts +18 -0
- package/dist/models/update-models/companions.js +175 -0
- package/dist/models/update-models/naming.js +0 -25
- package/dist/models/update-models/registry.js +4 -2
- package/dist/models/update-models/types.d.ts +37 -9
- package/dist/profiling/index.d.ts +49 -0
- package/dist/profiling/index.js +49 -0
- package/dist/schemas/cancel.d.ts +6 -2
- package/dist/schemas/cancel.js +14 -7
- package/dist/schemas/common.d.ts +353 -271
- package/dist/schemas/common.js +26 -5
- package/dist/schemas/completion-event.d.ts +225 -0
- package/dist/schemas/completion-event.js +79 -0
- package/dist/schemas/completion-stream.d.ts +122 -31
- package/dist/schemas/completion-stream.js +137 -36
- package/dist/schemas/delegate.d.ts +0 -2
- package/dist/schemas/delegate.js +25 -6
- package/dist/schemas/download-asset.d.ts +5 -5
- package/dist/schemas/embed.js +21 -9
- package/dist/schemas/engine-addon-map.d.ts +11 -1
- package/dist/schemas/engine-addon-map.js +2 -2
- package/dist/schemas/get-loaded-model-info.d.ts +52 -0
- package/dist/schemas/get-loaded-model-info.js +44 -0
- package/dist/schemas/get-model-info.d.ts +2 -2
- package/dist/schemas/get-model-info.js +103 -32
- package/dist/schemas/heartbeat.d.ts +0 -1
- package/dist/schemas/index.d.ts +4 -1
- package/dist/schemas/index.js +4 -1
- package/dist/schemas/llamacpp-config.d.ts +14 -4
- package/dist/schemas/llamacpp-config.js +5 -0
- package/dist/schemas/load-model.d.ts +3233 -1260
- package/dist/schemas/load-model.js +23 -16
- package/dist/schemas/model-src-utils.d.ts +7 -6
- package/dist/schemas/model-src-utils.js +27 -1
- package/dist/schemas/model-types.d.ts +4 -4
- package/dist/schemas/ocr.d.ts +1 -1
- package/dist/schemas/plugin.d.ts +27 -3
- package/dist/schemas/plugin.js +27 -2
- package/dist/schemas/profiling.js +11 -3
- package/dist/schemas/provide.d.ts +1 -3
- package/dist/schemas/provide.js +0 -3
- package/dist/schemas/rag.d.ts +4 -4
- package/dist/schemas/registry.d.ts +10 -10
- package/dist/schemas/registry.js +36 -14
- package/dist/schemas/reload-config.d.ts +73 -7
- package/dist/schemas/sdcpp-config.d.ts +16 -8
- package/dist/schemas/sdcpp-config.js +118 -25
- package/dist/schemas/sdk-config.d.ts +116 -90
- package/dist/schemas/sdk-config.js +16 -0
- package/dist/schemas/sdk-errors-client.d.ts +3 -0
- package/dist/schemas/sdk-errors-client.js +16 -1
- package/dist/schemas/sdk-errors-server.d.ts +3 -0
- package/dist/schemas/sdk-errors-server.js +23 -0
- package/dist/schemas/state.d.ts +23 -0
- package/dist/schemas/state.js +14 -0
- package/dist/schemas/stop-provide.d.ts +0 -5
- package/dist/schemas/stop-provide.js +2 -6
- package/dist/schemas/text-to-speech.d.ts +93 -27
- package/dist/schemas/text-to-speech.js +27 -0
- package/dist/schemas/tools.d.ts +16 -0
- package/dist/schemas/tools.js +15 -0
- package/dist/schemas/transcription-config.d.ts +8 -8
- package/dist/schemas/transcription.d.ts +33 -0
- package/dist/schemas/transcription.js +9 -0
- package/dist/schemas/translate.js +59 -19
- package/dist/schemas/translation-config.d.ts +157 -133
- package/dist/schemas/translation-config.js +34 -11
- package/dist/server/bare/delegate-rpc-client.d.ts +1 -1
- package/dist/server/bare/delegate-rpc-client.js +131 -122
- package/dist/server/bare/hyperswarm.d.ts +2 -2
- package/dist/server/bare/hyperswarm.js +12 -7
- package/dist/server/bare/ops/cancel.js +7 -0
- package/dist/server/bare/ops/kv-cache-utils.d.ts +7 -10
- package/dist/server/bare/ops/kv-cache-utils.js +31 -40
- package/dist/server/bare/ops/load-model.js +0 -1
- package/dist/server/bare/ops/transcribe.d.ts +11 -4
- package/dist/server/bare/ops/transcribe.js +25 -4
- package/dist/server/bare/ops/translate.js +42 -4
- package/dist/server/bare/ops/unload-model.js +21 -19
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +1 -2
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +13 -8
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +257 -85
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +101 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +135 -0
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +79 -22
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +57 -32
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -16
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +69 -44
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +113 -94
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +1 -2
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.d.ts +7 -0
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.js +116 -0
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.d.ts +2 -3
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.js +71 -9
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +41 -13
- package/dist/server/bare/plugins/onnx-tts/plugin.js +48 -3
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +15 -7
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +5 -6
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +6 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +8 -5
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +13 -13
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +17 -1
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +40 -17
- package/dist/server/bare/registry/config-registry.js +14 -3
- package/dist/server/bare/registry/model-registry.d.ts +8 -10
- package/dist/server/bare/registry/model-registry.js +17 -12
- package/dist/server/bare/registry/registry-client.js +79 -19
- package/dist/server/bare/runtime-lifecycle.d.ts +2 -1
- package/dist/server/bare/runtime-lifecycle.js +13 -2
- package/dist/server/bare/types/addon-responses.d.ts +8 -3
- package/dist/server/bare/utils/transcribe-metadata.d.ts +21 -0
- package/dist/server/bare/utils/transcribe-metadata.js +28 -0
- package/dist/server/bare/utils/tts-stats.d.ts +22 -0
- package/dist/server/bare/utils/tts-stats.js +10 -0
- package/dist/server/rpc/create-server.d.ts +4 -1
- package/dist/server/rpc/create-server.js +5 -1
- package/dist/server/rpc/delegate-transport.js +36 -29
- package/dist/server/rpc/handle-request.js +28 -3
- package/dist/server/rpc/handler-registry.js +7 -1
- package/dist/server/rpc/handler-utils.d.ts +5 -0
- package/dist/server/rpc/handler-utils.js +22 -0
- package/dist/server/rpc/handlers/cancel-delegated.js +3 -5
- package/dist/server/rpc/handlers/cancelHandler.js +4 -5
- package/dist/server/rpc/handlers/completion-stream-delegated.js +14 -5
- package/dist/server/rpc/handlers/delete-cache.js +8 -3
- package/dist/server/rpc/handlers/download-asset.js +3 -24
- package/dist/server/rpc/handlers/get-loaded-model-info.d.ts +3 -0
- package/dist/server/rpc/handlers/get-loaded-model-info.js +39 -0
- package/dist/server/rpc/handlers/get-model-info.js +93 -84
- package/dist/server/rpc/handlers/heartbeat-delegated.js +2 -2
- package/dist/server/rpc/handlers/index.d.ts +6 -0
- package/dist/server/rpc/handlers/index.js +6 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +35 -9
- package/dist/server/rpc/handlers/load-model/download-manager.js +142 -38
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +5 -4
- package/dist/server/rpc/handlers/load-model/download-stats.js +49 -8
- package/dist/server/rpc/handlers/load-model/handler.js +31 -50
- package/dist/server/rpc/handlers/load-model/http.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/http.js +97 -142
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +55 -74
- package/dist/server/rpc/handlers/load-model/index.d.ts +0 -1
- package/dist/server/rpc/handlers/load-model/index.js +0 -1
- package/dist/server/rpc/handlers/load-model/registry-client-options.d.ts +27 -0
- package/dist/server/rpc/handlers/load-model/registry-client-options.js +19 -0
- package/dist/server/rpc/handlers/load-model/registry-companion-set.d.ts +22 -0
- package/dist/server/rpc/handlers/load-model/registry-companion-set.js +208 -0
- package/dist/server/rpc/handlers/load-model/registry-download-utils.d.ts +24 -0
- package/dist/server/rpc/handlers/load-model/registry-download-utils.js +114 -0
- package/dist/server/rpc/handlers/load-model/registry.d.ts +2 -20
- package/dist/server/rpc/handlers/load-model/registry.js +109 -381
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +15 -0
- package/dist/server/rpc/handlers/load-model/resolve-session.js +61 -0
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/resolve.js +14 -23
- package/dist/server/rpc/handlers/load-model/types.d.ts +11 -4
- package/dist/server/rpc/handlers/load-model/types.js +28 -1
- package/dist/server/rpc/handlers/load-model-delegated.js +2 -4
- package/dist/server/rpc/handlers/plugin-dispatch.js +9 -5
- package/dist/server/rpc/handlers/plugin-invoke.js +1 -1
- package/dist/server/rpc/handlers/provideHandler/connection.js +13 -2
- package/dist/server/rpc/handlers/provideHandler/handler.js +42 -29
- package/dist/server/rpc/handlers/state.d.ts +3 -0
- package/dist/server/rpc/handlers/state.js +7 -0
- package/dist/server/rpc/handlers/stopProvideHandler.d.ts +2 -2
- package/dist/server/rpc/handlers/stopProvideHandler.js +12 -7
- package/dist/server/rpc/handlers/text-to-speech-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/text-to-speech-stream.js +4 -0
- package/dist/server/rpc/handlers/unload-model-delegated.js +3 -3
- package/dist/server/rpc/profiling/operation-metrics.js +20 -0
- package/dist/server/rpc/rpc-utils.js +1 -1
- package/dist/server/rpc/transport-selector.d.ts +3 -0
- package/dist/server/rpc/transport-selector.js +18 -0
- package/dist/server/utils/cache/auto-history.d.ts +4 -0
- package/dist/server/utils/cache/auto-history.js +22 -0
- package/dist/server/utils/{cache.d.ts → cache/paths.d.ts} +22 -5
- package/dist/server/utils/{cache.js → cache/paths.js} +36 -20
- package/dist/server/utils/cache/types.d.ts +8 -0
- package/dist/server/utils/cache/types.js +1 -0
- package/dist/server/utils/checksum.d.ts +2 -2
- package/dist/server/utils/checksum.js +1 -1
- package/dist/server/utils/clear-storage.d.ts +5 -0
- package/dist/server/utils/clear-storage.js +17 -0
- package/dist/server/utils/completion-normalizer.d.ts +17 -0
- package/dist/server/utils/completion-normalizer.js +301 -0
- package/dist/server/utils/expand-gguf-shards.d.ts +3 -0
- package/dist/server/utils/expand-gguf-shards.js +22 -0
- package/dist/server/utils/formatting.js +1 -1
- package/dist/server/utils/index.d.ts +4 -2
- package/dist/server/utils/index.js +4 -2
- package/dist/server/utils/qvac-paths.d.ts +2 -0
- package/dist/server/utils/qvac-paths.js +5 -0
- package/dist/server/utils/response-format.d.ts +3 -0
- package/dist/server/utils/response-format.js +20 -0
- package/dist/server/utils/tool-integration.d.ts +15 -4
- package/dist/server/utils/tool-integration.js +21 -41
- package/dist/server/utils/tools/dialect.d.ts +8 -0
- package/dist/server/utils/tools/dialect.js +12 -0
- package/dist/server/utils/tools/index.d.ts +3 -0
- package/dist/server/utils/tools/index.js +2 -0
- package/dist/server/utils/tools/parser.d.ts +6 -0
- package/dist/server/utils/tools/parser.js +40 -0
- package/dist/server/utils/tools/parsers/hermes.d.ts +4 -0
- package/dist/server/utils/tools/parsers/hermes.js +100 -0
- package/dist/server/utils/tools/parsers/json.d.ts +6 -0
- package/dist/server/utils/tools/parsers/json.js +115 -0
- package/dist/server/utils/tools/parsers/pythonic.d.ts +4 -0
- package/dist/server/utils/tools/parsers/pythonic.js +267 -0
- package/dist/server/utils/tools/shared.d.ts +18 -0
- package/dist/server/utils/tools/shared.js +54 -0
- package/dist/server/utils/worker-lock.d.ts +3 -0
- package/dist/server/utils/worker-lock.js +67 -0
- package/dist/server/worker-core.d.ts +16 -1
- package/dist/server/worker-core.js +114 -14
- package/dist/utils/aggregate-events.d.ts +16 -0
- package/dist/utils/aggregate-events.js +52 -0
- package/dist/utils/cache-normalize.d.ts +10 -0
- package/dist/utils/cache-normalize.js +23 -0
- package/dist/utils/encoding.d.ts +8 -0
- package/dist/utils/encoding.js +13 -0
- package/dist/utils/errors-client.d.ts +12 -0
- package/dist/utils/errors-client.js +20 -0
- package/dist/utils/errors-server.d.ts +14 -0
- package/dist/utils/errors-server.js +31 -0
- package/dist/utils/load-model-validation.d.ts +7 -0
- package/dist/utils/load-model-validation.js +18 -0
- package/expo/plugins/patches/android-link.mjs +1 -1
- package/expo/plugins/patches/ios-link.mjs +1 -1
- package/package.json +14 -18
- package/dist/examples/translation/translation-opus.d.ts +0 -2
- package/dist/examples/translation/translation-opus.js +0 -33
- package/dist/server/bare/utils/loader-adapter.d.ts +0 -7
- package/dist/server/bare/utils/loader-adapter.js +0 -9
- package/dist/server/utils/model-path.d.ts +0 -5
- package/dist/server/utils/model-path.js +0 -7
- package/dist/server/utils/tool-parser.d.ts +0 -7
- package/dist/server/utils/tool-parser.js +0 -248
|
@@ -1,34 +1,96 @@
|
|
|
1
1
|
import { getModel } from "../../../registry/model-registry.js";
|
|
2
|
-
import { ttsRequestSchema } from "../../../../../schemas/index.js";
|
|
2
|
+
import { ttsRequestSchema, } from "../../../../../schemas/index.js";
|
|
3
3
|
import { nowMs } from "../../../../../profiling/index.js";
|
|
4
4
|
import { buildStreamResult, hasDefinedValues } from "../../../../../profiling/model-execution.js";
|
|
5
|
+
import { TextToSpeechFailedError } from "../../../../../utils/errors-server.js";
|
|
6
|
+
import { collectTtsStats, } from "../../../utils/tts-stats.js";
|
|
7
|
+
function hasRunStream(model) {
|
|
8
|
+
return (typeof model === "object" &&
|
|
9
|
+
model !== null &&
|
|
10
|
+
"runStream" in model &&
|
|
11
|
+
typeof model.runStream === "function");
|
|
12
|
+
}
|
|
5
13
|
export async function* textToSpeech(params) {
|
|
6
|
-
const { modelId, inputType, text, stream } = ttsRequestSchema.parse(params);
|
|
14
|
+
const { modelId, inputType, text, stream, sentenceStream, sentenceStreamLocale, sentenceStreamMaxChunkScalars, } = ttsRequestSchema.parse(params);
|
|
7
15
|
const model = getModel(modelId);
|
|
8
16
|
const modelStart = nowMs();
|
|
9
|
-
|
|
17
|
+
if (sentenceStream) {
|
|
18
|
+
if (!hasRunStream(model)) {
|
|
19
|
+
throw new TextToSpeechFailedError("sentenceStream requires an ONNX TTS model with runStream (Supertonic)");
|
|
20
|
+
}
|
|
21
|
+
const streamOpts = sentenceStreamLocale !== undefined || sentenceStreamMaxChunkScalars !== undefined
|
|
22
|
+
? {
|
|
23
|
+
...(sentenceStreamLocale !== undefined
|
|
24
|
+
? { locale: sentenceStreamLocale }
|
|
25
|
+
: {}),
|
|
26
|
+
...(sentenceStreamMaxChunkScalars !== undefined
|
|
27
|
+
? { maxChunkScalars: sentenceStreamMaxChunkScalars }
|
|
28
|
+
: {}),
|
|
29
|
+
}
|
|
30
|
+
: undefined;
|
|
31
|
+
const response = await model.runStream(text, streamOpts);
|
|
32
|
+
if (!stream) {
|
|
33
|
+
let completeBuffer = [];
|
|
34
|
+
for await (const data of response.iterate()) {
|
|
35
|
+
if (data.outputArray != null) {
|
|
36
|
+
completeBuffer = completeBuffer.concat(Array.from(data.outputArray));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const modelExecutionMs = nowMs() - modelStart;
|
|
40
|
+
const stats = collectTtsStats(response);
|
|
41
|
+
yield { buffer: completeBuffer };
|
|
42
|
+
return buildStreamResult(modelExecutionMs, hasDefinedValues(stats) ? stats : undefined);
|
|
43
|
+
}
|
|
44
|
+
for await (const data of response.iterate()) {
|
|
45
|
+
if (data.outputArray == null)
|
|
46
|
+
continue;
|
|
47
|
+
const buf = Array.from(data.outputArray);
|
|
48
|
+
if (buf.length === 0)
|
|
49
|
+
continue;
|
|
50
|
+
yield {
|
|
51
|
+
buffer: buf,
|
|
52
|
+
...(data.chunkIndex !== undefined ? { chunkIndex: data.chunkIndex } : {}),
|
|
53
|
+
...(typeof data.sentenceChunk === "string" && data.sentenceChunk.length > 0
|
|
54
|
+
? { sentenceChunk: data.sentenceChunk }
|
|
55
|
+
: {}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const modelExecutionMs = nowMs() - modelStart;
|
|
59
|
+
const stats = collectTtsStats(response);
|
|
60
|
+
return buildStreamResult(modelExecutionMs, hasDefinedValues(stats) ? stats : undefined);
|
|
61
|
+
}
|
|
62
|
+
const response = (await model.run({
|
|
63
|
+
input: text,
|
|
64
|
+
inputType,
|
|
65
|
+
}));
|
|
10
66
|
if (!stream) {
|
|
11
|
-
// Non-streaming mode: collect all chunks and return once
|
|
12
67
|
let completeBuffer = [];
|
|
13
68
|
for await (const data of response.iterate()) {
|
|
14
69
|
completeBuffer = completeBuffer.concat(Array.from(data.outputArray));
|
|
15
70
|
}
|
|
16
71
|
const modelExecutionMs = nowMs() - modelStart;
|
|
17
72
|
const stats = {
|
|
18
|
-
...(response.stats?.audioDurationMs !== undefined && {
|
|
19
|
-
|
|
73
|
+
...(response.stats?.audioDurationMs !== undefined && {
|
|
74
|
+
audioDuration: response.stats.audioDurationMs,
|
|
75
|
+
}),
|
|
76
|
+
...(response.stats?.totalSamples !== undefined && {
|
|
77
|
+
totalSamples: response.stats.totalSamples,
|
|
78
|
+
}),
|
|
20
79
|
};
|
|
21
80
|
yield { buffer: completeBuffer };
|
|
22
81
|
return buildStreamResult(modelExecutionMs, hasDefinedValues(stats) ? stats : undefined);
|
|
23
82
|
}
|
|
24
|
-
// Streaming mode: yield chunks as they arrive
|
|
25
83
|
for await (const data of response.iterate()) {
|
|
26
84
|
yield { buffer: Array.from(data.outputArray) };
|
|
27
85
|
}
|
|
28
86
|
const modelExecutionMs = nowMs() - modelStart;
|
|
29
87
|
const stats = {
|
|
30
|
-
...(response.stats?.audioDurationMs !== undefined && {
|
|
31
|
-
|
|
88
|
+
...(response.stats?.audioDurationMs !== undefined && {
|
|
89
|
+
audioDuration: response.stats.audioDurationMs,
|
|
90
|
+
}),
|
|
91
|
+
...(response.stats?.totalSamples !== undefined && {
|
|
92
|
+
totalSamples: response.stats.totalSamples,
|
|
93
|
+
}),
|
|
32
94
|
};
|
|
33
95
|
return buildStreamResult(modelExecutionMs, hasDefinedValues(stats) ? stats : undefined);
|
|
34
96
|
}
|
|
@@ -23,6 +23,7 @@ export declare const ttsPlugin: {
|
|
|
23
23
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
24
24
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
25
25
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
26
|
+
embeddings: "embeddings";
|
|
26
27
|
"llamacpp-completion": "llamacpp-completion";
|
|
27
28
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
28
29
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -33,7 +34,6 @@ export declare const ttsPlugin: {
|
|
|
33
34
|
"sdcpp-generation": "sdcpp-generation";
|
|
34
35
|
llm: "llm";
|
|
35
36
|
whisper: "whisper";
|
|
36
|
-
embeddings: "embeddings";
|
|
37
37
|
nmt: "nmt";
|
|
38
38
|
parakeet: "parakeet";
|
|
39
39
|
tts: "tts";
|
|
@@ -53,6 +53,7 @@ export declare const ttsPlugin: {
|
|
|
53
53
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
54
54
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
55
55
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
56
|
+
embeddings: "embeddings";
|
|
56
57
|
"llamacpp-completion": "llamacpp-completion";
|
|
57
58
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
58
59
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -63,7 +64,6 @@ export declare const ttsPlugin: {
|
|
|
63
64
|
"sdcpp-generation": "sdcpp-generation";
|
|
64
65
|
llm: "llm";
|
|
65
66
|
whisper: "whisper";
|
|
66
|
-
embeddings: "embeddings";
|
|
67
67
|
nmt: "nmt";
|
|
68
68
|
parakeet: "parakeet";
|
|
69
69
|
tts: "tts";
|
|
@@ -83,6 +83,7 @@ export declare const ttsPlugin: {
|
|
|
83
83
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
84
84
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
85
85
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
86
|
+
embeddings: "embeddings";
|
|
86
87
|
"llamacpp-completion": "llamacpp-completion";
|
|
87
88
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
88
89
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -93,7 +94,6 @@ export declare const ttsPlugin: {
|
|
|
93
94
|
"sdcpp-generation": "sdcpp-generation";
|
|
94
95
|
llm: "llm";
|
|
95
96
|
whisper: "whisper";
|
|
96
|
-
embeddings: "embeddings";
|
|
97
97
|
nmt: "nmt";
|
|
98
98
|
parakeet: "parakeet";
|
|
99
99
|
tts: "tts";
|
|
@@ -113,6 +113,7 @@ export declare const ttsPlugin: {
|
|
|
113
113
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
114
114
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
115
115
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
116
|
+
embeddings: "embeddings";
|
|
116
117
|
"llamacpp-completion": "llamacpp-completion";
|
|
117
118
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
118
119
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -123,7 +124,6 @@ export declare const ttsPlugin: {
|
|
|
123
124
|
"sdcpp-generation": "sdcpp-generation";
|
|
124
125
|
llm: "llm";
|
|
125
126
|
whisper: "whisper";
|
|
126
|
-
embeddings: "embeddings";
|
|
127
127
|
nmt: "nmt";
|
|
128
128
|
parakeet: "parakeet";
|
|
129
129
|
tts: "tts";
|
|
@@ -143,6 +143,7 @@ export declare const ttsPlugin: {
|
|
|
143
143
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
144
144
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
145
145
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
146
|
+
embeddings: "embeddings";
|
|
146
147
|
"llamacpp-completion": "llamacpp-completion";
|
|
147
148
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
148
149
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -153,7 +154,6 @@ export declare const ttsPlugin: {
|
|
|
153
154
|
"sdcpp-generation": "sdcpp-generation";
|
|
154
155
|
llm: "llm";
|
|
155
156
|
whisper: "whisper";
|
|
156
|
-
embeddings: "embeddings";
|
|
157
157
|
nmt: "nmt";
|
|
158
158
|
parakeet: "parakeet";
|
|
159
159
|
tts: "tts";
|
|
@@ -173,6 +173,7 @@ export declare const ttsPlugin: {
|
|
|
173
173
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
174
174
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
175
175
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
176
|
+
embeddings: "embeddings";
|
|
176
177
|
"llamacpp-completion": "llamacpp-completion";
|
|
177
178
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
178
179
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -183,7 +184,6 @@ export declare const ttsPlugin: {
|
|
|
183
184
|
"sdcpp-generation": "sdcpp-generation";
|
|
184
185
|
llm: "llm";
|
|
185
186
|
whisper: "whisper";
|
|
186
|
-
embeddings: "embeddings";
|
|
187
187
|
nmt: "nmt";
|
|
188
188
|
parakeet: "parakeet";
|
|
189
189
|
tts: "tts";
|
|
@@ -214,6 +214,7 @@ export declare const ttsPlugin: {
|
|
|
214
214
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
215
215
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
216
216
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
217
|
+
embeddings: "embeddings";
|
|
217
218
|
"llamacpp-completion": "llamacpp-completion";
|
|
218
219
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
219
220
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -224,7 +225,6 @@ export declare const ttsPlugin: {
|
|
|
224
225
|
"sdcpp-generation": "sdcpp-generation";
|
|
225
226
|
llm: "llm";
|
|
226
227
|
whisper: "whisper";
|
|
227
|
-
embeddings: "embeddings";
|
|
228
228
|
nmt: "nmt";
|
|
229
229
|
parakeet: "parakeet";
|
|
230
230
|
tts: "tts";
|
|
@@ -244,6 +244,7 @@ export declare const ttsPlugin: {
|
|
|
244
244
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
245
245
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
246
246
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
247
|
+
embeddings: "embeddings";
|
|
247
248
|
"llamacpp-completion": "llamacpp-completion";
|
|
248
249
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
249
250
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -254,7 +255,6 @@ export declare const ttsPlugin: {
|
|
|
254
255
|
"sdcpp-generation": "sdcpp-generation";
|
|
255
256
|
llm: "llm";
|
|
256
257
|
whisper: "whisper";
|
|
257
|
-
embeddings: "embeddings";
|
|
258
258
|
nmt: "nmt";
|
|
259
259
|
parakeet: "parakeet";
|
|
260
260
|
tts: "tts";
|
|
@@ -274,6 +274,7 @@ export declare const ttsPlugin: {
|
|
|
274
274
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
275
275
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
276
276
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
277
|
+
embeddings: "embeddings";
|
|
277
278
|
"llamacpp-completion": "llamacpp-completion";
|
|
278
279
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
279
280
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -284,7 +285,6 @@ export declare const ttsPlugin: {
|
|
|
284
285
|
"sdcpp-generation": "sdcpp-generation";
|
|
285
286
|
llm: "llm";
|
|
286
287
|
whisper: "whisper";
|
|
287
|
-
embeddings: "embeddings";
|
|
288
288
|
nmt: "nmt";
|
|
289
289
|
parakeet: "parakeet";
|
|
290
290
|
tts: "tts";
|
|
@@ -304,6 +304,7 @@ export declare const ttsPlugin: {
|
|
|
304
304
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
305
305
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
306
306
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
307
|
+
embeddings: "embeddings";
|
|
307
308
|
"llamacpp-completion": "llamacpp-completion";
|
|
308
309
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
309
310
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -314,7 +315,6 @@ export declare const ttsPlugin: {
|
|
|
314
315
|
"sdcpp-generation": "sdcpp-generation";
|
|
315
316
|
llm: "llm";
|
|
316
317
|
whisper: "whisper";
|
|
317
|
-
embeddings: "embeddings";
|
|
318
318
|
nmt: "nmt";
|
|
319
319
|
parakeet: "parakeet";
|
|
320
320
|
tts: "tts";
|
|
@@ -334,6 +334,7 @@ export declare const ttsPlugin: {
|
|
|
334
334
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
335
335
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
336
336
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
337
|
+
embeddings: "embeddings";
|
|
337
338
|
"llamacpp-completion": "llamacpp-completion";
|
|
338
339
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
339
340
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -344,7 +345,6 @@ export declare const ttsPlugin: {
|
|
|
344
345
|
"sdcpp-generation": "sdcpp-generation";
|
|
345
346
|
llm: "llm";
|
|
346
347
|
whisper: "whisper";
|
|
347
|
-
embeddings: "embeddings";
|
|
348
348
|
nmt: "nmt";
|
|
349
349
|
parakeet: "parakeet";
|
|
350
350
|
tts: "tts";
|
|
@@ -364,6 +364,7 @@ export declare const ttsPlugin: {
|
|
|
364
364
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
365
365
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
366
366
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
367
|
+
embeddings: "embeddings";
|
|
367
368
|
"llamacpp-completion": "llamacpp-completion";
|
|
368
369
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
369
370
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -374,7 +375,6 @@ export declare const ttsPlugin: {
|
|
|
374
375
|
"sdcpp-generation": "sdcpp-generation";
|
|
375
376
|
llm: "llm";
|
|
376
377
|
whisper: "whisper";
|
|
377
|
-
embeddings: "embeddings";
|
|
378
378
|
nmt: "nmt";
|
|
379
379
|
parakeet: "parakeet";
|
|
380
380
|
tts: "tts";
|
|
@@ -394,6 +394,7 @@ export declare const ttsPlugin: {
|
|
|
394
394
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
395
395
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
396
396
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
397
|
+
embeddings: "embeddings";
|
|
397
398
|
"llamacpp-completion": "llamacpp-completion";
|
|
398
399
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
399
400
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -404,7 +405,6 @@ export declare const ttsPlugin: {
|
|
|
404
405
|
"sdcpp-generation": "sdcpp-generation";
|
|
405
406
|
llm: "llm";
|
|
406
407
|
whisper: "whisper";
|
|
407
|
-
embeddings: "embeddings";
|
|
408
408
|
nmt: "nmt";
|
|
409
409
|
parakeet: "parakeet";
|
|
410
410
|
tts: "tts";
|
|
@@ -443,6 +443,9 @@ export declare const ttsPlugin: {
|
|
|
443
443
|
inputType: import("zod").ZodDefault<import("zod").ZodString>;
|
|
444
444
|
text: import("zod").ZodString;
|
|
445
445
|
stream: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
446
|
+
sentenceStream: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
447
|
+
sentenceStreamLocale: import("zod").ZodOptional<import("zod").ZodString>;
|
|
448
|
+
sentenceStreamMaxChunkScalars: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
446
449
|
type: import("zod").ZodLiteral<"textToSpeech">;
|
|
447
450
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
448
451
|
type: import("zod").ZodLiteral<"textToSpeech">;
|
|
@@ -452,6 +455,31 @@ export declare const ttsPlugin: {
|
|
|
452
455
|
audioDuration: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
453
456
|
totalSamples: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
454
457
|
}, import("zod/v4/core").$strip>>;
|
|
458
|
+
chunkIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
459
|
+
sentenceChunk: import("zod").ZodOptional<import("zod").ZodString>;
|
|
460
|
+
}, import("zod/v4/core").$strip>>;
|
|
461
|
+
textToSpeechStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
462
|
+
modelId: import("zod").ZodString;
|
|
463
|
+
inputType: import("zod").ZodDefault<import("zod").ZodString>;
|
|
464
|
+
accumulateSentences: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
465
|
+
sentenceDelimiterPreset: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
466
|
+
latin: "latin";
|
|
467
|
+
cjk: "cjk";
|
|
468
|
+
multilingual: "multilingual";
|
|
469
|
+
}>>;
|
|
470
|
+
maxBufferScalars: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
471
|
+
flushAfterMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
472
|
+
type: import("zod").ZodLiteral<"textToSpeechStream">;
|
|
473
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
474
|
+
type: import("zod").ZodLiteral<"textToSpeechStream">;
|
|
475
|
+
buffer: import("zod").ZodArray<import("zod").ZodNumber>;
|
|
476
|
+
done: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
477
|
+
stats: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
478
|
+
audioDuration: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
479
|
+
totalSamples: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
480
|
+
}, import("zod/v4/core").$strip>>;
|
|
481
|
+
chunkIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
482
|
+
sentenceChunk: import("zod").ZodOptional<import("zod").ZodString>;
|
|
455
483
|
}, import("zod/v4/core").$strip>>;
|
|
456
484
|
};
|
|
457
485
|
logging: {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import path from "bare-path";
|
|
2
2
|
import ttsAddonLogging from "@qvac/tts-onnx/addonLogging.js";
|
|
3
3
|
import ONNXTTS from "@qvac/tts-onnx";
|
|
4
|
-
import { definePlugin, defineHandler, ttsRequestSchema, ttsResponseSchema, ModelType, ttsConfigSchema, ADDON_TTS, } from "../../../../schemas/index.js";
|
|
4
|
+
import { definePlugin, defineHandler, defineDuplexHandler, ttsRequestSchema, ttsResponseSchema, textToSpeechStreamRequestSchema, textToSpeechStreamResponseSchema, ModelType, ttsConfigSchema, ADDON_TTS, } from "../../../../schemas/index.js";
|
|
5
5
|
import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
|
|
6
6
|
import { TtsArtifactsRequiredError, TtsReferenceAudioRequiredError, } from "../../../../utils/errors-server.js";
|
|
7
7
|
import { textToSpeech } from "./ops/text-to-speech.js";
|
|
8
|
+
import { textToSpeechStream } from "./ops/text-to-speech-stream.js";
|
|
8
9
|
import { attachModelExecutionMs } from "../../../../profiling/model-execution.js";
|
|
9
10
|
import { loadReferenceAudioAt24k } from "./wav-helper.js";
|
|
10
11
|
async function resolveChatterboxConfig(config, ctx) {
|
|
@@ -118,7 +119,7 @@ function createChatterboxModel(modelId, config, artifacts) {
|
|
|
118
119
|
opts: { stats: true },
|
|
119
120
|
exclusiveRun: true,
|
|
120
121
|
});
|
|
121
|
-
return { model
|
|
122
|
+
return { model };
|
|
122
123
|
}
|
|
123
124
|
function createSupertonicModel(modelId, config, artifacts) {
|
|
124
125
|
const textEncoderPath = artifacts["textEncoderPath"];
|
|
@@ -160,7 +161,7 @@ function createSupertonicModel(modelId, config, artifacts) {
|
|
|
160
161
|
opts: { stats: true },
|
|
161
162
|
exclusiveRun: true,
|
|
162
163
|
});
|
|
163
|
-
return { model
|
|
164
|
+
return { model };
|
|
164
165
|
}
|
|
165
166
|
export const ttsPlugin = definePlugin({
|
|
166
167
|
modelType: ModelType.onnxTts,
|
|
@@ -197,6 +198,13 @@ export const ttsPlugin = definePlugin({
|
|
|
197
198
|
type: "textToSpeech",
|
|
198
199
|
buffer: result.value.buffer,
|
|
199
200
|
done: false,
|
|
201
|
+
...(result.value.chunkIndex !== undefined
|
|
202
|
+
? { chunkIndex: result.value.chunkIndex }
|
|
203
|
+
: {}),
|
|
204
|
+
...(typeof result.value.sentenceChunk === "string" &&
|
|
205
|
+
result.value.sentenceChunk.length > 0
|
|
206
|
+
? { sentenceChunk: result.value.sentenceChunk }
|
|
207
|
+
: {}),
|
|
200
208
|
};
|
|
201
209
|
result = await stream.next();
|
|
202
210
|
}
|
|
@@ -213,6 +221,43 @@ export const ttsPlugin = definePlugin({
|
|
|
213
221
|
}
|
|
214
222
|
},
|
|
215
223
|
}),
|
|
224
|
+
textToSpeechStream: defineDuplexHandler({
|
|
225
|
+
requestSchema: textToSpeechStreamRequestSchema,
|
|
226
|
+
responseSchema: textToSpeechStreamResponseSchema,
|
|
227
|
+
streaming: true,
|
|
228
|
+
duplex: true,
|
|
229
|
+
handler: async function* (request, inputStream) {
|
|
230
|
+
const stream = textToSpeechStream(request, inputStream);
|
|
231
|
+
try {
|
|
232
|
+
let result = await stream.next();
|
|
233
|
+
while (!result.done) {
|
|
234
|
+
yield {
|
|
235
|
+
type: "textToSpeechStream",
|
|
236
|
+
buffer: result.value.buffer,
|
|
237
|
+
done: false,
|
|
238
|
+
...(result.value.chunkIndex !== undefined
|
|
239
|
+
? { chunkIndex: result.value.chunkIndex }
|
|
240
|
+
: {}),
|
|
241
|
+
...(typeof result.value.sentenceChunk === "string" &&
|
|
242
|
+
result.value.sentenceChunk.length > 0
|
|
243
|
+
? { sentenceChunk: result.value.sentenceChunk }
|
|
244
|
+
: {}),
|
|
245
|
+
};
|
|
246
|
+
result = await stream.next();
|
|
247
|
+
}
|
|
248
|
+
const { modelExecutionMs, stats } = result.value;
|
|
249
|
+
yield attachModelExecutionMs({
|
|
250
|
+
type: "textToSpeechStream",
|
|
251
|
+
buffer: [],
|
|
252
|
+
done: true,
|
|
253
|
+
...(stats && { stats }),
|
|
254
|
+
}, modelExecutionMs);
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
await stream.return?.(undefined);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
}),
|
|
216
261
|
},
|
|
217
262
|
logging: {
|
|
218
263
|
module: ttsAddonLogging,
|
|
@@ -45,6 +45,7 @@ export declare const parakeetPlugin: {
|
|
|
45
45
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
46
46
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
47
47
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
48
|
+
embeddings: "embeddings";
|
|
48
49
|
"llamacpp-completion": "llamacpp-completion";
|
|
49
50
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
50
51
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -55,7 +56,6 @@ export declare const parakeetPlugin: {
|
|
|
55
56
|
"sdcpp-generation": "sdcpp-generation";
|
|
56
57
|
llm: "llm";
|
|
57
58
|
whisper: "whisper";
|
|
58
|
-
embeddings: "embeddings";
|
|
59
59
|
nmt: "nmt";
|
|
60
60
|
parakeet: "parakeet";
|
|
61
61
|
tts: "tts";
|
|
@@ -75,6 +75,7 @@ export declare const parakeetPlugin: {
|
|
|
75
75
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
76
76
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
77
77
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
78
|
+
embeddings: "embeddings";
|
|
78
79
|
"llamacpp-completion": "llamacpp-completion";
|
|
79
80
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
80
81
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -85,7 +86,6 @@ export declare const parakeetPlugin: {
|
|
|
85
86
|
"sdcpp-generation": "sdcpp-generation";
|
|
86
87
|
llm: "llm";
|
|
87
88
|
whisper: "whisper";
|
|
88
|
-
embeddings: "embeddings";
|
|
89
89
|
nmt: "nmt";
|
|
90
90
|
parakeet: "parakeet";
|
|
91
91
|
tts: "tts";
|
|
@@ -105,6 +105,7 @@ export declare const parakeetPlugin: {
|
|
|
105
105
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
106
106
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
107
107
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
108
|
+
embeddings: "embeddings";
|
|
108
109
|
"llamacpp-completion": "llamacpp-completion";
|
|
109
110
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
110
111
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -115,7 +116,6 @@ export declare const parakeetPlugin: {
|
|
|
115
116
|
"sdcpp-generation": "sdcpp-generation";
|
|
116
117
|
llm: "llm";
|
|
117
118
|
whisper: "whisper";
|
|
118
|
-
embeddings: "embeddings";
|
|
119
119
|
nmt: "nmt";
|
|
120
120
|
parakeet: "parakeet";
|
|
121
121
|
tts: "tts";
|
|
@@ -135,6 +135,7 @@ export declare const parakeetPlugin: {
|
|
|
135
135
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
136
136
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
137
137
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
138
|
+
embeddings: "embeddings";
|
|
138
139
|
"llamacpp-completion": "llamacpp-completion";
|
|
139
140
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
140
141
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -145,7 +146,6 @@ export declare const parakeetPlugin: {
|
|
|
145
146
|
"sdcpp-generation": "sdcpp-generation";
|
|
146
147
|
llm: "llm";
|
|
147
148
|
whisper: "whisper";
|
|
148
|
-
embeddings: "embeddings";
|
|
149
149
|
nmt: "nmt";
|
|
150
150
|
parakeet: "parakeet";
|
|
151
151
|
tts: "tts";
|
|
@@ -165,6 +165,7 @@ export declare const parakeetPlugin: {
|
|
|
165
165
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
166
166
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
167
167
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
168
|
+
embeddings: "embeddings";
|
|
168
169
|
"llamacpp-completion": "llamacpp-completion";
|
|
169
170
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
170
171
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -175,7 +176,6 @@ export declare const parakeetPlugin: {
|
|
|
175
176
|
"sdcpp-generation": "sdcpp-generation";
|
|
176
177
|
llm: "llm";
|
|
177
178
|
whisper: "whisper";
|
|
178
|
-
embeddings: "embeddings";
|
|
179
179
|
nmt: "nmt";
|
|
180
180
|
parakeet: "parakeet";
|
|
181
181
|
tts: "tts";
|
|
@@ -195,6 +195,7 @@ export declare const parakeetPlugin: {
|
|
|
195
195
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
196
196
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
197
197
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
198
|
+
embeddings: "embeddings";
|
|
198
199
|
"llamacpp-completion": "llamacpp-completion";
|
|
199
200
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
200
201
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -205,7 +206,6 @@ export declare const parakeetPlugin: {
|
|
|
205
206
|
"sdcpp-generation": "sdcpp-generation";
|
|
206
207
|
llm: "llm";
|
|
207
208
|
whisper: "whisper";
|
|
208
|
-
embeddings: "embeddings";
|
|
209
209
|
nmt: "nmt";
|
|
210
210
|
parakeet: "parakeet";
|
|
211
211
|
tts: "tts";
|
|
@@ -225,6 +225,7 @@ export declare const parakeetPlugin: {
|
|
|
225
225
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
226
226
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
227
227
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
228
|
+
embeddings: "embeddings";
|
|
228
229
|
"llamacpp-completion": "llamacpp-completion";
|
|
229
230
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
230
231
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -235,7 +236,6 @@ export declare const parakeetPlugin: {
|
|
|
235
236
|
"sdcpp-generation": "sdcpp-generation";
|
|
236
237
|
llm: "llm";
|
|
237
238
|
whisper: "whisper";
|
|
238
|
-
embeddings: "embeddings";
|
|
239
239
|
nmt: "nmt";
|
|
240
240
|
parakeet: "parakeet";
|
|
241
241
|
tts: "tts";
|
|
@@ -251,6 +251,7 @@ export declare const parakeetPlugin: {
|
|
|
251
251
|
transcribe: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
252
252
|
modelId: import("zod").ZodString;
|
|
253
253
|
prompt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
254
|
+
metadata: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
254
255
|
audioChunk: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
255
256
|
type: import("zod").ZodLiteral<"base64">;
|
|
256
257
|
value: import("zod").ZodString;
|
|
@@ -275,6 +276,13 @@ export declare const parakeetPlugin: {
|
|
|
275
276
|
melSpecTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
276
277
|
}, import("zod/v4/core").$strip>>;
|
|
277
278
|
error: import("zod").ZodOptional<import("zod").ZodString>;
|
|
279
|
+
segment: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
280
|
+
text: import("zod").ZodString;
|
|
281
|
+
startMs: import("zod").ZodNumber;
|
|
282
|
+
endMs: import("zod").ZodNumber;
|
|
283
|
+
append: import("zod").ZodBoolean;
|
|
284
|
+
id: import("zod").ZodNumber;
|
|
285
|
+
}, import("zod/v4/core").$strip>>;
|
|
278
286
|
type: import("zod").ZodLiteral<"transcribe">;
|
|
279
287
|
}, import("zod/v4/core").$strip>>;
|
|
280
288
|
};
|
|
@@ -2,9 +2,7 @@ import parakeetAddonLogging from "@qvac/transcription-parakeet/addonLogging.js";
|
|
|
2
2
|
import TranscriptionParakeet, {} from "@qvac/transcription-parakeet";
|
|
3
3
|
import { definePlugin, defineHandler, transcribeRequestSchema, transcribeResponseSchema, ModelType, parakeetConfigSchema, ADDON_PARAKEET, } from "../../../../schemas/index.js";
|
|
4
4
|
import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
|
|
5
|
-
import {
|
|
6
|
-
import { ModelLoadFailedError, ParakeetArtifactsRequiredError, } from "../../../../utils/errors-server.js";
|
|
7
|
-
import FilesystemDL from "@qvac/dl-filesystem";
|
|
5
|
+
import { ModelLoadFailedError, ParakeetArtifactsRequiredError, TranscriptionFailedError, } from "../../../../utils/errors-server.js";
|
|
8
6
|
import { transcribe } from "../../ops/transcribe.js";
|
|
9
7
|
import { attachModelExecutionMs } from "../../../../profiling/model-execution.js";
|
|
10
8
|
async function resolveTdtConfig(cfg, ctx) {
|
|
@@ -76,8 +74,6 @@ function createParakeetModel(params, primaryFileKey) {
|
|
|
76
74
|
if (!primaryPath) {
|
|
77
75
|
throw new ModelLoadFailedError(`Parakeet ${modelType} requires a model source`);
|
|
78
76
|
}
|
|
79
|
-
const { dirPath } = parseModelPath(primaryPath);
|
|
80
|
-
const loader = new FilesystemDL({ dirPath });
|
|
81
77
|
const logger = createStreamLogger(params.modelId, ModelType.parakeetTranscription);
|
|
82
78
|
registerAddonLogger(params.modelId, ModelType.parakeetTranscription, logger);
|
|
83
79
|
const files = {
|
|
@@ -101,7 +97,7 @@ function createParakeetModel(params, primaryFileKey) {
|
|
|
101
97
|
config: addonConfig,
|
|
102
98
|
logger,
|
|
103
99
|
});
|
|
104
|
-
return { model
|
|
100
|
+
return { model };
|
|
105
101
|
}
|
|
106
102
|
export const parakeetPlugin = definePlugin({
|
|
107
103
|
modelType: ModelType.parakeetTranscription,
|
|
@@ -131,6 +127,9 @@ export const parakeetPlugin = definePlugin({
|
|
|
131
127
|
responseSchema: transcribeResponseSchema,
|
|
132
128
|
streaming: true,
|
|
133
129
|
handler: async function* (request) {
|
|
130
|
+
if (request.metadata === true) {
|
|
131
|
+
throw new TranscriptionFailedError(`Parakeet transcription does not support metadata: true; only the whisper engine emits per-segment metadata. Use a whisper model to receive segments.`);
|
|
132
|
+
}
|
|
134
133
|
const stream = transcribe({
|
|
135
134
|
modelId: request.modelId,
|
|
136
135
|
audioChunk: request.audioChunk,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { getModel } from "../../../registry/model-registry.js";
|
|
2
2
|
export async function* diffusion(request) {
|
|
3
3
|
const model = getModel(request.modelId);
|
|
4
|
+
const init_image = request.init_image
|
|
5
|
+
? Buffer.from(request.init_image, "base64")
|
|
6
|
+
: undefined;
|
|
4
7
|
const response = await model.run({
|
|
5
8
|
prompt: request.prompt,
|
|
6
9
|
negative_prompt: request.negative_prompt,
|
|
@@ -8,6 +11,7 @@ export async function* diffusion(request) {
|
|
|
8
11
|
height: request.height,
|
|
9
12
|
steps: request.steps,
|
|
10
13
|
cfg_scale: request.cfg_scale,
|
|
14
|
+
img_cfg_scale: request.img_cfg_scale ?? -1,
|
|
11
15
|
guidance: request.guidance,
|
|
12
16
|
sampling_method: request.sampling_method,
|
|
13
17
|
scheduler: request.scheduler,
|
|
@@ -15,6 +19,8 @@ export async function* diffusion(request) {
|
|
|
15
19
|
batch_count: request.batch_count,
|
|
16
20
|
vae_tiling: request.vae_tiling,
|
|
17
21
|
cache_preset: request.cache_preset,
|
|
22
|
+
init_image,
|
|
23
|
+
strength: request.strength,
|
|
18
24
|
});
|
|
19
25
|
let outputIndex = 0;
|
|
20
26
|
for await (const chunk of response.iterate()) {
|