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/react-native-voice-processor

v1.2.3

Published

A library for real-time voice processing in React Native.

Downloads

829

Readme

React Native Voice Processor

GitHub release GitHub

npm

Made in Vancouver, Canada by Picovoice

Twitter URL

YouTube Channel Views

The React Native Voice Processor is an asynchronous audio capture library designed for real-time audio processing on mobile devices. Given some specifications, the library delivers frames of raw audio data to the user via listeners.

Table of Contents

Requirements

Compatibility

  • React Native 0.68.7+
  • Android 5.0+ (API 21+)
  • iOS 13.0+

Installation

React Native Voice Processor is available via npm. To import it into your React Native project install with npm or yarn:

yarn add @picovoice/react-native-voice-processor

or

npm i @picovoice/react-native-voice-processor --save

Permissions

To enable recording with the hardware's microphone, you must first ensure that you have enabled the proper permission on both iOS and Android.

On iOS, open the Info.plist file and add the following line:

<key>NSMicrophoneUsageDescription</key>
<string>[Permission explanation]</string>

On Android, open the AndroidManifest.xml and add the following line:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

See our example app for how to properly request this permission from your users.

Usage

Access the singleton instance of VoiceProcessor:

import {
  VoiceProcessor,
  VoiceProcessorError
} from '@picovoice/react-native-voice-processor';

let voiceProcessor = VoiceProcessor.instance;

Add listeners for audio frames and errors:

voiceProcessor.addFrameListener((frame: number[]) => {
  // use audio frame
});
voiceProcessor.addErrorListener((error: VoiceProcessorError) => {
  // handle error
});

Ask for audio record permission and start recording with the desired frame length and audio sample rate:

const frameLength = 512;
const sampleRate = 16000;

try {
  if (await voiceProcessor.hasRecordAudioPermission()) {
    await voiceProcessor.start(frameLength, sampleRate);
  } else {
    // user did not grant permission
  }
} catch (e) {
  // handle start error
}

Stop audio capture:

try {
  await this._voiceProcessor.stop();
} catch (e) {
  // handle stop error
}

Once audio capture has started successfully, any frame listeners assigned to the VoiceProcessor will start receiving audio frames with the given frameLength and sampleRate.

Capturing with Multiple Listeners

Any number of listeners can be added to and removed from the VoiceProcessor instance. However, the instance can only record audio with a single audio configuration (frameLength and sampleRate), which all listeners will receive once a call to start() has been made. To add multiple listeners:

const listener1 = (frame) => { };
const listener2 = (frame) => { };
const listeners = [listener1, listener2];
voiceProcessor.addFrameListeners(listeners);

voiceProcessor.removeFrameListeners(listeners);
// or
voiceProcessor.clearFrameListeners();

Example

The React Native Voice Processor app demonstrates how to ask for user permissions and capture output from the VoiceProcessor.

To launch the demo, run:

yarn bootstrap
yarn example ios
# or
yarn example android

Releases

v1.2.0 - August 11, 2023

  • Numerous API improvements
  • Error handling improvements
  • Allow for multiple listeners
  • Upgrades to testing infrastructure and example app

v1.1.0 - February 23, 2023

  • Migrated to new template

v1.0.0 - March 29, 2021

  • Initial public release