Instantly share code, notes, and snippets.

Embed
What would you like to do?
Speech it
var current = null;
var originalStyle = '';
document.onmouseover = function(e) {
current = document.elementFromPoint(e.clientX, e.clientY);
originalStyle = current.style;
current.style = 'background: rgba(255, 0, 0, 0.2)';
if (window.speechSynthesis) {
var synth = speechSynthesis;
var message = current.textContent;
var utter = new SpeechSynthesisUtterance(message);
utter.lang = "ja-JP";
current.onmouseup = function(ev) {
ev.stopPropagation();
synth.speak(utter);
}
}
}
document.onmouseout = function(e) {
current.style = originalStyle;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment