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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@speechmatics/expo-two-way-audio

v0.1.2

Published

Native module for two way audio streaming

Readme

Speechmatics Two Way Audio

Expo module for capturing and playing pcm audio data in react-native apps (iOS and Android).

The aim of the module is to facilitate creating real-time conversational apps. The following features are provided:

  • Request audio recording permissions
  • Get clean (applying Acoustic Echo Cancelling) microphone samples in PCM format (1 channel 16 bit at 16kHz)
  • Play audio samples in PCM format (1 channel 16 bit at 16kHz). Playback happens trough main speaker unless external audio sources are connected.
  • Provide volume level both for the input and output samples. Float between 0 and 1.
  • [iOS only] Get microphone mode and prompt user to select a microphone mode.

Check out our examples/ to see the module in action.

Installation

npm i @speechmatics/expo-two-way-audio

Usage

Please check out our examples/ to get full sample code.

  1. Request permissions for recording audio

    import {useMicrophonePermissions} from "@speechmatics/expo-two-way-audio";
    
    const [micPermission, requestMicPermission] = useMicrophonePermissions();
    console.log(micPermission);
  2. Initialize the module before calling any audio functionality.

    useEffect(() => {
        const initializeAudio = async () => {
            await initialize();
        };
        initializeAudio();
    }, []);
    
  3. Play audio

    [!NOTE] The sample below uses the buffer module: npm install buffer

     import { Buffer } from "buffer";
    
     // As an example, let's play pcm data hardcoded in a variable.
     // The examples/basic-usage does this. Check it out for real base64 data.
     const audioChunk = "SOME PCM DATA BASE64 ENCODED HERE"
     const buffer = Buffer.from(audioChunk, "base64");
     const pcmData = new Uint8Array(buffer);
     playPCMData(pcmData);
  4. Get microphone samples

    // Set up a function to deal with microphone sample events.
    // In this case just print the data in the console.
    useExpoTwoWayAudioEventListener(
        "onMicrophoneData",
        useCallback<MicrophoneDataCallback>((event) => {
            console.log(`MIC DATA: ${event.data}`);
        }, []),
    );
    
    // Unmute the microphone to get microphone data events
    toggleRecording(true);

Notes

Some audio features of expo-two-way-audio like Acoustic Echo Cancelling, noise reduction or microphone modes (iOS) don't work on simulator. Run the example on a real device to test these features.

# iOS
npx expo run:ios --device --configuration Release

# Android
npx expo run:android --device --variant release

For Android, the following permissions are needed: RECORD_AUDIO, MODIFY_AUDIO_SETTINGS. In Expo apps they can bee added in your app.json file:

expo.android.permissions: ["RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS"]