https://github.com/lookang/codesforejss/blob/master/function%20speech%20()
example
https://iwant2study.org/ospsg/index.php/855
You may modify the code accordingly
// add the speech(option) on a play button for iOS// copy this custom function
function speech (option) {try { // allow code to run in Student Learning Spacevar parent = parent.cordova;if(parent) { // check it is running in Android or iOSparent.TTS.speak(option, function () {}, function (reason) {});}}catch(e) {var parent=false;var msg = new SpeechSynthesisUtterance(option);//https://stackoverflow.com/questions/43983845/speechsynthesis-api-for-chinese-firefox// Set the text.//msg.text = option;//https://forums.developer.apple.com/message/323564#323564msg.voice = speechSynthesis.getVoices().filter(function(voice) { return voice.name == 'Ting-Ting'; })[0];msg.lang = 'zh-CH'; // need for android//https://flaviocopes.com/speech-synthesis-api///debug//console.log(`Voices #: ${speechSynthesis.getVoices().length}`)//speechSynthesis.getVoices().forEach(voice => {// console.log(voice.name, voice.lang)//})//debug// Queue this utterance.window.speechSynthesis.speak(msg);}}
No comments:
Post a Comment