{"_id":"@agentfiber/asr","name":"@agentfiber/asr","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@agentfiber/asr","version":"0.1.0","description":"Provider-neutral audio capture and speech transcription contracts for AgentFiber.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/tereby/agentic-tv-ui.git","directory":"packages/agentfiber-asr"},"homepage":"https://agentfiber.org","bugs":{"url":"https://github.com/tereby/agentic-tv-ui/issues"},"type":"module","sideEffects":false,"publishConfig":{"access":"public"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./browser":{"types":"./dist/browser.d.ts","import":"./dist/browser.js","default":"./dist/browser.js"},"./http":{"types":"./dist/http.d.ts","import":"./dist/http.js","default":"./dist/http.js"},"./web-speech":{"types":"./dist/web-speech.d.ts","import":"./dist/web-speech.js","default":"./dist/web-speech.js"}},"scripts":{"build":"tsc -p tsconfig.build.json","prepare":"pnpm build","prepack":"pnpm build","smoke:pack":"node ../../scripts/smoke-agentfiber-asr-pack.mjs","typecheck":"tsc --noEmit","test":"vitest run"},"engines":{"node":">=20.0.0"},"devDependencies":{"typescript":"5.6.3","vitest":"2.1.5"},"gitHead":"4728e79c917eb45f55540b7376e626d5e5e0b469","_id":"@agentfiber/asr@0.1.0","_nodeVersion":"22.18.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-aReTWnBNzbqOP/TrlRCdQnHeXErgNjnRaYpwA8bocqej6X5dlLaNmHs7NmyvWCRA2HqICKd0dl7aec+C1GTTaA==","shasum":"dbe8a27f1deb57614fd4172d8f64eda5a89fda48","tarball":"https://registry.npmjs.org/@agentfiber/asr/-/asr-0.1.0.tgz","fileCount":13,"unpackedSize":39643,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICupxKRhr2t+uzI+2QxjwG403pZ2OMfoUOsA1u9XLQJkAiEAyZOvkL+L5N43mw8I9XX89FpUhsk/FaAj9I07VSd9Qfo="}]},"_npmUser":{"name":"tereby","email":"a@appg.dev"},"directories":{},"maintainers":[{"name":"tereby","email":"a@appg.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/asr_0.1.0_1787831675546_0.9017637608625588"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-27T11:54:35.377Z","0.1.0":"2026-08-27T11:54:35.711Z","modified":"2026-08-27T11:54:35.955Z"},"maintainers":[{"name":"tereby","email":"a@appg.dev"}],"description":"Provider-neutral audio capture and speech transcription contracts for AgentFiber.","homepage":"https://agentfiber.org","repository":{"type":"git","url":"git+https://github.com/tereby/agentic-tv-ui.git","directory":"packages/agentfiber-asr"},"bugs":{"url":"https://github.com/tereby/agentic-tv-ui/issues"},"license":"MIT","readme":"# `@agentfiber/asr`\n\nProvider-neutral audio capture and speech transcription contracts for AgentFiber.\n\nThis package turns an explicit capture or transcription request into audio or transcript data.\nIt does not match intents, grant authority, or execute product actions. Products pass final\ntranscripts to their grammar and retain policy and execution authority.\n\n## Install\n\n```sh\nnpm install @agentfiber/asr\n```\n\nThe initial `0.1.x` package has no runtime dependencies and four explicit surfaces:\n\n- `@agentfiber/asr`: environment-neutral contracts and result/error helpers;\n- `@agentfiber/asr/browser`: browser PCM capture and WAV helpers;\n- `@agentfiber/asr/http`: configurable HTTP and OpenAI-compatible Whisper clients; and\n- `@agentfiber/asr/web-speech`: optional live Web Speech API adapter.\n\nImporting the root package does not read `window`, `navigator`, audio, speech, or network globals.\n\n## Browser PCM capture\n\n```ts\nimport { startBrowserAudioCapture } from \"@agentfiber/asr/browser\";\n\nconst capture = await startBrowserAudioCapture(\n  (peak) => updateMeter(peak),\n  { targetSampleRate: 16_000, maxDurationMs: 10_000 },\n);\n\nconst wav = await capture.stop();\n```\n\nCapture uses AudioWorklet when available and a ScriptProcessor compatibility fallback otherwise.\nIt records mono PCM at the AudioContext's native rate, resamples once on release, and returns a\nself-describing 16-bit PCM WAV. `cancel()` tears down without encoding.\n\nBrowser globals are touched only when capture starts. Microphone access still requires a secure\ncontext and product-owned permission UX.\n\n## Configurable HTTP transcription\n\n```ts\nimport { createHttpAsrTranscriber } from \"@agentfiber/asr/http\";\n\nconst transcriber = createHttpAsrTranscriber({\n  endpoint: \"/api/asr/transcribe\",\n  fetch,\n  timeoutMs: 15_000,\n});\n```\n\nThe default HTTP format posts the audio bytes with their content type and parses `{text}`. Supply\n`encodeRequest` and `parseResponse` for any other endpoint. Endpoint, headers, authentication,\nlocale, timeout, and fetch implementation are caller-owned.\n\nFor a compatible Whisper endpoint:\n\n```ts\nimport { createOpenAiCompatibleWhisperTranscriber } from \"@agentfiber/asr/http\";\n\nconst transcriber = createOpenAiCompatibleWhisperTranscriber({\n  endpoint: \"https://speech.example.test/v1/audio/transcriptions\",\n  fetch,\n  model: \"whisper-large-v3-turbo\",\n  headers: () => ({ Authorization: `Bearer ${readShortLivedCredential()}` }),\n});\n```\n\nThis helper uses the common multipart `file`, `model`, optional `language`, and `{text}` contract.\nIt does not require or imply one provider. Never expose a server secret to a browser bundle.\n\n## Browser or local recognition\n\n```ts\nimport { createWebSpeechTranscriptSource } from \"@agentfiber/asr/web-speech\";\n\nconst source = createWebSpeechTranscriptSource({ interimResults: true });\nconst result = await source.start({\n  locale: \"en-GB\",\n  signal: controller.signal,\n  onInterim: ({ text }) => showInterimText(text),\n});\n```\n\nOnly `completed` results are final. Interim text is observational and must not execute an action.\nWeb Speech availability, provider, network use, and privacy vary by browser; the adapter makes no\non-device or confidentiality claim. A local WASM, WebGPU, worker, or native implementation can\nsatisfy the root `AsrTranscriber` or `AsrTranscriptSource` contract without changing callers.\n\n## Lifecycle and privacy\n\n- Every request carries an `AbortSignal`.\n- Transcribers and transcript sources expose active/disposed lifecycle.\n- Results are `completed`, `rejected`, or `cancelled`.\n- Empty audio, empty transcripts, timeouts, provider errors, malformed responses, and disposal\n  are explicit.\n- The package performs no telemetry and retains no audio, transcript, or voiceprint itself.\n\nProducts own consent, visible listening state, retention/deletion policy, rate limiting,\nauthentication, grammar, authority, and execution.\n\nFor observational orb or level UI, use [`@agentfiber/voice-ui`](../agentfiber-voice-ui/README.md).\nFor normalization, intent proposals, and dispatch contracts, use\n[`@agentfiber/voice`](../agentfiber-voice/README.md).\n\nSee [ADR 0023](../../docs/adr/0023-agentfiber-asr-boundary.md) for the complete boundary. Packed\nartifact validation and clean consumers are release evidence only; they do not prove publication,\nASR accuracy, privacy compliance, physical-device behavior, latency, memory, or performance.\n","readmeFilename":"README.md","_rev":"1-759f6b51283773facfac7eeeb9e3d63a"}