Skip to content

Announcer

Overview

Abstract base class for the type that wires into an UtteranceQueue to announce Utterances.

@author Michael Kauzmann (PhET Interactive Simulations)

Class Announcer

import { Announcer } from 'scenerystack/utterance-queue';

Constructor

new Announcer( providedOptions? : AnnouncerOptions )

Instance Methods

announce( announceText : ResolvedResponse, utterance : Utterance, providedOptions? : AnnouncerAnnounceOptions )

Announce an alert, setting textContent to an aria-live element.

@param announceText - The string that was formulated from the utterance @param utterance - Utterance with content to announce @param [providedOptions] - specify support for options particular to this announcer's features.

cancelUtterance( utterance : Utterance )

Cancel announcement if this Announcer is currently announcing the Utterance. Does nothing to queued Utterances. The announcer needs to implement cancellation of speech.

cancel()

’ * Cancel announcement of any Utterance that is being spoken. The announcer needs to implement cancellation of speech.

shouldUtteranceCancelOther( utterance : Utterance, utteranceToCancel : Utterance ) : boolean

Determine if one utterance should cancel another. Default behavior for this superclass is to cancel when the new Utterance is of higher priority. But subclasses may re-implement this function if it has special logic or announcerOptions that override this behavior.

onUtterancePriorityChange( utterance : Utterance )

Intended to be overridden by subtypes if necessary as a way to order the queue if there is announcer specific logic.

Instance Properties

respectResponseCollectorProperties : boolean

(readonly)

When an Utterance to be announced provided an alert in ResponsePacket-form, whether or not to listen to the current values of responseCollector Properties, or to just combine all pieces of it no matter.

readyToAnnounce

A flag that indicates to an UtteranceQueue that this Announcer is ready to speak the next Utterance.

hasSpoken

A flag that indicates whether this announcer has successfully spoken at least once.

announcementCompleteEmitter : TEmitter<[ Utterance, ResolvedResponse ]>

(readonly)

Emits an event when this Announcer is finished with an Utterance. It is up to the Announcer subclass to emit this because different speech technologies may have different APIs to determine when speaking is finished.

Static Properties

AnnouncerIO : IOType

Type AnnouncerAnnounceOptions

Options for the announce method

import type { AnnouncerAnnounceOptions } from 'scenerystack/utterance-queue';

EmptySelfOptions

Type AnnouncerOptions

import type { AnnouncerOptions } from 'scenerystack/utterance-queue';

Source Code

See the source for Announcer.ts in the utterance-queue repository.