Drafts Script Reference
    Preparing search index...

    Class Speech

    Supports text-to-speech operations to read aloud text content using system speech synthesis APIs. Speech objects cannot be instantiated, but are accessed via a single global speech object.

    // read text 
    speech.speak("Hello World")

    // read with options
    let voices = speech.voices("it-IT")
    speech.speak("Hello World", {
    "voice": voices[0],
    "rate": "fast",
    "autoClose": false
    })

    Note: Speech features are available only on iOS 18 and macOS 15 and greater.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    allVoices: SpeechVoice[]

    Array of available voices on the device. Can be used to locate available voices for different languages.

    Methods

    • Executes the shell script.

      Parameters

      • text: string
      • settings: { autoClose?: boolean; autoStart?: boolean; rate?: string; voice?: SpeechVoice }

        An object containing optional configuration values.

        • OptionalautoClose?: boolean

          If enabled, auto-close the speech interface and continue when audio is finished. Default: true

        • OptionalautoStart?: boolean

          If enabled, auto-start the speech. Default: true

        • Optionalrate?: string

          Rate of speech, supported values "slow", "normal", "fast"

        • Optionalvoice?: SpeechVoice

          A voice to pre-select. Optional, and defaults to user's last selected voice.

      Returns boolean

      true if the script was executed without error, false if not.

    • List voices available for a specific language/locale.

      Parameters

      • language: string

        BCP 47 style locale identifier for the language to filter voices by, similar to en-US (US English) or it-IT (Italian Italian).

      Returns SpeechVoice[]

      Array of available voices of the specified locale.