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

whisper-nodejs-wrapper

v1.0.0

Published

Node.js wrapper for OpenAI Whisper speech recognition with TypeScript support

Readme

Whisper for Node.js

A Node.js wrapper for OpenAI's Whisper speech recognition model. This package provides an easy-to-use interface for transcribing audio files with word-level timestamps.

Features

  • 🎯 Simple async/await API
  • 🔄 Automatic retry with exponential backoff
  • 📝 Word-level timestamps
  • 🌍 Multi-language support
  • 🔧 TypeScript support
  • 🚀 Automatic dependency installation
  • 💻 CPU and GPU support

Installation

npm install @whisper/nodejs

The package will automatically create a Python virtual environment and install dependencies during the npm install process. This avoids conflicts with system Python packages.

Quick Start

const { whisper } = require('@whisper/nodejs');

// Basic transcription
const result = await whisper.transcribe('audio.mp3');
console.log(result.text);

// With options
const result = await whisper.transcribe('audio.mp3', {
  language: 'en',
  modelSize: 'base'
});

TypeScript Usage

import { WhisperTranscriber, WhisperOptions, WhisperResult } from '@whisper/nodejs';

const transcriber = new WhisperTranscriber();

const options: WhisperOptions = {
  language: 'en',
  modelSize: 'base',
  verbose: true
};

const result: WhisperResult = await transcriber.transcribe('audio.mp3', options);

// Access word-level timestamps
result.segments.forEach(segment => {
  console.log(`[${segment.start}-${segment.end}] ${segment.text}`);
  
  segment.words?.forEach(word => {
    console.log(`  ${word.text} (${word.start}-${word.end})`);
  });
});

API Reference

WhisperTranscriber

Constructor

new WhisperTranscriber(options?: { pythonPath?: string })
  • pythonPath (optional): Path to Python executable. Auto-detects if not provided.

Methods

transcribe(audioPath: string, options?: WhisperOptions): Promise<WhisperResult>

Transcribe an audio file.

Parameters:

  • audioPath: Path to the audio file
  • options: Transcription options
transcribeWithRetry(audioPath: string, options?: WhisperOptions, maxRetries?: number): Promise<WhisperResult>

Transcribe with automatic retry on failure.

Parameters:

  • audioPath: Path to the audio file
  • options: Transcription options
  • maxRetries: Maximum number of retry attempts (default: 3)
initialize(): Promise<void>

Initialize and check/install dependencies.

checkDependencies(): Promise<boolean>

Check if Python dependencies are installed.

Types

WhisperOptions

interface WhisperOptions {
  language?: string;           // Language code (e.g., 'en', 'es', 'fr')
  modelSize?: 'tiny' | 'base' | 'small' | 'medium' | 'large';
  pythonPath?: string;         // Custom Python path
  cpuOnly?: boolean;           // Force CPU-only mode
  verbose?: boolean;           // Enable verbose logging
}

WhisperResult

interface WhisperResult {
  text: string;                // Full transcribed text
  segments: WhisperSegment[];  // Time-aligned segments
  language?: string;           // Detected language
  duration?: number;           // Total audio duration
}

WhisperSegment

interface WhisperSegment {
  text: string;                // Segment text
  start: number;               // Start time in seconds
  end: number;                 // End time in seconds
  words?: WhisperWord[];       // Word-level timestamps
}

Model Sizes

| Model | Parameters | English-only | Multilingual | Required VRAM | Relative Speed | |-------|------------|--------------|--------------|---------------|----------------| | tiny | 39 M | ✓ | ✓ | ~1 GB | ~32x | | base | 74 M | ✓ | ✓ | ~1 GB | ~16x | | small | 244 M | ✓ | ✓ | ~2 GB | ~6x | | medium| 769 M | ✓ | ✓ | ~5 GB | ~2x | | large | 1550 M | ✗ | ✓ | ~10 GB | 1x |

Language Support

Supports 100+ languages including:

  • English (en)
  • Spanish (es)
  • French (fr)
  • German (de)
  • Italian (it)
  • Portuguese (pt)
  • Russian (ru)
  • Chinese (zh)
  • Japanese (ja)
  • Korean (ko)
  • Vietnamese (vi)
  • And many more...

Environment Variables

  • WHISPER_CPU_ONLY: Set to "1" to force CPU-only mode
  • WHISPER_VERBOSE: Set to "true" for verbose logging
  • SKIP_WHISPER_SETUP: Set to "true" to skip automatic setup

Requirements

  • Node.js >= 16.0.0
  • Python >= 3.7
  • FFmpeg (for audio processing)

Troubleshooting

Python not found

Make sure Python 3.7+ is installed and available in PATH:

python3 --version

Manual dependency installation

If automatic installation fails:

pip install openai-whisper torch

GPU Support

For GPU acceleration, install CUDA-enabled PyTorch:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.