Licensed under CC0 (https://creativecommons.org/publicdomain/zero/1.0/deed)
document.addEventListener('onEventReceived', function(obj) { | |
const synth = window.speechSynthesis; | |
if (obj.detail.command === 'PRIVMSG') { | |
var utter = new SpeechSynthesisUtterance(obj.detail.body); | |
utter.voice = synth.getVoices().filter(v => v.lang === 'ja-JP')[0]; | |
utter.rate = 1; | |
utter.pitch = 1; | |
synth.speak(utter); | |
} | |
}); |
This comment has been minimized.
This comment has been minimized.
I release above code under CC0. |
This comment has been minimized.
This comment has been minimized.
I see. Thank you. |
This comment has been minimized.
This comment has been minimized.
If it doesn't work use the following instead; window.addEventListener('message', function(e) {
const data = e.data || {};
if (data.type !== 'item')
return;
const message = data.message || {};
const obj = { detail: { command: message.command, body: message.body, from: message.from }};
const synth = window.speechSynthesis;
if (obj.detail.command === 'PRIVMSG') {
var utter = new SpeechSynthesisUtterance(obj.detail.body);
utter.voice = synth.getVoices().filter(v => v.lang === 'ja-JP')[0];
utter.rate = 1;
utter.pitch = 1;
synth.speak(utter);
}
}); EDIT: Applied above to the gist. Previous version can be seen at https://gist.github.com/mecab/a14a761d76a9136a96466b0fc4c2acc3/e93bca2e683b30ca2ccbb03702972be20734012f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
What kind of license is applied for this code?