npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@picovoice/pvspeaker-node

v1.0.1

Published

Audio player sdk for Nodejs.

Downloads

14

Readme

PvSpeaker Binding for Node.js

PvSpeaker

PvSpeaker 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.

Compatibility

  • Node.js 16+
  • Runs on Linux (x86_64), macOS (x86_64 and arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5).

Installation

yarn add @picovoice/pvspeaker-node

Usage

Initialize and start PvSpeaker:

const { PvSpeaker } = require("@picovoice/pvspeaker-node");

const sampleRate = 22050;
const bitsPerSample = 16;
const speaker = new PvSpeaker(sampleRate, bitsPerSample);

speaker.start()

(or)

Use getAvailableDevices() to get a list of available devices and then initialize the instance based on the index of a device:


const { PvSpeaker } = require("@picovoice/pvspeaker-node");

const devices = PvSpeaker.getAvailableDevices()

const sampleRate = 22050;
const bitsPerSample = 16;
const deviceIndex = 0;
const speaker = new PvSpeaker(sampleRate, bitsPerSample, { deviceIndex });

speaker.start()

Write PCM data to the speaker:

function getNextAudioFrame(): ArrayBuffer {
    //
}

speaker.write(getNextAudioFrame())

Note: 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.

When all frames have been written, run flush() to wait for all buffered PCM data (i.e. previously buffered via write()) to be played:

speaker.flush()

Note: calling flush() with PCM data as an argument will both write that PCM data and wait for all buffered PCM data to finish.

function getRemainingAudioFrames(): ArrayBuffer {
    //
}

speaker.flush(getRemainingAudioFrames())

To stop the audio output device, run stop():

speaker.stop();

Once 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:

speaker.release();

Demos

@picovoice/pvspeaker-demo provides command-line utilities for playing audio from a file.