Closed jwonderly closed 6 years ago
Hi @jwonderly, Thank you for working on this! And apologies for taking some time to review.
Overall looks good, but there's one thing I hope you could change before I merge this into master. Currently this will break in browsers that don't support the Speech Synthesis API. I'd like it to check for the support for speechSynthesis
and SpeechSynthesisUtterance` before using those features. While JSAV doesn't have a list of officially supported browsers, there's no need for this feature to break older browsers. Could you change the code to check for these?
I'll also comment on a few other things that could be changed but don't need to.
Hi Ville, Thanks for the feedback! Sorry it's taken so long for me to address your comments; I've had a busy week.
Here's a summary of the changes I made in response to your comments:
soundSettings()
is no longer a JSAV extension; since it just creates the button element, it shouldn't be called outside the init()
function anyway.JSAV_OPTIONS.narration.replacements
. These global defaults are initially set in core.js at the bottom of the file. If a developer wants to extend the default list for a single visualization, then they can do:
var avOptions = {
narration: {
appendReplacements = [
{searchValue: /\\theta/gi, replaceValue: 'theta'}
]
}
};
var av = new JSAV('myAV', avOptions);
If a developer wants to override the default list, they can do:
var avOptions = {
narration: {
overrideReplacements = [
{searchValue: /\\theta/gi, replaceValue: 'theta'}
]
}
};
var av = new JSAV('myAV', avOptions);
I chose to do it this way because when providing an array of length N for avOptions.narration.replacements
, jQuery's extend method simply overwrites the first N elements in JSAV_OPTIONS.narration.replacements
JSAV_OPTONS.narration.enabled = true
JSAV.ext.textToSpeech()
.options.lang
. Note that since the speechSynthesis API uses IETF language codes (which includes a region specifier for languages with regional variations) I also added JSAV_OPTIONS.narration.langMap
which defines which regional variation should be used for such languages. This mapping can be modified by the developer.If you find these changes acceptable, I will update the documentation.
Looks really good @jwonderly, thank you for making the changes! And apologies for taking so long, I thought I had already merged this.
Adds support for narration of calls to
umsg()
for slideshows, making use of the SpeechSynthesis functionality of the user's browser.Narration is disabled by default. It can be enabled globally by setting
JSAV_OPTIONS.narrationEnabled = true
, and it can be enabled/disabled for an individual slideshow.Enabling narration will add a button to the left of the settings button that users can click to toggle narration for the slideshow.
When a user clicks the narration button, an event is logged. If clicking the button turns on narration, then
jsav-narration-on
is logged. If clicking the button turns off narration, thenjsav-narration-off
is logged.The vast majority of the work for this feature was done by @ehsanelgendi.