eSpeak-ng.js

Browser-based text-to-speech using eSpeak-ng. No servers, no APIs, pure JavaScript.

🎯 Pure JavaScript

No frameworks needed

🔊 Clear Speech

eSpeak-ng synthesis

🌍 100+ Languages

All voices included

⚡ Runs Offline

No server required

📦 What's Included

Quick Start

// Initialize TTS
const tts = new SimpleTTS();

// Generate and play speech
tts.onReady(() => {
  tts.speak('Hello world!', (audioData, sampleRate) => {
    SimpleTTS.playAudioData(audioData, sampleRate);
  });
});
Simple & Effective: Get started with text-to-speech in minutes!
Try Demo Audio Options View on GitHub

Advanced Usage

// Speak with options
tts.speak('Hello world!', {
  voice: 'en',        // Voice ID
  rate: 200,          // Speed (80-450)
  pitch: 75,          // Pitch (0-100)
  volume: 1.2         // Volume (0-2.0)
}, (audioData, sampleRate) => {
  SimpleTTS.playAudioData(audioData, sampleRate);
});

// List available voices
tts.getVoices(voices => {
  console.log(voices);
});

Using the Original API

// Direct eSpeak-ng access
const espeak = new eSpeakNG('js/espeakng.worker.js', () => {
  espeak.set_voice('en');
  espeak.synthesize('Hello', (samples, events) => {
    // Raw PCM samples
  });
});

Files Needed

  1. espeakng-simple.js - Simple wrapper API
  2. espeakng.worker.js - Web Worker
  3. espeakng.worker.data - Voice data

License: GPLv3