{"_rev":"6-ce42b42c5ed46bc4ec944e67d33f4549","time":{"created":"2026-05-27T15:51:55.087Z","modified":"2026-05-27T15:51:55.665Z","1.0.3-esm.0":"2026-04-28T08:07:44.093Z","1.0.3-esm.1":"2026-04-28T08:15:15.811Z","1.0.3-esm.2":"2026-05-27T15:51:55.468Z"},"_id":"@amzgrainrain/pvspeaker-node","name":"@amzgrainrain/pvspeaker-node","dist-tags":{"latest":"1.0.3-esm.2"},"versions":{"1.0.3-esm.2":{"name":"@amzgrainrain/pvspeaker-node","version":"1.0.3-esm.2","description":"Audio player sdk for Nodejs.","main":"dist/index.js","keywords":["audio, audio player"],"type":"module","author":{"name":"Picovoice Inc."},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/AmzGrainRain/pvspeaker-esm.git","directory":"binding/nodejs"},"scripts":{"build":"npm-run-all --parallel build:**","build:all":"tsc","prepack":"npm run build","prepare":"node copy.js","test":"jest --no-cache","lint":"eslint . --ext .js,.ts"},"devDependencies":{"@types/jest":"^30.0.0","@types/node":"^25.6.0","@typescript-eslint/eslint-plugin":"^8.59.1","@typescript-eslint/parser":"^8.59.1","eslint":"^10.2.1","eslint-plugin-jest":"^29.15.2","jest":"^30.3.0","mkdirp":"^3.0.1","ncp":"^2.0.0","npm-run-all":"^4.1.5","prettier":"^3.8.3","ts-jest":"^29.4.9","typescript":"^6.0.3"},"engines":{"node":">=18.0.0"},"_id":"@amzgrainrain/pvspeaker-node@1.0.3-esm.2","gitHead":"00af07b4a90962575feb366e8ed21c60e083bfcc","types":"./dist/index.d.ts","bugs":{"url":"https://github.com/AmzGrainRain/pvspeaker-esm/issues"},"homepage":"https://github.com/AmzGrainRain/pvspeaker-esm#readme","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-xdL2bw2ayMFIt4CbqMC2CpfPrH2cmMVWcQRT+jsHaFh7kdN50rwPhUXOcMWbNmb0ULODeRhUmBJOaWRC23xnnQ==","shasum":"b88dd8481a274cfb017d90c2a6ad67c1364a0c16","tarball":"https://registry.npmjs.org/@amzgrainrain/pvspeaker-node/-/pvspeaker-node-1.0.3-esm.2.tgz","fileCount":37,"unpackedSize":8855192,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIET3Eqq/erajCFkQT/mWmS7IcCoyuLxFhvUiJ7SJPsiDAiEArq43zX9YECYPiFGEu6sAjZvlXew8wSfOMbILRRqhERE="}]},"_npmUser":{"name":"amzgrainrain","email":"amzgrainrain@outlook.com"},"directories":{},"maintainers":[{"name":"amzgrainrain","email":"amzgrainrain@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pvspeaker-node_1.0.3-esm.2_1779897115207_0.8745769711926428"},"_hasShrinkwrap":false}},"maintainers":[{"name":"amzgrainrain","email":"amzgrainrain@outlook.com"}],"description":"Audio player sdk for Nodejs.","homepage":"https://github.com/AmzGrainRain/pvspeaker-esm#readme","keywords":["audio, audio player"],"repository":{"type":"git","url":"git+https://github.com/AmzGrainRain/pvspeaker-esm.git","directory":"binding/nodejs"},"author":{"name":"Picovoice Inc."},"bugs":{"url":"https://github.com/AmzGrainRain/pvspeaker-esm/issues"},"license":"Apache-2.0","readme":"# PvSpeaker Binding for Node.js (ESM Version)\r\n\r\n> **Note:** This is an ESM-compatible fork of the original [@picovoice/pvspeaker-node](https://github.com/Picovoice/pvspeaker). It provides full ES Module support and modernized TypeScript definitions.\r\n\r\n## PvSpeaker\r\n\r\nPvSpeaker is an easy-to-use, cross-platform audio player designed for real-time speech audio processing. It allows developers to send raw PCM frames to an audio device's output stream.\r\n\r\n## Compatibility\r\n\r\n- Node.js 18+\r\n- Runs on Linux (x86_64), macOS (x86_64 and arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).\r\n\r\n## Installation\r\n\r\n```console\r\nnpm install @amzgrainrain/pvspeaker-node\r\n# or\r\nyarn add @amzgrainrain/pvspeaker-node\r\n# or\r\npnpm add @amzgrainrain/pvspeaker-node\r\n```\r\n\r\n## Usage\r\n\r\nSince this package is ESM-only, use `import` syntax:\r\n\r\n```javascript\r\nimport { PvSpeaker } from \"@amzgrainrain/pvspeaker-node\";\r\n\r\nconst sampleRate = 22050;\r\nconst bitsPerSample = 16;\r\nconst speaker = new PvSpeaker(sampleRate, bitsPerSample);\r\n\r\nspeaker.start();\r\n```\r\n\r\n(or)\r\n\r\nUse `getAvailableDevices()` to get a list of available devices and then initialize the instance based on the index of a device:\r\n\r\n```javascript\r\nimport { PvSpeaker } from \"@amzgrainrain/pvspeaker-node\";\r\n\r\nconst devices = PvSpeaker.getAvailableDevices();\r\n\r\nconst sampleRate = 22050;\r\nconst bitsPerSample = 16;\r\nconst deviceIndex = 0;\r\nconst speaker = new PvSpeaker(sampleRate, bitsPerSample, { deviceIndex });\r\n\r\nspeaker.start();\r\n```\r\n\r\nWrite PCM data to the speaker:\r\n\r\n```typescript\r\nfunction getNextAudioFrame(): ArrayBuffer {\r\n    // ...\r\n}\r\n\r\nspeaker.write(getNextAudioFrame());\r\n```\r\n\r\nNote: the `write()` method only writes as much PCM data as the internal circular buffer can currently fit, and returns the length of the PCM data that was successfully written.\r\n\r\nWhen all frames have been written, run `flush()` to wait for all buffered PCM data (i.e. previously buffered via `write()`) to be played:\r\n\r\n```typescript\r\nspeaker.flush();\r\n```\r\n\r\nNote: calling `flush()` with PCM data as an argument will both write that PCM data and wait for all buffered PCM data to finish.\r\n\r\n```typescript\r\nfunction getRemainingAudioFrames(): ArrayBuffer {\r\n    // ...\r\n}\r\n\r\nspeaker.flush(getRemainingAudioFrames());\r\n```\r\n\r\nTo stop the audio output device, run `stop()`:\r\n\r\n```typescript\r\nspeaker.stop();\r\n```\r\n\r\nOnce you are done (i.e. no longer need PvSpeaker to write and/or play PCM), free the resources acquired by PvSpeaker by calling `release`. You do not have to call `stop` before `release`:\r\n\r\n```typescript\r\nspeaker.release();\r\n```\r\n\r\n## Key Changes from Original\r\n\r\n- **ESM Support**: Fully migrated to ES Modules.\r\n- **Type Safety**: Improved TypeScript definitions with `bigint` handles.\r\n- **Modern Tooling**: Updated to latest TypeScript and Jest versions.\r\n\r\n## Demos\r\n\r\nThe original [@picovoice/pvspeaker-demo](https://www.npmjs.com/package/@picovoice/pvspeaker-demo) provides command-line utilities for playing audio from a file.\r\n\r\n## License\r\n\r\nCopyright 2024 Picovoice Inc.\r\nLicensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.\r\n","readmeFilename":"README.md"}