jetlag2d
    Preparing search index...

    Class TextToSpeechDevice

    TextToSpeechDevice provides speech synthesis (text-to-speech) via the browser's SpeechSynthesis API. It does not queue or track individual utterances itself; the browser's own utterance queue handles that.

    Index
    supported: boolean = ...

    True if this browser supports speech synthesis at all

    • Get the list of voices available for speech synthesis. On some browsers, this list is empty until the browser fires its voiceschanged event, so code that needs voices immediately on page load may need to also listen for that event directly.

      Returns SpeechSynthesisVoice[]

    • Speak some text out loud. Utterances are queued by the browser, so calling this while something is already speaking will not interrupt it; call stop() first if you want to interrupt.

      Parameters

      • cfg: {
            lang?: string;
            onDone?: () => void;
            onError?: (err: SpeechSynthesisErrorEvent) => void;
            pitch?: number;
            rate?: number;
            text: string;
            voice?: SpeechSynthesisVoice;
            volume?: number;
        }
        • Optionallang?: string

          A BCP 47 language tag (e.g. "en-US"), if you want to override the voice's default language

        • OptionalonDone?: () => void

          Code to run once this utterance finishes speaking

        • OptionalonError?: (err: SpeechSynthesisErrorEvent) => void

          Code to run if this utterance fails to speak

        • Optionalpitch?: number

          Voice pitch, in [0, 2]. Defaults to 1 (normal pitch)

        • Optionalrate?: number

          Speaking rate, in [0.1, 10]. Defaults to 1 (normal speed)

        • text: string

          The text to speak

        • Optionalvoice?: SpeechSynthesisVoice

          A specific voice to use, from getVoices()

        • Optionalvolume?: number

          Volume, in [0, 1]. Defaults to 1 (full volume)

      Returns void