/** * SherpaONNXBridge - V2 canonical ONNX backend bridge. * * STT/TTS/VAD inference flows entirely through the RACommons proto-byte * C ABI (`_rac_stt_component_*_proto`, `_rac_tts_component_*_proto`, * `_rac_vad_component_*_proto`) exported by this bridge's dedicated * `racommons-onnx-sherpa.wasm` artifact. * * Responsibilities: * 1. Always load this package's own `racommons-onnx-sherpa.{js,wasm}` * artifact as an independent Emscripten module. The bridge does not * piggy-back on any other package's WASM module — the ONNX and * Sherpa backend registration entry points * (`_rac_backend_onnx_register` / `_rac_backend_sherpa_register`) are * only exported by this artifact, so each ONNX bridge instance owns * its own dedicated module. * 2. Install the shared browser `PlatformAdapter`, call `rac_init()`, and * claim the speech/embedding/RAG capabilities on the per-capability * registry so the core proto-byte adapters can resolve this module. * 3. Call `_rac_backend_onnx_register()` and * `_rac_backend_sherpa_register()` to register the ONNX runtime and * Sherpa speech vtables with the C++ plugin registry. After this, all * proto-byte STT/TTS/VAD calls in core route through the registered * backend. * * Backend availability requirement: * The `racommons-onnx-sherpa.wasm` artifact MUST be built with ONNX * Runtime WASM and Sherpa-ONNX WASM static archives linked, so * `_rac_backend_onnx_register` and `_rac_backend_sherpa_register` are * exported. Without both, `register()` reports a typed * `BackendNotAvailable` error and STT/TTS/VAD calls stay unavailable. */ export interface SherpaONNXBridgeLoadOptions { /** * Override URL to the `racommons-onnx-sherpa.js` glue file. When omitted, * the bridge resolves it via `import.meta.url` so bundlers (Vite/webpack) * can rewrite the asset path correctly. */ wasmUrl?: string; } /** * Singleton orchestrator for the ONNX backend. The TS surface is a thin * shell — all real STT/TTS/VAD work happens in C++ via the proto-byte * adapters in `@runanywhere/web` core. */ export declare class SherpaONNXBridge { private static _instance; private _module; private _onnxBackendRegistered; private _sherpaBackendRegistered; private _loaded; private _loading; /** * Shared browser adapter retained for the entire lifetime of this WASM * module. RACommons stores its struct pointer during `rac_init`, so the * callback table and allocation must remain alive until after * `_rac_shutdown` completes. */ private _platformAdapter; /** * `true` when this bridge has loaded the dedicated * `racommons-onnx-sherpa` WASM and called `_rac_init` on it (i.e. * `_doLoad` ran to completion). When ownership is held, `unregister()` * mirrors LlamaCppBridge teardown and calls `_rac_shutdown` plus * cleans up the shared platform adapter before dropping the module from the * capability registry. */ private _bridgeOwnedInit; /** Override URL to `racommons-onnx-sherpa.js`. Set before `register()`. */ wasmUrl: string | null; static get shared(): SherpaONNXBridge; get isLoaded(): boolean; get isBackendRegistered(): boolean; /** Acquire/load the commons module and register the ONNX backend vtable. */ ensureLoaded(options?: SherpaONNXBridgeLoadOptions): Promise; /** * Unregister the ONNX/Sherpa backend vtables. Idempotent. * * Mirrors LlamaCppBridge teardown: drops the module from the * capability registry (releasing only the slots it owned — * STT/TTS/VAD/voice-agent), leaving siblings (commons, llamacpp) intact. * If this bridge held the module install, calls `_rac_shutdown` to * unwind C++ state too. */ unregister(): void; /** Release backend registrations, native state, and JS callbacks in order. */ private _teardown; private _doLoad; /** * Build the ordered list of candidate URLs from which to import the * `racommons-onnx-sherpa.js` Emscripten glue. The dedicated ONNX/Sherpa * artifact lives in this package's own `wasm/` folder, so we do not * need to probe sibling-package paths. */ private _collectCommonsModuleCandidates; private _loadCommonsModule; /** Call `rac_init()` with the shared browser platform adapter. */ private _initCommons; private _isRegistrationSuccess; /** * Invoke an exported C function via `ccall`, awaiting a Promise when the * module was built with ASYNCIFY/JSPI. */ private _callMaybeAsync; } //# sourceMappingURL=SherpaONNXBridge.d.ts.map