Skip to content

Instantly share code, notes, and snippets.

@greengiraffe
Created February 27, 2018 10:15
Show Gist options
  • Save greengiraffe/0cef51852a0417b047e027c7274ca6ae to your computer and use it in GitHub Desktop.
Save greengiraffe/0cef51852a0417b047e027c7274ca6ae to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/natayar
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
speechSynthesis.cancel();
const utterance = new SpeechSynthesisUtterance();
const testString = "Sobald das Wort E-Mail auftaucht, liefert das onboundary-Event falsche Werte."
utterance.text = testString;
utterance.pitch = 1;
utterance.rate = 0.5;
utterance.volume = 1;
utterance.voice = speechSynthesis.getVoices().find(v => v.lang === 'de-DE');
utterance.onboundary = event => {
console.log("charIndex: " + event.charIndex);
console.log("char: " + testString.slice(event.charIndex, event.charIndex + 1))
}
speechSynthesis.speak(utterance)
</script>
<script id="jsbin-source-javascript" type="text/javascript">speechSynthesis.cancel();
const utterance = new SpeechSynthesisUtterance();
const testString = "Sobald das Wort E-Mail auftaucht, liefert das onboundary-Event falsche Werte."
utterance.text = testString;
utterance.pitch = 1;
utterance.rate = 0.5;
utterance.volume = 1;
utterance.voice = speechSynthesis.getVoices().find(v => v.lang === 'de-DE');
utterance.onboundary = event => {
console.log("charIndex: " + event.charIndex);
console.log("char: " + testString.slice(event.charIndex, event.charIndex + 1))
}
speechSynthesis.speak(utterance)
</script></body>
</html>
speechSynthesis.cancel();
const utterance = new SpeechSynthesisUtterance();
const testString = "Sobald das Wort E-Mail auftaucht, liefert das onboundary-Event falsche Werte."
utterance.text = testString;
utterance.pitch = 1;
utterance.rate = 0.5;
utterance.volume = 1;
utterance.voice = speechSynthesis.getVoices().find(v => v.lang === 'de-DE');
utterance.onboundary = event => {
console.log("charIndex: " + event.charIndex);
console.log("char: " + testString.slice(event.charIndex, event.charIndex + 1))
}
speechSynthesis.speak(utterance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment