πŸš€ Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More β†’
Socket
Book a DemoInstallSign in
Socket

@juspay/vokal

Package Overview
Dependencies
Maintainers
7
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@juspay/vokal

Production voice bot framework with TTS, STT, and AI evaluation using Neurolink

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
7
Created
Source

Vokal πŸŽ™οΈ

A production-ready voice bot testing and interaction framework with streaming Speech-to-Text, Text-to-Speech, and AI-powered evaluation

TypeScript Node.js License: MIT NPM Package

✨ What is Vokal?

Vokal is a comprehensive TypeScript framework for building, testing, and evaluating voice-based applications. It provides a provider-agnostic architecture for Speech-to-Text, Text-to-Speech, and AI-powered evaluation services. Currently supports Google Cloud providers (Speech-to-Text, Text-to-Speech via Neurolink SDK, and Gemini AI), with an extensible design that allows for additional provider integrations.

Perfect for:

  • πŸ€– Testing voice bots and conversational AI
  • πŸ“ž IVR (Interactive Voice Response) system validation
  • 🎯 Voice UI/UX testing and evaluation
  • πŸ”Š Speech synthesis and recognition workflows
  • πŸ§ͺ Automated voice conversation testing

πŸš€ Key Features

Voice Services

  • 🎀 Text-to-Speech (TTS) - High-quality neural speech synthesis via Neurolink SDK
  • 🎧 Streaming Speech-to-Text - Real-time audio transcription with voice activity detection
  • πŸ—£οΈ Voice Interaction Pipeline - Complete TTS β†’ Listen β†’ STT conversation flows
  • 🎡 Background Audio Mixing - Realistic test environments (office, cafe, rain, nature, phone, crowd)

Testing & Evaluation

  • πŸ€– AI-Powered Evaluation - Semantic response validation using Google Gemini
  • πŸ“Š Comprehensive Test Suites - JSON-based test configuration with detailed reporting
  • πŸ”„ Automatic Retries - Built-in retry logic with exponential backoff
  • πŸ“ˆ Performance Metrics - Pass rates, confidence scores, and detailed analytics

Developer Experience

  • πŸ“˜ Full TypeScript Support - Complete type safety with strict mode
  • πŸ›‘οΈ Security First - Input validation, sanitization, and secure credential handling
  • πŸ”§ Easy Configuration - JSON-based configuration with sensible defaults
  • πŸ“¦ Modular Architecture - Use individual services or the complete framework
  • πŸ–₯️ Powerful CLI - Command-line interface for all operations

πŸ“‹ Table of Contents

πŸ”§ Installation

Prerequisites

node -v  # Should be 20.x or higher
pnpm -v  # Should be 9.x or higher (npm or yarn also work)

Install Vokal

pnpm add @juspay/vokal

Or clone and build from source:

git clone https://github.com/juspay/vokal.git
cd vokal
pnpm install
pnpm run build

Set Up Credentials

Create a .env file in your project root:

# Option 1: Service Account (Recommended - Full Features)
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

# Option 2: API Key (Limited Features)
GOOGLE_AI_API_KEY=your_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here

πŸ’‘ Tip: Service account authentication provides access to advanced features like configurable VAD timeouts and enhanced STT capabilities.

🎯 Quick Start

1. Simple Text-to-Speech

import { createVoiceTest } from '@juspay/vokal';

const voiceTest = createVoiceTest();

// Generate and save speech
const audioPath = await voiceTest.generateSpeech({
  text: "Welcome to Vokal! Your voice testing framework.",
  languageCode: 'en-US',
  voiceName: 'en-US-Neural2-F'
});

console.log('Audio saved to:', audioPath);

2. Voice Interaction with Background Audio

import { VoiceInteractionService } from '@juspay/vokal';

const voiceBot = new VoiceInteractionService();

// Run complete voice interaction
const result = await voiceBot.runVoiceInteraction(
  "What is your name?",
  {
    language: 'en-US',
    voice: 'en-US-Neural2-D',
    backgroundSound: 'office',
    backgroundVolume: 0.15
  }
);

console.log('User said:', result.transcript);
console.log('Confidence:', result.confidence);

3. Automated Voice Bot Testing

import { VoiceBotTestService } from '@juspay/vokal';

// Run test suite from configuration
const testService = VoiceBotTestService.create('./test-config.json');
const results = await testService.runTestSuite();

console.log(`βœ… Pass Rate: ${results.summary.passRate}%`);
console.log(`πŸ“Š Average Score: ${results.summary.averageScore}`);
console.log(`πŸ“ Results: ${results.summary.resultsFile}`);

🎯 Core Services

ServiceDescriptionUse Case
VoiceTestServiceText-to-Speech with background audio via NeurolinkGenerate test audio with realistic environments
VoiceInteractionServiceComplete TTS + Listen + STT pipelineFull conversation simulation
VoiceBotTestServiceAutomated test suite executionTest multiple scenarios with AI evaluation
AIComparisonServiceAI-powered response evaluationSemantic answer validation using Gemini
AudioMixerServiceBackground audio mixingAdd realistic noise to test scenarios
AudioRecordingServiceMicrophone recording via naudiodonCapture user responses
STTHandlerManagerProvider-agnostic STT managementUnified interface for multiple STT providers

πŸ–₯️ CLI Usage

Vokal includes a comprehensive command-line interface:

Generate Speech

# Basic TTS generation
vokal voice generate "Hello, world!" --voice en-US-Neural2-F --lang en-US

# With background audio
vokal voice generate "Welcome" --voice en-US-Neural2-D --lang en-US --bg cafe --bgvol 0.2 --play

# Advanced settings
vokal voice generate "Fast speech" --voice en-US-Neural2-A --rate 1.5 --pitch 5.0 --output speech.mp3

List Available Voices

# List all voices
vokal voices

# Filter by language
vokal voices en-US

# JSON output
vokal voices en-IN --format json

Background Sounds

# List available background sounds
vokal backgrounds

Test Audio Playback

# Test system audio capability
vokal test-audio

# Play an audio file
vokal play ./output.wav

Run Voice Bot Tests

# Create sample configuration
vokal test --save-sample

# Run test suite
vokal test ./config.json

# Run with specific provider and debug mode
vokal test --provider google-ai --debug --verbose

Show Examples

# Display comprehensive usage examples
vokal example

Run vokal --help for complete CLI documentation.

βš™οΈ Configuration

Test Suite Configuration

Create a JSON file to define your test scenarios:

{
  "metadata": {
    "name": "My Voice Bot Tests",
    "version": "1.0.0",
    "description": "Voice bot test suite"
  },
  "settings": {
    "defaultLanguage": "en-US",
    "defaultVoice": "en-US-Neural2-D",
    "recordingDuration": 10000,
    "passingScore": 0.7,
    "sttProvider": "google-ai",
    "ttsProvider": "google-ai",
    "aiProvider": "google-ai",
    "vadSettings": {
      "silenceThreshold": 0.02,
      "silenceDuration": 2000,
      "speechTimeout": 10000
    }
  },
  "questions": [
    {
      "id": "greeting",
      "question": "Hello! How can I help you?",
      "intent": "User greets and asks for help",
      "expectedElements": ["Greeting", "Request for assistance"],
      "sampleResponse": "Hi, I need help with my account"
    }
  ]
}

See the examples/sample-config.json for a complete example.

πŸ—οΈ Architecture

Vokal is built with a provider-agnostic architecture using the Handler pattern for extensibility.

Current Provider Support

Google Cloud (Default)

  • TTS: Google Cloud Text-to-Speech via Neurolink SDK
  • STT: Google Cloud Speech-to-Text via GoogleAISTTHandler
  • AI Evaluation: Google Gemini via AIComparisonService

Project Structure

vokal/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ services/          # Core voice services
β”‚   β”‚   β”œβ”€β”€ voice-test.ts           # TTS service with Neurolink
β”‚   β”‚   β”œβ”€β”€ voice-interaction.ts    # Complete pipeline orchestration
β”‚   β”‚   β”œβ”€β”€ voice-bot-test.ts       # Test suite execution
β”‚   β”‚   β”œβ”€β”€ ai-comparison.ts        # AI-powered evaluation
β”‚   β”‚   β”œβ”€β”€ audio-mixer.ts          # Background audio processing
β”‚   β”‚   └── audio-recording.ts      # Microphone capture
β”‚   β”œβ”€β”€ providers/         # Provider implementations
β”‚   β”‚   β”œβ”€β”€ google-ai-stt.handler.ts    # Google Cloud STT
β”‚   β”‚   β”œβ”€β”€ stt-handler-manager.ts      # Provider manager
β”‚   β”‚   └── stt-registry.ts             # Provider registry
β”‚   β”œβ”€β”€ types/             # TypeScript type definitions
β”‚   β”œβ”€β”€ utils/             # Utilities (logging, retry, validation, security)
β”‚   β”œβ”€β”€ constants/         # Audio configuration constants
β”‚   β”œβ”€β”€ errors/            # Custom error classes
β”‚   └── cli/               # Command-line interface
β”œβ”€β”€ examples/              # Example configurations
β”‚   β”œβ”€β”€ sample-config.json          # Test suite example
β”‚   β”œβ”€β”€ basic-example.js            # Basic usage template
β”‚   └── stt-handler-example.ts      # STT provider example
β”œβ”€β”€ assets/                # Background audio files
β”‚   β”œβ”€β”€ office-ambience.wav
β”‚   β”œβ”€β”€ cafe-ambience.wav
β”‚   β”œβ”€β”€ nature-sounds.wav
β”‚   β”œβ”€β”€ rain-light.wav
β”‚   β”œβ”€β”€ phone-static.wav
β”‚   └── crowd-distant.wav
β”œβ”€β”€ memory-bank/           # AI assistant context
└── docs/                  # Documentation (coming soon)

Provider Architecture

// Handler pattern for provider abstraction
interface STTHandler {
  startStreaming(config, onResult, onSpeechStart, onSpeechEnd, onError);
  stopStreaming();
}

// Register providers
STTHandlerManager.registerHandler('google-ai', GoogleAISTTHandler);

// Get provider instance
const handler = STTHandlerManager.getHandler('google-ai');

🎡 Background Sounds

Available background sound presets for realistic test environments:

SoundDescriptionRecommended VolumeUse Case
officeOffice ambience with typing and quiet chatter0.15Business applications, productivity bots
cafeCoffee shop atmosphere with ambient noise0.20Customer service, casual conversations
natureOutdoor setting with birds and gentle wind0.18Wellness apps, meditation guides
rainGentle rainfall ambience0.12Calming applications, sleep aids
phonePhone line static and connection noise0.08IVR testing, call center simulations
crowdDistant crowd noise and murmurs0.10Public space simulations, event apps

All audio files are located in the assets/ directory as WAV files.

πŸ›‘οΈ Security

Vokal follows security best practices:

  • βœ… Input validation and sanitization via validation.ts
  • βœ… Secure credential handling (no hardcoded secrets)
  • βœ… Command injection prevention in secure-exec.ts
  • βœ… Safe file path handling with path resolution
  • βœ… API key validation
  • βœ… Spawn-based command execution (no shell injection)

πŸ§ͺ Testing

# Build the project
pnpm run build

# Run linting
pnpm run lint

# Format code
pnpm run format

# Type checking
pnpm run typecheck

πŸ“¦ NPM Scripts

ScriptDescription
pnpm run buildBuild TypeScript to JavaScript (dist/)
pnpm run devBuild in watch mode
pnpm run cleanClean build directory
pnpm run lintLint code with ESLint
pnpm run formatFormat code with Prettier
pnpm run typecheckRun TypeScript type checking
pnpm run prebuildFormat and lint before build

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide for details.

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes using Conventional Commits
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

See CODE_OF_CONDUCT.md for community guidelines.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

Made with ❀️ by the Breeze Team

Keywords

voice-bot

FAQs

Package last updated on 12 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts