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

avr-resampler

v1.0.4

Published

Audio Resampler for Agent Voice Response (AVR) STS or TTS service

Readme

Agent Voice Response - Resampler

Discord GitHub Repo stars npm version npm downloads Ko-fi

A TypeScript npm package for audio resampling between different sample rates, specifically designed for AVR (Agent Voice Response) STS or TTS service integration.

Features

  • Configurable Provider Sample Rate: Set the provider sample rate via constructor parameter
  • Fixed Client Sample Rate: Client sample rate is fixed at 8000 Hz for compatibility (Asterisk AudioSocket Module)
  • Bidirectional Resampling: Handle both upsampling (client → provider) and downsampling (provider → client)
  • Buffered Processing: Accumulates audio chunks for optimal processing
  • TypeScript Support: Full TypeScript support with type definitions

Installation

npm install avr-resampler

Usage

Basic Usage

import { AudioResampler } from 'avr-resampler';

const customResampler = new AudioResampler(48000); // 48 kHz provider rate
await customResampler.initialize();
const result = customResampler.downsample(audioBuffer);

Constructor Parameters

  • providerSampleRate (number, optional): The sample rate of the audio provider in Hz. Defaults to 48000 Hz.

Methods

downsample(data: Buffer): Buffer

Processes incoming audio chunks from the provider and converts them to client format (8000 Hz).

  • Input: Raw audio data from provider
  • Output: Converted audio data if not enough data accumulated
  • Usage: Call repeatedly with incoming audio chunks

upsample(data: Buffer): Buffer

Processes incoming audio chunks from the client (8000 Hz) and converts them to provider format.

  • Input: Raw audio data from client
  • Output: Converted audio data for provider
  • Usage: Call with client audio chunks

destroy(): void

Cleans up resources and resets the resampler state.

initialize(): Promise<void>

Initializes the audio resamplers. Called automatically when needed.

Example

import { AudioResampler } from 'avr-resampler';

// Create resampler for 48 kHz provider
const resampler = new AudioResampler(48000);
await resampler.initialize();

// Process provider audio → client audio
const providerAudio = Buffer.from([/* your audio data */]);
const clientAudio = resampler.downsample(providerAudio);

if (clientAudio) {
  // Send to client
  sendToClient(clientAudio);
}

// Process client audio → provider audio
const clientInput = Buffer.from([/* client audio data */]);
const providerInput = await resampler.upsample(clientInput);

// Send to provider
sendToProvider(providerInput);

// Clean up when done
resampler.destroy();

Dependencies

  • @alexanderolsen/libsamplerate-js: Audio resampling library

Support & Community

Support AVR

AVR is free and open-source. If you find it valuable, consider supporting its development:

License

MIT License - see the LICENSE file for details.