A Pen by guyfedwards

Thumbnail
This awesome code was written by guyfedwards, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright guyfedwards ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  guyfedwards</title>
  
  
  
  
  
</head>

<body>

  <button>Speak to me</button>
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/guyfedwards/a-pen-by-guyfedwards-aBAkC */

function speak(){
  
 

  var msg = new SpeechSynthesisUtterance('Tally ho old chap, bloody good show');
  
  /*msg.voice = speechSynthesis.getVoices().filter(function(voice) { 
    return voie.name == 'Google UK English Male'; 
  })[0];*/
  
  var voices = window.speechSynthesis.getVoices();
  msg.default = false;
  msg.voice = voices[8]; 
  msg.voiceURI = 'native';

  speechSynthesis.speak(msg);
  
}


document.querySelector('button').addEventListener("click", speak, false);

Comments