Speech Provider - v0.1.4
    Preparing search index...

    Class ElevenLabsVoiceProvider

    A voice provider that uses the ElevenLabs API for high-quality text-to-speech. This provider requires an API key from ElevenLabs.

    // Basic usage
    const provider = createElevenLabsVoiceProvider("your-api-key");
    const voices = await provider.getVoices({ lang: "en-US", minVoices: 1 });
    const voice = voices[0];
    const utterance = voice.createUtterance("Hello, world!");
    utterance.start();

    // With volume normalization enabled
    const providerWithNormalization = createElevenLabsVoiceProvider("your-api-key", undefined, {
    normalizeVolume: true
    });
    const voices = await providerWithNormalization.getVoices({ lang: "en-US", minVoices: 1 });
    const voice = voices[0];
    const utterance = voice.createUtterance("Hello, world!");
    utterance.start(); // Audio will be played with normalized volume

    Implements

    Index

    Constructors

    • Create a new ElevenLabs voice provider.

      Parameters

      • apiKey: string

        Your ElevenLabs API key

      • baseUrl: string = ELEVEN_LABS_BASE_URL

        The base URL for the ElevenLabs API (defaults to the official API)

      • options: {
            cacheMaxAge?: null | number;
            normalizeVolume?: boolean;
            printVoiceProperties?: boolean;
            validateResponses?: boolean;
        } = {}

        Additional options for the provider

        • OptionalcacheMaxAge?: null | number

          Maximum age of cached responses in seconds (default: 1 hour). Set to null to disable caching.

        • OptionalnormalizeVolume?: boolean

          Whether to automatically normalize audio volume during playback (default: false)

        • OptionalprintVoiceProperties?: boolean

          Whether to print voice properties for debugging

        • OptionalvalidateResponses?: boolean

          Whether to validate API responses against the schema

      Returns ElevenLabsVoiceProvider

    Properties

    apiKey: string
    cacheMaxAge: null | number
    name: string = "ElevenLabs"

    The name of the voice provider

    Accessors

    • get normalizeVolume(): boolean

      Get the current volume normalization setting

      Returns boolean

    • set normalizeVolume(value: boolean): void

      Set the volume normalization setting

      Parameters

      • value: boolean

        Whether to normalize audio volume

      Returns void

    Methods

    • Get the default voice for a given language code.

      Parameters

      • options: { lang: string }

        The options for getting the default voice

        • lang: string

          The language code to match (e.g., "en-US")

      Returns Promise<null | Voice>

      A promise that resolves to the first available voice or null if none is available

    • Get available voices for a given language code.

      Parameters

      • options: { lang: string; minVoices: number }

        The options for getting voices

        • lang: string

          The language code to match (e.g., "en-US")

        • minVoices: number

          The minimum number of voices to return

      Returns Promise<Voice[]>

      A promise that resolves to an array of ElevenLabs voices