@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,58 +1,434 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { textToSpeechStreamResponseSchema, ttsClientParamsSchema, } from "../../schemas/index.js";
|
|
2
|
+
import { stream as streamRpc, duplex } from "../rpc/rpc-client.js";
|
|
3
|
+
import { getClientLogger } from "../../logging/index.js";
|
|
4
|
+
import { TextToSpeechStreamFailedError } from "../../utils/errors-client.js";
|
|
5
|
+
const logger = getClientLogger();
|
|
6
|
+
/**
|
|
7
|
+
* Fan-out queue that lets multiple consumers iterate the same TTS response
|
|
8
|
+
* stream independently. Items are retained only until every active subscriber
|
|
9
|
+
* has consumed them, then trimmed from the queue.
|
|
10
|
+
*
|
|
11
|
+
* The source is injected as an `AsyncIterable<TtsResponse>` so this class can
|
|
12
|
+
* be unit-tested directly against the real implementation (without mocking
|
|
13
|
+
* the RPC layer). Production callsites adapt `streamRpc(...)` via
|
|
14
|
+
* `ttsResponseSource()` below.
|
|
15
|
+
*
|
|
16
|
+
* Exported for test use; not part of the public SDK surface.
|
|
17
|
+
*/
|
|
18
|
+
export class TtsMulticast {
|
|
19
|
+
queue = [];
|
|
20
|
+
waiters = [];
|
|
21
|
+
subscriberIndexes = [];
|
|
22
|
+
ended = false;
|
|
23
|
+
fatal;
|
|
24
|
+
resolvePumpDone;
|
|
25
|
+
rejectPumpDone;
|
|
26
|
+
done;
|
|
27
|
+
constructor(source) {
|
|
28
|
+
let resolve;
|
|
29
|
+
let reject;
|
|
30
|
+
this.done = new Promise((r, rj) => {
|
|
31
|
+
resolve = r;
|
|
32
|
+
reject = rj;
|
|
33
|
+
});
|
|
34
|
+
// Silence unhandled-rejection warnings when the caller never awaits
|
|
35
|
+
// `done` (e.g. only iterates the buffer stream). Re-awaits still get the
|
|
36
|
+
// rejection because the underlying promise state is unchanged.
|
|
37
|
+
this.done.catch(() => { });
|
|
38
|
+
this.resolvePumpDone = resolve;
|
|
39
|
+
this.rejectPumpDone = reject;
|
|
40
|
+
void this.pump(source);
|
|
41
|
+
}
|
|
42
|
+
subscribe() {
|
|
43
|
+
const subIdx = this.subscriberIndexes.length;
|
|
44
|
+
this.subscriberIndexes.push(0);
|
|
45
|
+
return this.drain(subIdx);
|
|
46
|
+
}
|
|
47
|
+
notify() {
|
|
48
|
+
for (const fn of this.waiters.splice(0))
|
|
49
|
+
fn();
|
|
50
|
+
}
|
|
51
|
+
trimConsumed() {
|
|
52
|
+
if (this.subscriberIndexes.length === 0)
|
|
53
|
+
return;
|
|
54
|
+
// `Number.POSITIVE_INFINITY` marks an unsubscribed slot; ignore those when
|
|
55
|
+
// computing how far every live subscriber has advanced.
|
|
56
|
+
const minIndex = Math.min(...this.subscriberIndexes);
|
|
57
|
+
if (!Number.isFinite(minIndex))
|
|
58
|
+
return;
|
|
59
|
+
if (minIndex > 0) {
|
|
60
|
+
this.queue.splice(0, minIndex);
|
|
61
|
+
for (let j = 0; j < this.subscriberIndexes.length; j++) {
|
|
62
|
+
const v = this.subscriberIndexes[j] ?? 0;
|
|
63
|
+
if (Number.isFinite(v))
|
|
64
|
+
this.subscriberIndexes[j] = v - minIndex;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
unsubscribe(subIdx) {
|
|
69
|
+
// Park the slot at +Infinity instead of splicing so every other
|
|
70
|
+
// subscriber's `subIdx` stays valid. `trimConsumed` filters these out.
|
|
71
|
+
this.subscriberIndexes[subIdx] = Number.POSITIVE_INFINITY;
|
|
72
|
+
this.trimConsumed();
|
|
73
|
+
}
|
|
74
|
+
async pump(source) {
|
|
75
|
+
try {
|
|
76
|
+
for await (const response of source) {
|
|
77
|
+
// The server owns this response schema; per-frame Zod .parse() adds
|
|
78
|
+
// non-trivial CPU overhead for large sentences with many PCM frames.
|
|
79
|
+
// Rely on the discriminated union narrowing at the RPC boundary and
|
|
80
|
+
// skip re-validation here.
|
|
81
|
+
this.queue.push(response);
|
|
82
|
+
this.notify();
|
|
83
|
+
if (response.done)
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
this.fatal = e instanceof Error ? e : new Error(String(e));
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
this.ended = true;
|
|
92
|
+
this.notify();
|
|
93
|
+
if (this.fatal) {
|
|
94
|
+
// Reject rather than resolving false so callers awaiting `done`
|
|
95
|
+
// with no iteration — and callers iterating drain() — both see the
|
|
96
|
+
// real error instead of a silent sentinel.
|
|
97
|
+
this.rejectPumpDone(this.fatal);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.resolvePumpDone(true);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async *drain(subIdx) {
|
|
105
|
+
// If the consumer breaks out of a `for await` (or calls `.return()` /
|
|
106
|
+
// throws), this generator's finally block runs; release the slot so it
|
|
107
|
+
// no longer pins `trimConsumed`'s min-index and the queue can be GC'd.
|
|
108
|
+
try {
|
|
109
|
+
while (true) {
|
|
110
|
+
while ((this.subscriberIndexes[subIdx] ?? 0) < this.queue.length) {
|
|
111
|
+
const currentIdx = this.subscriberIndexes[subIdx] ?? 0;
|
|
112
|
+
const item = this.queue[currentIdx];
|
|
113
|
+
this.subscriberIndexes[subIdx] = currentIdx + 1;
|
|
114
|
+
this.trimConsumed();
|
|
115
|
+
yield item;
|
|
116
|
+
}
|
|
117
|
+
if (this.fatal)
|
|
118
|
+
throw this.fatal;
|
|
119
|
+
if (this.ended)
|
|
120
|
+
return;
|
|
121
|
+
await new Promise((resolve) => {
|
|
122
|
+
this.waiters.push(resolve);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
this.unsubscribe(subIdx);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function buildTtsRequest(params) {
|
|
132
|
+
return {
|
|
5
133
|
type: "textToSpeech",
|
|
6
134
|
modelId: params.modelId,
|
|
7
135
|
inputType: params.inputType,
|
|
8
136
|
text: params.text,
|
|
9
137
|
stream: params.stream,
|
|
138
|
+
sentenceStream: params.sentenceStream,
|
|
139
|
+
...(params.sentenceStreamLocale !== undefined && {
|
|
140
|
+
sentenceStreamLocale: params.sentenceStreamLocale,
|
|
141
|
+
}),
|
|
142
|
+
...(params.sentenceStreamMaxChunkScalars !== undefined && {
|
|
143
|
+
sentenceStreamMaxChunkScalars: params.sentenceStreamMaxChunkScalars,
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function buildTextToSpeechStreamRequest(params) {
|
|
148
|
+
return {
|
|
149
|
+
type: "textToSpeechStream",
|
|
150
|
+
modelId: params.modelId,
|
|
151
|
+
inputType: params.inputType ?? "text",
|
|
152
|
+
...(params.accumulateSentences !== undefined && {
|
|
153
|
+
accumulateSentences: params.accumulateSentences,
|
|
154
|
+
}),
|
|
155
|
+
...(params.sentenceDelimiterPreset !== undefined && {
|
|
156
|
+
sentenceDelimiterPreset: params.sentenceDelimiterPreset,
|
|
157
|
+
}),
|
|
158
|
+
...(params.maxBufferScalars !== undefined && {
|
|
159
|
+
maxBufferScalars: params.maxBufferScalars,
|
|
160
|
+
}),
|
|
161
|
+
...(params.flushAfterMs !== undefined && {
|
|
162
|
+
flushAfterMs: params.flushAfterMs,
|
|
163
|
+
}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Converts text to speech audio using a loaded TTS model.
|
|
168
|
+
*
|
|
169
|
+
* Three modes selected by `params.stream` and `params.sentenceStream`:
|
|
170
|
+
*
|
|
171
|
+
* - `stream: false` (default) — collect all PCM samples and resolve once via
|
|
172
|
+
* `result.buffer` (`Promise<number[]>`). `bufferStream` is empty.
|
|
173
|
+
* - `stream: true` — yield PCM samples through `result.bufferStream`
|
|
174
|
+
* (`AsyncGenerator<number>`) as they arrive. `buffer` resolves to an empty
|
|
175
|
+
* array.
|
|
176
|
+
* - `stream: true, sentenceStream: true` — also exposes `result.chunkUpdates`
|
|
177
|
+
* (`AsyncGenerator<TtsSentenceChunkUpdate>`) so callers can mux per-sentence
|
|
178
|
+
* metadata with the audio. Multiple consumers can iterate the response
|
|
179
|
+
* independently via the underlying `TtsMulticast`.
|
|
180
|
+
*
|
|
181
|
+
* `result.done` resolves to `true` when synthesis completes cleanly, `false`
|
|
182
|
+
* if the consumer breaks out before the terminal frame, or rejects on a
|
|
183
|
+
* pipeline error. Awaiting `done` is safe even when no stream is iterated.
|
|
184
|
+
*
|
|
185
|
+
* @param params - TTS request parameters (see `TtsClientParamsInput`).
|
|
186
|
+
* @param options - Optional RPC options (timeout, profiling, force new connection).
|
|
187
|
+
* @returns A `TextToSpeechStreamResult` with `bufferStream`, `buffer`, `done`,
|
|
188
|
+
* and (when `sentenceStream: true`) `chunkUpdates`.
|
|
189
|
+
* @throws {TextToSpeechStreamFailedError} When `sentenceStream: true` is paired
|
|
190
|
+
* with `stream: false`, or when the underlying RPC stream errors.
|
|
191
|
+
*/
|
|
192
|
+
export function textToSpeech(params, options) {
|
|
193
|
+
const parsed = ttsClientParamsSchema.parse(params);
|
|
194
|
+
if (parsed.sentenceStream && !parsed.stream) {
|
|
195
|
+
throw new TextToSpeechStreamFailedError("textToSpeech: `sentenceStream: true` requires `stream: true`");
|
|
196
|
+
}
|
|
197
|
+
const request = buildTtsRequest(parsed);
|
|
198
|
+
if (parsed.stream && parsed.sentenceStream) {
|
|
199
|
+
return sentenceStreamTts(request, options);
|
|
200
|
+
}
|
|
201
|
+
if (parsed.stream) {
|
|
202
|
+
return plainStreamTts(request, options);
|
|
203
|
+
}
|
|
204
|
+
return collectTts(request, options);
|
|
205
|
+
}
|
|
206
|
+
// Adapts the raw RPC stream into the filtered `TtsResponse` source the
|
|
207
|
+
// multicast expects. Kept here (not inlined) so the multicast can be
|
|
208
|
+
// constructed in tests with a hand-rolled source instead.
|
|
209
|
+
async function* ttsResponseSource(request, options) {
|
|
210
|
+
for await (const response of streamRpc(request, options)) {
|
|
211
|
+
if (response.type !== "textToSpeech")
|
|
212
|
+
continue;
|
|
213
|
+
yield response;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function sentenceStreamTts(request, options) {
|
|
217
|
+
const multicast = new TtsMulticast(ttsResponseSource(request, options));
|
|
218
|
+
// Subscribe eagerly, synchronously — before pump() can push its first
|
|
219
|
+
// item — so both subscribers see the full queue from index 0. If we
|
|
220
|
+
// deferred subscribing until the generators were iterated, the first
|
|
221
|
+
// consumer could trim the queue before the second ever registered,
|
|
222
|
+
// silently dropping earlier frames.
|
|
223
|
+
const bufferSubscription = multicast.subscribe();
|
|
224
|
+
const chunkSubscription = multicast.subscribe();
|
|
225
|
+
return {
|
|
226
|
+
bufferStream: sentenceBufferStream(bufferSubscription),
|
|
227
|
+
chunkUpdates: sentenceChunkUpdates(chunkSubscription),
|
|
228
|
+
buffer: Promise.resolve([]),
|
|
229
|
+
done: multicast.done,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async function* sentenceBufferStream(source) {
|
|
233
|
+
for await (const m of source) {
|
|
234
|
+
if (m.buffer.length > 0) {
|
|
235
|
+
yield* m.buffer;
|
|
236
|
+
}
|
|
237
|
+
if (m.done)
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async function* sentenceChunkUpdates(source) {
|
|
242
|
+
for await (const m of source) {
|
|
243
|
+
const hasAudio = m.buffer.length > 0;
|
|
244
|
+
const hasMeta = m.chunkIndex !== undefined ||
|
|
245
|
+
(typeof m.sentenceChunk === "string" && m.sentenceChunk.length > 0);
|
|
246
|
+
if (hasAudio || hasMeta) {
|
|
247
|
+
yield {
|
|
248
|
+
buffer: hasAudio ? [...m.buffer] : [],
|
|
249
|
+
...(m.chunkIndex !== undefined ? { chunkIndex: m.chunkIndex } : {}),
|
|
250
|
+
...(typeof m.sentenceChunk === "string" && m.sentenceChunk.length > 0
|
|
251
|
+
? { sentenceChunk: m.sentenceChunk }
|
|
252
|
+
: {}),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
if (m.done)
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function plainStreamTts(request, options) {
|
|
260
|
+
let resolveDone;
|
|
261
|
+
let rejectDone;
|
|
262
|
+
const done = new Promise((resolve, reject) => {
|
|
263
|
+
resolveDone = resolve;
|
|
264
|
+
rejectDone = reject;
|
|
265
|
+
});
|
|
266
|
+
done.catch(() => { });
|
|
267
|
+
return {
|
|
268
|
+
bufferStream: plainTtsBufferStream(request, options, resolveDone, rejectDone),
|
|
269
|
+
buffer: Promise.resolve([]),
|
|
270
|
+
done,
|
|
10
271
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
272
|
+
}
|
|
273
|
+
async function* plainTtsBufferStream(request, options, resolveDone, rejectDone) {
|
|
274
|
+
let settled = false;
|
|
275
|
+
try {
|
|
276
|
+
for await (const response of streamRpc(request, options)) {
|
|
277
|
+
if (response.type !== "textToSpeech")
|
|
278
|
+
continue;
|
|
279
|
+
// See TtsMulticast.pump — skip per-frame Zod validation; the server is
|
|
280
|
+
// the source of truth for this wire shape.
|
|
281
|
+
if (response.buffer.length > 0) {
|
|
282
|
+
yield* response.buffer;
|
|
283
|
+
}
|
|
284
|
+
if (response.done) {
|
|
285
|
+
settled = true;
|
|
286
|
+
resolveDone(true);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch (e) {
|
|
291
|
+
if (!settled) {
|
|
292
|
+
settled = true;
|
|
293
|
+
rejectDone(e);
|
|
294
|
+
}
|
|
295
|
+
throw e;
|
|
296
|
+
}
|
|
297
|
+
finally {
|
|
298
|
+
// Consumer broke out of the for-await before `done` arrived; resolve
|
|
299
|
+
// with `false` so `await result.done` never hangs.
|
|
300
|
+
if (!settled)
|
|
301
|
+
resolveDone(false);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function collectTts(request, options) {
|
|
305
|
+
let resolveDone;
|
|
306
|
+
let rejectDone;
|
|
307
|
+
const done = new Promise((resolve, reject) => {
|
|
308
|
+
resolveDone = resolve;
|
|
309
|
+
rejectDone = reject;
|
|
14
310
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
311
|
+
done.catch(() => { });
|
|
312
|
+
return {
|
|
313
|
+
bufferStream: emptyBufferStream(),
|
|
314
|
+
buffer: collectTtsBuffer(request, options, resolveDone, rejectDone),
|
|
315
|
+
done,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
async function* emptyBufferStream() {
|
|
319
|
+
// Non-streaming mode exposes no incremental buffer stream.
|
|
320
|
+
}
|
|
321
|
+
async function collectTtsBuffer(request, options, resolveDone, rejectDone) {
|
|
322
|
+
let buffer = [];
|
|
323
|
+
try {
|
|
324
|
+
for await (const response of streamRpc(request, options)) {
|
|
325
|
+
if (response.type !== "textToSpeech")
|
|
326
|
+
continue;
|
|
327
|
+
buffer = buffer.concat(response.buffer);
|
|
328
|
+
if (response.done) {
|
|
329
|
+
resolveDone(true);
|
|
27
330
|
}
|
|
28
|
-
}
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
331
|
+
}
|
|
332
|
+
return buffer;
|
|
333
|
+
}
|
|
334
|
+
catch (e) {
|
|
335
|
+
rejectDone(e);
|
|
336
|
+
throw e;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Duplex session: write UTF-8 text fragments (e.g. LLM token deltas) via `write`. Each string or
|
|
341
|
+
* Buffer should be a complete UTF-8 fragment. The worker forwards them to ONNX TTS `runStreaming`
|
|
342
|
+
* (optional sentence accumulation via request fields). Iterate the session for `TextToSpeechStreamResponse`
|
|
343
|
+
* lines (PCM in `buffer`, optional `chunkIndex` / `sentenceChunk`) until `done`.
|
|
344
|
+
*/
|
|
345
|
+
export async function textToSpeechStream(params, options) {
|
|
346
|
+
const request = buildTextToSpeechStreamRequest(params);
|
|
347
|
+
const { requestStream, responseStream } = await duplex(request, options);
|
|
348
|
+
const responses = parseTextToSpeechStreamLines(responseStream);
|
|
349
|
+
let consumed = false;
|
|
350
|
+
// `closed` flips on `end()` or `destroy()`. Without this guard a late
|
|
351
|
+
// `write()` would propagate a raw Bare/Node "write after end" stream error
|
|
352
|
+
// to the caller. Throwing a typed SDK error keeps the duplex session
|
|
353
|
+
// surface predictable.
|
|
354
|
+
let closed = false;
|
|
355
|
+
return {
|
|
356
|
+
write(textFragment) {
|
|
357
|
+
if (closed) {
|
|
358
|
+
throw new TextToSpeechStreamFailedError("TextToSpeechStreamSession.write() called after end()/destroy()");
|
|
359
|
+
}
|
|
360
|
+
const buf = typeof textFragment === "string"
|
|
361
|
+
? Buffer.from(textFragment, "utf8")
|
|
362
|
+
: textFragment;
|
|
363
|
+
requestStream.write(buf);
|
|
364
|
+
},
|
|
365
|
+
end() {
|
|
366
|
+
if (closed)
|
|
367
|
+
return;
|
|
368
|
+
closed = true;
|
|
369
|
+
requestStream.end();
|
|
370
|
+
},
|
|
371
|
+
destroy() {
|
|
372
|
+
closed = true;
|
|
373
|
+
requestStream.destroy();
|
|
374
|
+
responseStream.destroy();
|
|
375
|
+
},
|
|
376
|
+
[Symbol.asyncIterator]() {
|
|
377
|
+
if (consumed) {
|
|
378
|
+
// Return an iterator whose first .next() rejects asynchronously so
|
|
379
|
+
// `for await` surfaces the error in the normal async-iteration
|
|
380
|
+
// control flow instead of a synchronous throw from the iterator
|
|
381
|
+
// protocol (which callers commonly forget to wrap in try/catch).
|
|
382
|
+
return {
|
|
383
|
+
next() {
|
|
384
|
+
return Promise.reject(new TextToSpeechStreamFailedError("TextToSpeechStreamSession can only be iterated once"));
|
|
385
|
+
},
|
|
386
|
+
};
|
|
49
387
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
388
|
+
consumed = true;
|
|
389
|
+
return responses;
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
async function* parseTextToSpeechStreamLines(responseStream) {
|
|
394
|
+
let buf = "";
|
|
395
|
+
for await (const chunk of responseStream) {
|
|
396
|
+
buf += chunk.toString();
|
|
397
|
+
const lines = buf.split("\n");
|
|
398
|
+
buf = lines.pop() || "";
|
|
399
|
+
for (const line of lines) {
|
|
400
|
+
const yielded = processTextToSpeechStreamLine(line);
|
|
401
|
+
if (yielded === undefined)
|
|
402
|
+
continue;
|
|
403
|
+
yield yielded;
|
|
404
|
+
// Close the stream after the terminal frame so consumers don't
|
|
405
|
+
// depend on the server closing the socket to stop iteration.
|
|
406
|
+
if (yielded.done)
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (buf.trim()) {
|
|
411
|
+
const yielded = processTextToSpeechStreamLine(buf);
|
|
412
|
+
if (yielded !== undefined) {
|
|
413
|
+
yield yielded;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function processTextToSpeechStreamLine(line) {
|
|
418
|
+
if (!line.trim()) {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
let parsed;
|
|
422
|
+
try {
|
|
423
|
+
parsed = JSON.parse(line);
|
|
424
|
+
}
|
|
425
|
+
catch {
|
|
426
|
+
logger.warn("textToSpeechStream: malformed JSON from server:", line);
|
|
427
|
+
return undefined;
|
|
428
|
+
}
|
|
429
|
+
const obj = parsed;
|
|
430
|
+
if (obj["type"] === "error") {
|
|
431
|
+
throw new TextToSpeechStreamFailedError(obj["message"] ?? "Unknown server error");
|
|
57
432
|
}
|
|
433
|
+
return textToSpeechStreamResponseSchema.parse(parsed);
|
|
58
434
|
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { type TranscribeClientParams, type RPCOptions, type TranscribeStreamClientParams, type TranscribeStreamSession } from "../../schemas/index";
|
|
1
|
+
import { type TranscribeClientParams, type RPCOptions, type TranscribeSegment, type TranscribeStreamClientParams, type TranscribeStreamSession, type TranscribeStreamMetadataSession } from "../../schemas/index";
|
|
2
2
|
/**
|
|
3
3
|
* Transcribe audio and return the complete text. Accepts either a file
|
|
4
4
|
* path or an audio buffer.
|
|
5
5
|
*
|
|
6
|
+
* @param params - Transcription parameters.
|
|
6
7
|
* @param params.modelId - The identifier of the transcription model to use
|
|
7
8
|
* @param params.audioChunk - Audio input as either a file path (string) or audio buffer
|
|
8
9
|
* @param params.prompt - Optional initial prompt to guide the transcription
|
|
10
|
+
* @param params.metadata - When true, resolves to an array of transcript
|
|
11
|
+
* segments (`{ text, startMs, endMs, append, id }`)
|
|
12
|
+
* instead of joined text. Whisper engine only.
|
|
9
13
|
* @param options - Optional RPC options including per-call profiling
|
|
10
|
-
* @returns The complete transcribed text
|
|
14
|
+
* @returns The complete transcribed text, or — when `metadata` is true —
|
|
15
|
+
* the list of transcript segments in emission order.
|
|
11
16
|
*/
|
|
17
|
+
export declare function transcribe(params: TranscribeClientParams & {
|
|
18
|
+
metadata: true;
|
|
19
|
+
}, options?: RPCOptions): Promise<TranscribeSegment[]>;
|
|
12
20
|
export declare function transcribe(params: TranscribeClientParams, options?: RPCOptions): Promise<string>;
|
|
13
21
|
/**
|
|
14
22
|
* @deprecated Pass audio via `transcribe()` instead. This overload will be
|
|
@@ -16,7 +24,15 @@ export declare function transcribe(params: TranscribeClientParams, options?: RPC
|
|
|
16
24
|
*
|
|
17
25
|
* Streaming transcription with upfront audio: sends full audio, yields text
|
|
18
26
|
* chunks as they arrive.
|
|
27
|
+
*
|
|
28
|
+
* @overloadLabel "Upfront audio (deprecated)"
|
|
29
|
+
* @param params - Transcription parameters including audio source.
|
|
30
|
+
* @param options - Optional RPC options including per-call profiling.
|
|
31
|
+
* @returns An async generator yielding text chunks as they become available.
|
|
19
32
|
*/
|
|
33
|
+
export declare function transcribeStream(params: TranscribeClientParams & {
|
|
34
|
+
metadata: true;
|
|
35
|
+
}, options?: RPCOptions): AsyncGenerator<TranscribeSegment>;
|
|
20
36
|
export declare function transcribeStream(params: TranscribeClientParams, options?: RPCOptions): AsyncGenerator<string>;
|
|
21
37
|
/**
|
|
22
38
|
* Opens a bidirectional streaming transcription session. Audio is streamed
|
|
@@ -26,11 +42,20 @@ export declare function transcribeStream(params: TranscribeClientParams, options
|
|
|
26
42
|
* The returned session is single-use. Attempting to iterate a second
|
|
27
43
|
* time will throw a `TranscriptionFailedError`.
|
|
28
44
|
*
|
|
45
|
+
* @overloadLabel "Bidirectional session"
|
|
46
|
+
* @param params - Streaming transcription parameters.
|
|
29
47
|
* @param params.modelId - The loaded transcription model to use
|
|
30
48
|
* @param params.prompt - Optional initial prompt to guide transcription
|
|
49
|
+
* @param params.metadata - When true, the session yields transcript segment
|
|
50
|
+
* objects (`{ text, startMs, endMs, append, id }`)
|
|
51
|
+
* instead of plain text. Whisper engine only.
|
|
52
|
+
* @param options - Optional RPC options including per-call profiling.
|
|
31
53
|
* @returns A session object: call `write(buffer)` to feed audio,
|
|
32
|
-
* iterate with `for await (
|
|
33
|
-
*
|
|
54
|
+
* iterate with `for await (...)` to receive transcription,
|
|
55
|
+
* and `end()` to signal end of audio.
|
|
34
56
|
*/
|
|
57
|
+
export declare function transcribeStream(params: TranscribeStreamClientParams & {
|
|
58
|
+
metadata: true;
|
|
59
|
+
}, options?: RPCOptions): Promise<TranscribeStreamMetadataSession>;
|
|
35
60
|
export declare function transcribeStream(params: TranscribeStreamClientParams, options?: RPCOptions): Promise<TranscribeStreamSession>;
|
|
36
61
|
//# sourceMappingURL=transcribe.d.ts.map
|