hammerspoon2-docs
    Preparing search index...

    Class HSSpeaker

    A text-to-speech speaker, with its own queue of speech. Create one with hs.speech.create().

    Text passed to speak() is queued, and spoken after anything already queued. The voice, rate, pitch, volume and prefersAssistiveTechnologySettings properties apply to speech queued after they are set, and can be overridden for a single utterance with speak()'s options.

    Index
    identifier: string

    A unique identifier for this speaker.

    isPaused: boolean

    Whether this speaker has been paused with pause().

    isSpeaking: boolean

    Whether this speaker is speaking, paused or has speech queued.

    pitch: number

    The pitch multiplier, from 0.5 to 2.0. Defaults to 1.0.

    prefersAssistiveTechnologySettings: boolean

    Whether to speak with the settings of a running assistive technology, such as VoiceOver's voice and rate, instead of this speaker's voice, rate, pitch and volume. Defaults to false. Has no effect when no assistive technology is running.

    rate: number

    The speaking rate, from 0.0 (slowest) to 1.0 (fastest). Defaults to 0.5, the normal rate.

    voice: string | null

    The identifier of the voice this speaker uses, or null for the system's default voice. Assign a voice's identifier or name (see hs.speech.voices()) to change it, or null to go back to the default. An unknown voice is ignored, and logged.

    volume: number

    The volume, from 0.0 (silent) to 1.0 (full volume). Defaults to 1.0.

    • Pauses speech, which can be continued with resume(). Queued speech stays queued.

      Parameters

      • OptionalatWordBoundary: boolean

        If true, finishes the current word before pausing. Defaults to false, which pauses immediately.

      Returns HSSpeaker

      This speaker, for chaining.

    • Continues speech paused by pause().

      Returns HSSpeaker

      This speaker, for chaining.

    • Queues text to be spoken. Speech queued by earlier calls is spoken first.

      Parameters

      • text: string

        The text to speak.

      • Optionaloptions: HSSpeechOptions

        How to speak this text, overriding the speaker's properties.

      Returns Promise<boolean>

      Resolves to true when the text has been spoken, or false if it was interrupted by stop(). Rejects if an option is invalid, such as an unknown voice

      A speaker with speech queued keeps speaking even if you don't keep a reference to it

    • Stops speaking immediately, discarding any queued speech. The Promises of the interrupted utterances resolve to false.

      Returns HSSpeaker

      This speaker, for chaining.