Main entry point for the speech-provider library. This module exports the core interfaces and implementations for text-to-speech functionality. It provides a unified interface for both browser-based speech synthesis and ElevenLabs voices.
import { getVoiceProvider } from 'speech-provider';// Use browser voices onlyconst provider = getVoiceProvider({});// Use Eleven Labs voices if API key is availableconst provider = getVoiceProvider({ elevenLabs: 'your-api-key' });// Get voices for a specific languageconst voices = await provider.getVoices({ lang: 'en-US', minVoices: 1 });// Create and play an utteranceif (voices.length > 0) { const utterance = voices[0].createUtterance('Hello, world!'); utterance.start();} Copy
import { getVoiceProvider } from 'speech-provider';// Use browser voices onlyconst provider = getVoiceProvider({});// Use Eleven Labs voices if API key is availableconst provider = getVoiceProvider({ elevenLabs: 'your-api-key' });// Get voices for a specific languageconst voices = await provider.getVoices({ lang: 'en-US', minVoices: 1 });// Create and play an utteranceif (voices.length > 0) { const utterance = voices[0].createUtterance('Hello, world!'); utterance.start();}
Main entry point for the speech-provider library. This module exports the core interfaces and implementations for text-to-speech functionality. It provides a unified interface for both browser-based speech synthesis and ElevenLabs voices.
Example