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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-nitro-speech-recognition

v0.2.1

Published

react-native-nitro-speech-recognition

Readme

react-native-nitro-speech-recognition

npm version

A powerful speech recognition library for React Native, built with Nitro Modules.

Features

  • 🚀 Fast & Efficient: Built with Nitro Modules for high performance.
  • 🎙️ Real-time Recognition: Supports real-time speech-to-text.
  • 📱 On-Device Support: Supports on-device speech recognition (Android 13+).
  • 🌍 Multi-language: Supports multiple locales.
  • 🔄 Flexible Audio Input: Accepts raw audio buffers (PCM Int16 or Float32).

Installation

npm install react-native-nitro-speech-recognition
# or
yarn add react-native-nitro-speech-recognition
# or
bun add react-native-nitro-speech-recognition

Expo

You can use this library with Expo. It includes a Config Plugin to automatically configure permissions.

First, install the package:

npx expo install react-native-nitro-speech-recognition

Then, add the config plugin to your app.json or app.config.js:

{
  "expo": {
    "plugins": [
      [
        "react-native-nitro-speech-recognition",
        {
          "microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone.",
          "speechRecognitionPermission": "Allow $(PRODUCT_NAME) to access speech recognition."
        }
      ]
    ]
  }
}

Manual Installation (Bare React Native)

If you are not using Expo, or if you are using a bare React Native project, you need to configure permissions manually.

iOS

Add the following key to your Info.plist to request speech recognition permission:

<key>NSSpeechRecognitionUsageDescription</key>
<string>Allow access to speech recognition for transcribing your voice.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow access to the microphone for recording audio.</string>

Android

Add the following permission to your AndroidManifest.xml:

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

Usage

Basic Usage

import { SpeechRecognition } from 'react-native-nitro-speech-recognition';

const speechRecognition = new SpeechRecognition();

// 1. Check availability
const isAvailable = SpeechRecognition.isRecognitionAvailable();

// 2. Request permissions
const permissions = await SpeechRecognition.requestPermissionsAsync();

// 3. Setup event listeners
speechRecognition.on('result', (event) => {
  console.log('Transcript:', event.results[0]?.transcript);
  console.log('Is Final:', event.isFinal);
});

speechRecognition.on('error', (error) => {
  console.error('Error:', error);
});

// 4. Start recognition
speechRecognition.start({
  locale: 'en-US',
  interimResults: true,
  audioFormat: 'pcmFloat32', // or 'pcmInt16'
  sampleRate: 16000,
});

// 5. Feed audio data (e.g., from a microphone stream)
// This library does NOT handle audio recording. You need to use an external library
// like `react-native-audio-api` to record audio and feed the raw PCM data (ArrayBuffer)
// to the recognizer.

// Example using `react-native-audio-api`:
// import { AudioRecorder } from 'react-native-audio-api';

// const recorder = new AudioRecorder({
//   sampleRate: 16000,
//   bufferLengthInSamples: 4096,
// });

// recorder.onAudioReady((event) => {
//   const bufferData = event.buffer.getChannelData(0);
//   // Ensure the data is in the correct format (e.g. pcmFloat32 or pcmInt16)
//   speechRecognition.streamInsert(bufferData.buffer);
// });

// recorder.start();

// 6. Stop recognition
speechRecognition.stop();

On-Device Recognition (Android)

To use on-device recognition on Android, you might need to download the model first.

const locale = 'en-US';
const supported = await SpeechRecognition.getSupportedLocales();

if (!supported.installedLocales.includes(locale)) {
  const result = await SpeechRecognition.downloadOnDeviceModel(locale, (progress) => {
    console.log(`Download progress: ${progress * 100}%`);
  });
  
  if (result.status === 'download_success') {
    console.log('Model downloaded successfully');
  }
}

speechRecognition.start({
  locale,
  requiresOnDeviceRecognition: true,
  // ... other options
});

API Reference

SpeechRecognition

The main class for managing speech recognition sessions.

Methods

  • start(options: SpeechRecognitionOptions): void: Starts the speech recognition session.
  • stop(): void: Stops the speech recognition session.
  • streamInsert(buffer: ArrayBuffer): void: Feeds audio data into the recognizer.
  • on(event: EventType, listener: Function): void: Registers an event listener.
  • unsubscribeAll(): void: Unsubscribes all listeners.

Static Methods

  • isRecognitionAvailable(): boolean: Checks if speech recognition is available on the device.
  • isOnDeviceRecognitionAvailable(): boolean: Checks if on-device recognition is available.
  • downloadOnDeviceModel(locale: string, onProgress: (progress: number) => void): Promise<OnDeviceModelDownloadResult>: Downloads the on-device model for the specified locale (Android).
  • getSupportedLocales(): Promise<SupportedLocales>: Returns the list of supported and installed locales.
  • getPermissionsAsync(): Promise<PermissionResponse>: Gets the current permission status.
  • requestPermissionsAsync(): Promise<PermissionResponse>: Requests speech recognition permissions.

SpeechRecognitionOptions

| Property | Type | Description | | :--- | :--- | :--- | | locale | string | The locale for recognition (e.g., "en-US"). | | interimResults | boolean | Whether to return interim results. | | maxAlternatives | number | Maximum number of alternative transcripts. | | requiresOnDeviceRecognition | boolean | Whether to require on-device recognition. | | addsPunctuation | boolean | Whether to add punctuation to the transcript. | | audioFormat | 'pcmInt16' \| 'pcmFloat32' | The format of the input audio buffer. | | sampleRate | number | The sample rate of the input audio. |

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT