Last active
August 29, 2015 14:23
-
-
Save reeonce/13ccc1788cab8dae2321 to your computer and use it in GitHub Desktop.
speechSynthesis js, it is working on Safari
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function speech() { | |
| var voices = window.speechSynthesis.getVoices(); | |
| var zhVoices = voices.filter(function (ele) { return ele.lang.match(/zh.*/i); }); | |
| var foo = new SpeechSynthesisUtterance('世界你好!'); | |
| foo.lang = 'zh-CN'; | |
| foo.voice = zhVoices[0]; | |
| foo.volume = 1; // 0 to 1 | |
| foo.rate = 1; // 0.1 to 10 | |
| foo.pitch = 1.5; //0 to 2 | |
| foo.voiceURI = 'native'; | |
| window.speechSynthesis.speak(foo); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment