Skip to content

Commit

Permalink
inline alertNow into requestSpeech, see #37
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Feb 7, 2022
1 parent 24b8543 commit d55f48a
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions js/accessibility/voicing/voicingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,27 +239,6 @@ class VoicingManager extends Announcer {
queue.splice( index, 1 );
}

/**
* Ask the synth to speak an utterance now (synchronously).
* @private
*
* @param {SpeechSynthesisUtterance} speechSynthesisUtterance
*/
alertNow( speechSynthesisUtterance ) {
const synth = voicingManager.getSynth();
if ( synth ) {

// Signify to the utterance-queue that we cannot speak yet until this utterance has finished
this.readyToSpeak = false;

synth.speak( speechSynthesisUtterance );

if ( !this.hasSpoken ) {
this.hasSpoken = true;
}
}
}

/**
* @override
* @private
Expand Down Expand Up @@ -434,7 +413,14 @@ class VoicingManager extends Announcer {
// but the error event does. In this case signify that speaking has ended.
speechSynthUtterance.addEventListener( 'error', endListener );

this.alertNow( speechSynthUtterance );
// Signify to the utterance-queue that we cannot speak yet until this utterance has finished
this.readyToSpeak = false;

this.getSynth().speak( speechSynthUtterance );

if ( !this.hasSpoken ) {
this.hasSpoken = true;
}
}

/**
Expand Down

0 comments on commit d55f48a

Please sign in to comment.