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

@vexyl.ai/aivg-sdk

v1.0.4

Published

AI Voice Gateway Browser SDK - WebSocket-based voice assistant for browsers

Readme

@vexyl.ai/aivg-sdk

AI Voice Gateway Browser SDK - WebSocket-based voice assistant for browsers.

GitHub Docker Hub Twitter Discord Website

Demo

What is Vexyl AI Voice Gateway?

Vexyl is an ** production-ready voice AI gateway** that enables real-time conversational AI for telephone systems, contact centers, and web applications. It acts as an intelligent middleware between your telephony infrastructure (Asterisk, FreeSWITCH, SIP) and modern AI services (OpenAI, Gemini, Sarvam, Deepgram).

The Problem We Solve

Building voice AI systems traditionally requires:

  • Complex integration with multiple AI providers (STT, TTS, LLM)
  • Managing real-time audio streaming and processing
  • Handling telephony protocols (SIP, RTP, AudioSocket)
  • Optimizing latency for natural conversations
  • Supporting multiple languages and accents
  • Implementing features like barge-in, call transfer, and sentiment analysis
  • Managing costs across different AI services

Connect your web applications to AI-powered voice assistants with real-time speech-to-text, LLM processing, and text-to-speech.

Installation

npm install @vexyl.ai/aivg-sdk

Or via CDN:

<script src="https://unpkg.com/@vexyl.ai/aivg-sdk"></script>

Quick Start

import AIVoiceGateway from '@vexyl.ai/aivg-sdk';

const voice = new AIVoiceGateway({
    serverUrl: 'wss://your-server.com:8082',
    language: 'en-IN',
    onTranscript: (text, { isFinal }) => {
        console.log('User said:', text, isFinal ? '(final)' : '(partial)');
    },
    onResponse: (text) => {
        console.log('AI said:', text);
    },
    onError: (error) => {
        console.error('Error:', error.message);
    }
});

// Connect and start listening
await voice.connect();
await voice.startListening();

Usage

ES Modules

import AIVoiceGateway from '@vexyl.ai/aivg-sdk';

CommonJS

const AIVoiceGateway = require('@vexyl.ai/aivg-sdk');

Browser (CDN)

<script src="https://unpkg.com/@vexyl.ai/aivg-sdk"></script>
<script>
    const voice = new AIVoiceGateway({ serverUrl: 'wss://...' });
</script>

Configuration Options

const voice = new AIVoiceGateway({
    // Required
    serverUrl: 'wss://your-server.com:8082',

    // Optional
    language: 'en-IN',              // Language code (default: 'en-IN')
    apiKey: 'your-api-key',         // API key for authentication
    metadata: {                      // Custom session metadata
        botId: 'sales-bot',
        callerName: 'John Doe',
        department: 'sales'
    },
    autoGreet: false,               // AI speaks first on connect
    greetingMessage: 'hi',          // Message for auto-greeting
    autoReconnect: true,            // Auto-reconnect on disconnect
    maxReconnectAttempts: 5,        // Max reconnection attempts
    reconnectDelay: 1000,           // Delay between attempts (ms)

    // Callbacks
    onConnect: ({ uuid }) => {},
    onDisconnect: ({ code, reason }) => {},
    onTranscript: (text, { isFinal }) => {},
    onResponse: (text) => {},
    onAudio: (arrayBuffer) => {},
    onStatus: (status) => {},
    onError: ({ code, message }) => {},
    onHangup: ({ reason }) => {}
});

API Methods

Connection

// Connect to server
await voice.connect();

// Disconnect
voice.disconnect();

Audio Control

// Start listening (requests microphone permission)
await voice.startListening();

// Stop listening
voice.stopListening();

// Mute/unmute microphone
voice.mute();
voice.unmute();

Configuration

// Change language
voice.setLanguage('hi-IN');

// Update metadata (e.g., change bot mid-session)
voice.updateMetadata({ botId: 'support-bot' });

Status

// Get current status
const status = voice.getStatus();
// { isConnected, isListening, isMuted, uuid, language }

// Check if audio is playing
if (voice.isAudioPlaying()) {
    console.log('AI is speaking');
}

Audio Visualization

// Get Web Audio API analyser for visualization
const analyser = voice.getAnalyser();

// Get frequency data
const frequencyData = voice.getFrequencyData();
if (frequencyData) {
    // Use for visualization (e.g., waveform, spectrum)
}

Examples

Basic Voice Chat

const voice = new AIVoiceGateway({
    serverUrl: 'wss://voice.example.com:8082',
    onTranscript: (text, { isFinal }) => {
        document.getElementById('transcript').textContent = text;
    },
    onResponse: (text) => {
        document.getElementById('response').textContent = text;
    }
});

document.getElementById('start-btn').onclick = async () => {
    await voice.connect();
    await voice.startListening();
};

document.getElementById('stop-btn').onclick = () => {
    voice.disconnect();
};

With Dynamic Bot Selection

const voice = new AIVoiceGateway({
    serverUrl: 'wss://voice.example.com:8082',
    metadata: {
        botId: 'sales-bot',      // Select which bot to use
        callerName: 'John',
        department: 'sales'
    }
});

AI Speaks First (Auto-Greeting)

const voice = new AIVoiceGateway({
    serverUrl: 'wss://voice.example.com:8082',
    autoGreet: true,
    greetingMessage: 'Hello, how can I help you today?'
});

Audio Visualization

const voice = new AIVoiceGateway({
    serverUrl: 'wss://voice.example.com:8082'
});

await voice.connect();
await voice.startListening();

// Visualize audio
function visualize() {
    const data = voice.getFrequencyData();
    if (data) {
        // Draw waveform or spectrum
        const avg = data.reduce((a, b) => a + b, 0) / data.length;
        console.log('Audio level:', avg);
    }
    requestAnimationFrame(visualize);
}
visualize();

Supported Languages

The SDK supports any language configured on your AI Voice Gateway server:

  • Indian Languages (via Sarvam): Hindi, Malayalam, Tamil, Telugu, Kannada, Bengali, etc.
  • International Languages (via Groq/Gemini): 90+ languages

Common language codes:

  • en-IN - English (India)
  • hi-IN - Hindi
  • ml-IN - Malayalam
  • ta-IN - Tamil
  • te-IN - Telugu
  • en-US - English (US)

Error Handling

const voice = new AIVoiceGateway({
    serverUrl: 'wss://voice.example.com:8082',
    onError: (error) => {
        switch (error.code) {
            case 'WS_ERROR':
                console.error('WebSocket error');
                break;
            case 'MIC_ERROR':
                console.error('Microphone access denied');
                break;
            case 'RECORDER_ERROR':
                console.error('Recording error');
                break;
            default:
                console.error('Error:', error.message);
        }
    }
});

Browser Support

  • Chrome 66+
  • Firefox 60+
  • Safari 14.1+
  • Edge 79+

Requires:

  • WebSocket API
  • MediaRecorder API
  • Web Audio API
  • getUserMedia API

License

MIT

Links