{"id":46729770,"url":"https://github.com/analyticsinmotion/micstream","last_synced_at":"2026-03-09T15:00:15.921Z","repository":{"id":343044354,"uuid":"1176062475","full_name":"analyticsinmotion/micstream","owner":"analyticsinmotion","description":" Cross-platform microphone audio capture for Node.js with pre-built binaries. No build tools required.","archived":false,"fork":false,"pushed_at":"2026-03-08T16:27:32.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-08T19:30:35.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/analyticsinmotion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-08T15:11:03.000Z","updated_at":"2026-03-08T16:20:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/analyticsinmotion/micstream","commit_stats":null,"previous_names":["analyticsinmotion/micstream"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/analyticsinmotion/micstream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticsinmotion%2Fmicstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticsinmotion%2Fmicstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticsinmotion%2Fmicstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticsinmotion%2Fmicstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/analyticsinmotion","download_url":"https://codeload.github.com/analyticsinmotion/micstream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analyticsinmotion%2Fmicstream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30299835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T14:33:48.460Z","status":"ssl_error","status_checked_at":"2026-03-09T14:33:48.027Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-09T15:00:14.616Z","updated_at":"2026-03-09T15:00:15.888Z","avatar_url":"https://github.com/analyticsinmotion.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"256\" height=\"138\" alt=\"micstream-github-logo-rectangle\" src=\"https://github.com/user-attachments/assets/0850e868-d79d-4787-911d-8126a012869c\" /\u003e\n\n# micstream\n\n  Cross-platform microphone audio capture for Node.js.\n\n  Pre-built binaries for Windows, macOS, and Linux. No build tools, no SoX, no system dependencies required.\n\n  \u003c!-- badges: start --\u003e\n  \u003ctable\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003cstrong\u003eMeta\u003c/strong\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003ca href=\"https://www.npmjs.com/package/@analyticsinmotion/micstream\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@analyticsinmotion/micstream\" alt=\"npm version\"\u003e\u003c/a\u003e\u0026nbsp;\n        \u003ca href=\"https://github.com/analyticsinmotion/micstream/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-Apache_2.0-blue.svg\" alt=\"Apache 2.0 License\"\u003e\u003c/a\u003e\u0026nbsp;\n        \u003ca href=\"https://github.com/analyticsinmotion\"\u003e\u003cimg src=\"https://github.com/user-attachments/assets/616c530f-cf2a-4f26-8f6c-7397be513847\" alt=\"Analytics in Motion\" width=\"137\" height=\"20\"\u003e\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003cstrong\u003eBinaries\u003c/strong\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003ca href=\"https://github.com/analyticsinmotion/micstream/actions/workflows/prebuild.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/analyticsinmotion/micstream/prebuild.yml?job=Windows%20x64\u0026label=Windows%20x64\u0026logo=microsoft\u0026logoColor=white\" alt=\"Windows x64\"\u003e\u003c/a\u003e\u0026nbsp;\n        \u003ca href=\"https://github.com/analyticsinmotion/micstream/actions/workflows/prebuild.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/analyticsinmotion/micstream/prebuild.yml?job=macOS%20ARM64\u0026label=macOS%20ARM64\u0026logo=apple\" alt=\"macOS ARM64\"\u003e\u003c/a\u003e\u0026nbsp;\n        \u003ca href=\"https://github.com/analyticsinmotion/micstream/actions/workflows/prebuild.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/analyticsinmotion/micstream/prebuild.yml?job=Linux%20x64\u0026label=Linux%20x64\u0026logo=linux\u0026logoColor=white\" alt=\"Linux x64\"\u003e\u003c/a\u003e\u0026nbsp;\n        \u003ca href=\"https://github.com/analyticsinmotion/micstream/actions/workflows/prebuild.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/analyticsinmotion/micstream/prebuild.yml?job=Linux%20ARM64\u0026label=Linux%20ARM64\u0026logo=linux\u0026logoColor=white\" alt=\"Linux ARM64\"\u003e\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/table\u003e\n  \u003c!-- badges: end --\u003e\n\u003c/div\u003e\n\n---\n\n## Installation\n\n```bash\nnpm install @analyticsinmotion/micstream\n```\n\nAt install time `prebuild-install` downloads the correct pre-compiled binary for your platform. If no binary is available, it falls back to compiling from source (requires build tools and `libasound2-dev` on Linux).\n\n---\n\n## Usage\n\n### Stream PCM audio from the default microphone\n\n```javascript\nconst MicStream = require('@analyticsinmotion/micstream');\n\nconst mic = new MicStream();\n\nmic.on('data', (chunk) =\u003e {\n  // chunk is a Buffer of 16-bit signed integer PCM samples (little-endian)\n  // default: 16kHz, mono, 1600 frames per chunk (100ms)\n});\n\nmic.on('error', (err) =\u003e {\n  console.error('Microphone error:', err);\n});\n\n// Stop after 10 seconds\nsetTimeout(() =\u003e mic.stop(), 10000);\n```\n\n### Pipe to a file\n\n```javascript\nconst fs = require('fs');\nconst MicStream = require('@analyticsinmotion/micstream');\n\nconst mic = new MicStream({ sampleRate: 44100, channels: 2 });\nconst out = fs.createWriteStream('capture.raw');\n\nmic.pipe(out);\n\nsetTimeout(() =\u003e mic.stop(), 5000);\n```\n\n### Pipe to a speech engine\n\n```javascript\nconst MicStream = require('@analyticsinmotion/micstream');\n\nconst mic = new MicStream({ sampleRate: 16000, channels: 1 });\n\nmic.on('data', (chunk) =\u003e {\n  speechEngine.feed(chunk); // pass raw PCM directly\n});\n```\n\n### TypeScript\n\nTypeScript definitions are bundled. No `@types/` package needed.\n\n```typescript\nimport MicStream, { DeviceInfo, MicStreamOptions } from '@analyticsinmotion/micstream';\n\nconst options: MicStreamOptions = { sampleRate: 16000, channels: 1 };\nconst mic = new MicStream(options);\n\nmic.on('data', (chunk: Buffer) =\u003e {\n  // zero-copy Int16 view over the same memory\n  const samples = new Int16Array(chunk.buffer, chunk.byteOffset, chunk.length / 2);\n});\n\nmic.on('backpressure', () =\u003e console.warn('Consumer too slow'));\n\nconst devices: DeviceInfo[] = MicStream.devices();\n```\n\n---\n\n## API\n\n### `new MicStream(options?)`\n\nCreates a Readable stream that captures from the system default microphone.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `sampleRate` | number | `16000` | Samples per second (1000–384000) |\n| `channels` | number | `1` | Number of input channels (1–32) |\n| `framesPerBuffer` | number | `1600` | Frames per audio callback (64–65536) |\n| `device` | number | system default | Device index from `MicStream.devices()`; omit to use the system default |\n\nStandard Node.js `Readable` stream options (e.g. `highWaterMark`) are also accepted.\n\n### `mic.stop()`\n\nStops microphone capture and ends the stream. Safe to call multiple times.\n\n### Event: `'backpressure'`\n\nEmitted when `push()` returns `false`, meaning the stream's internal buffer is full and the consumer is reading too slowly. Because a microphone cannot be paused, audio chunks will continue to arrive. Callers should drain the stream or drop data to avoid unbounded memory growth.\n\n### `mic.isOpen`\n\n`true` if the microphone is currently capturing.\n\n### `MicStream.devices()`\n\nReturns an array of available input devices on the system.\n\n```javascript\nconst devices = MicStream.devices();\n// [\n//   { index: 0, name: 'Built-in Microphone', maxInputChannels: 1, defaultSampleRate: 44100, isDefault: true },\n//   ...\n// ]\n```\n\n### `MicStream.version()`\n\nReturns version information for micstream and the bundled PortAudio.\n\n```javascript\nMicStream.version();\n// { micstream: '0.2.0', portaudio: 'PortAudio V19.7.0-devel...' }\n```\n\n---\n\n## Audio format\n\nAll audio is captured as **16-bit signed integer PCM, little-endian**. This is the raw format expected by most speech and wake-word engines (Vosk, sherpa-onnx, whisper.cpp, openWakeWord).\n\nEach `data` event emits a `Buffer` where every 2 bytes is one 16-bit sample:\n\n```javascript\nmic.on('data', (chunk) =\u003e {\n  const samples = new Int16Array(chunk.buffer, chunk.byteOffset, chunk.length / 2);\n  // samples[0], samples[1], ...\n});\n```\n\n---\n\n## Platform Support\n\n### Pre-built binaries (zero setup)\n\n| Platform | Architecture | Audio Backend |\n| --- | --- | --- |\n| Windows 11 | x64 | WASAPI |\n| macOS (Apple Silicon) | arm64 | CoreAudio |\n| Linux | x64 | ALSA |\n| Linux | arm64 | ALSA |\n\n### Source build fallback (requires build tools)\n\n| Platform | Requirements |\n| --- | --- |\n| macOS Intel (pre-2020) | Xcode CLI tools: `xcode-select --install` |\n| Windows ARM64 | Visual C++ Build Tools |\n\n### Not supported\n\n| Platform | Reason |\n| --- | --- |\n| Windows 32-bit | N-API native addons require 64-bit |\n\n---\n\n## Building from source\n\nRequires Node.js \u003e= 16, node-gyp, and platform build tools.\n\n**Linux:**\n\n```bash\nsudo apt-get install -y build-essential libasound2-dev\n```\n\n**macOS:**\n\n```bash\nxcode-select --install\n```\n\n**Windows:**\nInstall [Visual C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/).\n\nThen:\n\n```bash\ngit clone --recurse-submodules https://github.com/analyticsinmotion/micstream.git\ncd micstream\nnpm install\nnpm run build\n```\n\n---\n\n## How it works\n\nmicstream wraps [PortAudio](http://www.portaudio.com/) — the standard cross-platform audio I/O library — as a Node.js native addon using [N-API](https://nodejs.org/api/n-api.html). PortAudio is compiled from source and statically linked, so there is no system PortAudio dependency.\n\nThe native addon opens the default input device, runs a PortAudio callback in an audio thread, and forwards PCM chunks to JavaScript via an N-API `ThreadSafeFunction`. The JavaScript layer wraps this in a standard Node.js `Readable` stream.\n\n---\n\n## License\n\nApache-2.0 © [Analytics in Motion](https://github.com/analyticsinmotion)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalyticsinmotion%2Fmicstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanalyticsinmotion%2Fmicstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalyticsinmotion%2Fmicstream/lists"}