Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
window.SpeechRecognition=window.webkitSpeechRecognition||window.SpeechRecognition;letfinalTranscript='';letrecognition=newwindow.SpeechRecognition();recognition.interimResults=true;recognition.maxAlternatives=10;recognition.continuous=true;recognition.onresult=(event)=>{letinterimTranscript='';for(leti=event.resultIndex,len=event.results.length;i<len;i++){lettranscript=event.results[i][0].transcript;if(event.results[i].isFinal){finalTranscript+=transcript;//alert(finalTranscript);if(finalTranscript=="main page"){window.location.href="https://en.wikipedia.org/wiki/Main_Page";}if(finalTranscript=="contents"){window.location.href="https://en.wikipedia.org/wiki/Wikipedia:Contents";}if(finalTranscript=="current events"){window.location.href="https://en.wikipedia.org/wiki/Portal:Current_events";}if(finalTranscript=="random page"||finalTranscript=="random"){window.location.href="https://en.wikipedia.org/wiki/Special:Random";}if(finalTranscript=="about wikipedia"||finalTranscript=="about"){window.location.href="https://en.wikipedia.org/wiki/Wikipedia:About";}if(finalTranscript=="contact us"||finalTranscript=="contact"){window.location.href="https://en.wikipedia.org/wiki/Wikipedia:Contact_Us";}if(finalTranscript=="donate"){window.location.href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en";}if(finalTranscript=="pause"||finalTranscript=="stop"){location.reload();speechSynthesis.cancel();}if(finalTranscript=="read"){funcread();}}else{interimTranscript+=transcript;}}document.querySelector('body').innerHTML=finalTranscript+'<i style="color:#ddd;">'+interimTranscript+'</>';};recognition.start();//alert("Unfortunately, your browser does not support speech recognition");// REMEMBER TO CHANGE THIS TO TTS//alert("Does this work?");functionfuncread(){if(window.speechSynthesis.getVoices().length===0){window.speechSynthesis.addEventListener('voiceschanged',function(){textToSpeech();});}else{// languages list available, no need to waittextToSpeech();}}functiontextToSpeech(){// get all voices that browser offersvaravailable_voices=window.speechSynthesis.getVoices();// this will hold an english voicevarenglish_voice='';// find voice by language locale "en-US"// if not then select the first voicefor(vari=0;i<available_voices.length;i++){if(available_voices[i].lang==='en-US'){english_voice=available_voices[i];break;}}if(english_voice==='')english_voice=available_voices[0];// new SpeechSynthesisUtterance objectvarpagecontent=document.getElementById("mw-content-text").textContent;varutter=newSpeechSynthesisUtterance();utter.rate=1;utter.pitch=0.5;utter.text=pagecontent;utter.voice=english_voice;// event after text has been spokenutter.onend=function(){//alert('Speech has finished');};// speaklocation.reload();window.speechSynthesis.speak(utter);}