Skip to content

Commit

Permalink
add a function to get prioritized voices for voicingManager, see #1282
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Sep 16, 2021
1 parent 5d776f8 commit e8a0638
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions js/accessibility/voicing/voicingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ class VoicingManager extends Announcer {
this.voicesChangedEmitter.emit();
}

/**
* Returns an array of voices where "Google" voices are prioritized. Google voices generally sound the best so they
* can be promoted if desired. Returns an array of SpeechSynthesisVoices where "Google" voices are at the top of the
* list.
* @public
*/
getVoicesWithGooglePrioritized() {
assert && assert( this.initialized, 'No voices available until the voicingManager is initialized' );
assert && assert( this.voices.length > 0, 'No voices available to provided a prioritized list.' );

return this.voices.slice( 0 ).sort( ( a, b ) => {
return b.name.includes( 'Google' ) ? 1 : -1;
} );
}

/**
* Implements announce so the voicingManager can be a source of output for utteranceQueue.
* @public
Expand Down

0 comments on commit e8a0638

Please sign in to comment.