You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SpeechSynthesis module supports various voices.
In JS, we can get the list of voices as speechSynthesis.getVoices():
# Via ChatGPT# THe complexity arises becuase Chrom does not simply return the voices...fromIPython.displayimportJavascript, displayimportjsonimporttime# JavaScript code to get the list of SpeechSynthesis voicesjs_code="""var waitForVoices = new Promise(function(resolve, reject) { var voices = window.speechSynthesis.getVoices(); if (voices.length !== 0) { resolve(voices); } else { window.speechSynthesis.onvoiceschanged = function() { voices = window.speechSynthesis.getVoices(); resolve(voices); }; }});waitForVoices.then(function(voices) { var voices_list = voices.map(function(voice) { return { name: voice.name, lang: voice.lang, default: voice.default, localService: voice.localService }; }); var voices_list_str = JSON.stringify(voices_list); # In simple classic notebook days, propagate the value back to the IPython environment #IPython.notebook.kernel.execute(`voices_list = ${voices_list_str}`); alert(voices_list_str)});"""# Execute the JavaScript codedisplay(Javascript(js_code))
# But i'm not sure if there is a simple hack for this in JupyterLab?
To change the voice, we then call SpeechSynthesisUtterance.voice= but this needs to match one of the names in the voices list. Which may be different on different browsers? (Or is there a common set of voice names across browsers?)
The text was updated successfully, but these errors were encountered:
The
SpeechSynthesis
module supports various voices.In JS, we can get the list of voices as
speechSynthesis.getVoices()
:To change the voice, we then call
SpeechSynthesisUtterance.voice=
but this needs to match one of the names in the voices list. Which may be different on different browsers? (Or is there a common set of voice names across browsers?)The text was updated successfully, but these errors were encountered: