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

@loqalabs/loqa-audio-bridge

v0.3.1

Published

Production-grade Expo native module for real-time audio streaming with Voice Activity Detection and battery optimization

Downloads

210

Readme

@loqalabs/loqa-audio-bridge

Production-grade Expo native module for real-time audio streaming with Voice Activity Detection and battery optimization

CI npm version License: MIT

Features

  • Real-time Audio Streaming - Capture audio at 8kHz-48kHz with configurable buffer sizes
  • Voice Activity Detection (VAD) - Automatic silence detection for battery optimization
  • Cross-Platform - Unified API for iOS (AVAudioEngine) and Android (AudioRecord)
  • TypeScript Support - Full type definitions with strict typing
  • Zero Configuration - Autolinking works out-of-the-box with Expo

Installation

npx expo install @loqalabs/loqa-audio-bridge

That's it! Autolinking handles the rest.

Quick Start

import { startAudioStream, addAudioSampleListener } from '@loqalabs/loqa-audio-bridge';

// Start streaming
await startAudioStream({ sampleRate: 16000, bufferSize: 2048 });

// Listen for audio samples
const subscription = addAudioSampleListener((event) => {
  console.log('RMS:', event.rms); // Volume level
  // Access audio samples: event.samples (number[])
});

// Clean up when done
subscription.remove();

Documentation

Platform Requirements

  • iOS 13.4+
  • Android API 24+
  • Expo 52+
  • React Native 0.72+

Key Capabilities

Audio Configuration

Configure sample rate, buffer size, channels, and enable VAD for your use case:

await startAudioStream({
  sampleRate: 16000, // 8000, 16000, 32000, 44100, 48000
  bufferSize: 2048, // 512-8192 samples
  channels: 1, // 1 (mono) or 2 (stereo)
  vadEnabled: true, // Voice Activity Detection
});

Event-Driven Architecture

Subscribe to audio samples, status changes, and errors:

import {
  addAudioSampleListener,
  addStreamStatusListener,
  addStreamErrorListener,
} from '@loqalabs/loqa-audio-bridge';

// Audio samples (~8 Hz at 16kHz/2048 buffer)
const audioSub = addAudioSampleListener((event) => {
  const samples = event.samples; // number[] of audio data
  const rms = event.rms; // Volume level (0.0-1.0)
});

// Stream status changes
const statusSub = addStreamStatusListener((event) => {
  console.log('Status:', event.status); // "streaming" | "stopped" | "paused"
});

// Stream errors
const errorSub = addStreamErrorListener((event) => {
  console.error('Error:', event.error, event.message);
});

React Hook

Use the useAudioStreaming hook for automatic lifecycle management:

import { useAudioStreaming } from '@loqalabs/loqa-audio-bridge';

function MyComponent() {
  const { startStream, stopStream, isStreaming, rmsLevel } = useAudioStreaming({
    sampleRate: 16000,
    bufferSize: 2048,
  });

  return (
    <View>
      <Button title="Start" onPress={startStream} />
      <Button title="Stop" onPress={stopStream} />
      <Text>RMS: {rmsLevel}</Text>
    </View>
  );
}

Permissions

iOS

Add microphone permission to your app.json:

{
  "expo": {
    "ios": {
      "infoPlist": {
        "NSMicrophoneUsageDescription": "This app needs microphone access for audio recording."
      }
    }
  }
}

Android

Add microphone permission to your app.json:

{
  "expo": {
    "android": {
      "permissions": ["RECORD_AUDIO"]
    }
  }
}

Request permission at runtime using expo-av or similar:

import { Audio } from 'expo-av';

const { status } = await Audio.requestPermissionsAsync();
if (status === 'granted') {
  // Start streaming
}

Performance

  • CPU Usage: 2-5% during active streaming
  • Battery Impact: 3-8% per hour with VAD enabled (30-50% reduction vs. continuous)
  • Event Rate: ~8 Hz at 16kHz/2048 buffer (configurable via buffer size)

Common Use Cases

  • Speech Recognition: 16kHz sample rate for optimal accuracy
  • Voice Communication: 8kHz-16kHz with VAD for battery efficiency
  • Audio Analysis: 44.1kHz-48kHz for high-fidelity capture
  • Environmental Monitoring: VAD-enabled streaming with low sample rates

EAS Build Compatibility

This package works seamlessly with Expo Application Services (EAS) Build for cloud-based iOS and Android builds. No special configuration required.

Quick Setup

  1. Install the package:

    npx expo install @loqalabs/loqa-audio-bridge
  2. Configure EAS Build (if not already done):

    npx eas build:configure
  3. Build your app:

    # iOS
    eas build --platform ios --profile development
    
    # Android
    eas build --platform android --profile development

Standard Configuration

The package works with a standard eas.json:

{
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "production": {
      "distribution": "store"
    }
  }
}

No custom plugins, build hooks, or special environment variables required. The module autolinks identically in cloud builds as it does in local builds.

Verification

Once your EAS build completes:

  1. Download the .ipa (iOS) or .apk (Android) from the EAS dashboard
  2. Install on a physical device
  3. The audio streaming functionality works identically to local builds

For detailed EAS Build setup and troubleshooting, see the Integration Guide.

License

MIT

Contributing

This package is part of the Loqa monorepo. See the repository for contribution guidelines.

Support