Quick Start
Basic Usage
Section titled “Basic Usage”Drop in the script tag or install from npm — both reach the same API:
<!DOCTYPE html><html> <head> <script src="https://cdn.responsivevoice.org/sdk/latest/responsivevoice.js"></script> </head> <body> <button onclick="speak()">Speak</button>
<script> responsiveVoice.init({ apiKey: 'YOUR_API_KEY' });
function speak() { responsiveVoice.speak('Hello from the browser!'); } </script> </body></html>npm install @responsivevoice/core# or: pnpm add @responsivevoice/core / yarn add @responsivevoice/coreimport { getResponsiveVoice } from '@responsivevoice/core';
const rv = await getResponsiveVoice({ apiKey: 'YOUR_API_KEY' });
rv.speak('Hello, world!');Voice Selection
Section titled “Voice Selection”// Get available voicesconst voices = rv.getVoices();console.log(voices);
// Speak with a specific voicerv.speak('Hello', 'UK English Female');rv.speak('Hello', 'US English Male');rv.speak('Hallo', 'Deutsch Female');Playback Control
Section titled “Playback Control”// Pause speechrv.pause();
// Resume speechrv.resume();
// Cancel speechrv.cancel();
// Check if speakingif (rv.isPlaying()) { console.log('Currently speaking');}Events
Section titled “Events”// Per-call callbacks — bound to this speak() callrv.speak('Hello with events', 'UK English Female', { onstart: () => console.log('Speech started'), onend: () => console.log('Speech ended'), onerror: (error) => console.error('Speech error:', error), onboundary: (charIndex, name) => console.log('Word boundary:', charIndex, name),});
// Global events — fire across every speak() call (pause/resume live here)rv.addEventListener('OnPause', () => console.log('Speech paused'));rv.addEventListener('OnResume', () => console.log('Speech resumed'));