--- title: "Stream ASR — Complete Technical Reference & Knowledge Base" description: "Full-context developer documentation, architecture specification, and TypeScript SDK manual for Stream ASR — 100% on-device WebAssembly streaming speech recognition." url: "https://asr.firetable.tech/llms-full.txt" author: "FireTable" license: "Apache-2.0" --- # Stream ASR — Complete Technical Reference & Knowledge Base > Ultra-fast, browser-native WebAssembly streaming speech recognition runtime powered by MNN & SIMD128. Zero cloud dependencies, zero audio uploaded to any server, fully offline-ready. ## 1. System Architecture & Technical Principles Stream ASR operates entirely on the client side inside modern web browsers. It eliminates the standard client-server streaming speech recognition topology (such as gRPC/WebSocket audio streaming) and replaces it with an in-browser neural execution pipeline. ### 1.1 Audio Ingestion & Worklet Pipeline - **Sample Rate**: 16,000 Hz, single-channel (Mono), 32-bit floating point PCM (`Float32Array`). - **Processing Unit**: Runs on a dedicated Web Audio `AudioWorkletNode` isolated from the browser's DOM / UI thread. - **Chunk Size**: 160ms audio windows (2,560 samples per chunk). - **Feature Extraction**: 80-dimensional Log-Mel Filterbank computed directly in WebAssembly or fast JavaScript SIMD routines. ### 1.2 Multi-Threaded Worker Topology To avoid dropped audio frames and UI frame rate stuttering: - **Main Thread**: Manages UI state, microphone permissions, audio visualization (e.g. WebGL canvas or Hero Orb), and user interaction. - **Worker Thread**: Hosts the compiled WebAssembly binary and neural network weights. Incoming audio chunks are transferred via `postMessage` (`TransferableArrayBuffer`) to eliminate memory copy overhead. ### 1.3 WebAssembly & SIMD128 Neural Runtime - **Inference Engine**: Mobile Neural Network (MNN) compiled to WebAssembly via Emscripten. - **Vector Acceleration**: WebAssembly SIMD128 (Single Instruction, Multiple Data) instructions accelerate matrix multiplication, convolution, and layer normalization operations. - **Quantization**: INT8 / FP16 quantized model weights reducing the binary footprint to ~175MB without compromising Chinese/English recognition accuracy. - **Streaming State Management**: Causal convolution caches and chunked self-attention key/value states are maintained across audio chunks, ensuring sub-50ms inference time per chunk. ### 1.4 Cache & Offline Storage Strategy - **Initial Download**: When requested for the first time, model weights (~175MB) and WASM binaries (~2.4MB) are streamed via `ReadableStream` with real-time download percentage calculation. - **CacheStorage Persistence**: Resources are saved directly into the browser's persistent `CacheStorage` (`stream-asr-v1`). - **Subsequent Cold Boots**: Zero network requests. Weights and binaries are loaded directly from local browser storage within ~800ms, enabling full offline functionality on airplanes, subways, and secure intranets. --- ## 2. TypeScript SDK Manual (`@firetable/stream-asr`) ### 2.1 Installation ```bash # npm npm install @firetable/stream-asr # pnpm pnpm add @firetable/stream-asr # yarn yarn add @firetable/stream-asr ``` ### 2.2 Core API: `StreamRecognizer` ```typescript import { StreamRecognizer } from '@firetable/stream-asr'; // 1. Instantiate the recognizer const recognizer = new StreamRecognizer({ modelPath: '/model.bin', // Path or URL to model binary weights wasmPath: '/wasm/engine.wasm', // Optional path to custom WASM binary sampleRate: 16000, // Default: 16000 chunkSize: 2560, // 160ms at 16kHz }); // 2. Listen to download & initialization events recognizer.on('download_progress', ({ loaded, total, percent }) => { console.log(`Downloading model weights: ${percent}% (${loaded} / ${total} bytes)`); }); recognizer.on('ready', () => { console.log('Stream ASR engine successfully initialized and ready'); }); // 3. Listen to recognition results recognizer.on('result', ({ text, isFinal, timestamp }) => { console.log(`[ASR Result] ${text} (Final: ${isFinal})`); }); recognizer.on('error', (err) => { console.error('ASR Engine Error:', err); }); // 4. Initialize engine (loads from cache or downloads) await recognizer.init(); // 5. Feed audio data continuously // pcmData: Float32Array containing 16kHz mono audio samples recognizer.feed(pcmData); // 6. Signal end of speech session to flush pending decoding states recognizer.flush(); // 7. Cleanup resources recognizer.destroy(); ``` ### 2.3 Event Signatures | Event Name | Payload | Description | | :--- | :--- | :--- | | `download_progress` | `{ loaded: number, total: number, percent: number }` | Emitted during first-time download stream | | `ready` | `void` | Emitted when WASM compiled and tensor graph allocated | | `result` | `{ text: string, isFinal: boolean, timestamp: number }` | Real-time transcription output | | `error` | `{ code: string, message: string }` | Runtime or initialization errors | --- ## 3. Performance Benchmarks All benchmarks measured with 16kHz Chinese & English conversational speech datasets: | Hardware Environment | Real-Time Factor (RTF) | Chunk Latency (160ms chunk) | Peak RAM Usage | | :--- | :--- | :--- | :--- | | **Apple M1 / M2 / M3 / M4 (Chrome)** | **0.08x ~ 0.14x** | **18ms ~ 28ms** | **~220 MB** | | **Intel Core i7-12700H (Edge)** | **0.22x ~ 0.28x** | **35ms ~ 45ms** | **~240 MB** | | **AMD Ryzen 7 7840U (Chrome)** | **0.18x ~ 0.24x** | **29ms ~ 38ms** | **~230 MB** | | **iPhone 14 / 15 / 16 (Safari iOS)** | **0.25x ~ 0.35x** | **40ms ~ 56ms** | **~210 MB** | | **Qualcomm Snapdragon 8 Gen 2 / 3 (Android)** | **0.28x ~ 0.38x** | **45ms ~ 60ms** | **~245 MB** | *Note: RTF (Real-Time Factor) < 1.0 means faster than real-time. An RTF of 0.12x indicates 1.0 second of speech is processed in only 0.12 seconds.* --- ## 4. Security & Privacy Guarantees - **No Remote Audio Transmission**: Zero audio packets are dispatched to external servers, cloud providers, or third-party analytics. - **Zero Retention**: Audio buffers are processed in memory and released immediately after tensor extraction. - **Enterprise Intranet Compliance**: Operates in air-gapped, zero-trust, and highly regulated environments where sending voice data across network boundaries is prohibited by law or policy. --- ## 5. Frequently Asked Questions (FAQ) ### Q: Why does the model need ~175MB of storage? A: Stream ASR contains a full state-of-the-art streaming acoustic model and language model capable of high-accuracy multi-lingual recognition. This 175MB is downloaded once and cached permanently via the browser's `CacheStorage`. ### Q: Can it run when disconnected from the Internet? A: Yes. Once downloaded on the first visit, the engine and model weights load entirely from local disk cache, requiring zero internet connectivity. ### Q: Does it support iOS Safari? A: Yes, Safari 16.4 and newer on iOS and iPadOS support the required WebAssembly SIMD128 extensions and AudioWorklet specifications. --- ## 6. Official Resources - Homepage: https://asr.firetable.tech - GitHub: https://github.com/firetable/stream-asr - Agent Manifest: https://asr.firetable.tech/llms.txt - Agent Policy: https://asr.firetable.tech/auth.md - Sitemap: https://asr.firetable.tech/sitemap.xml