Browser talk to user press key

3

I'm doing a blind person-oriented project, I was wondering if there is any way to make the browser speak by voice "Press the ENTER key to speak", I'm using SpeechRecognition to recognize the user's talk, but I have not found any site that I researched a way to make the browser speak.

    
asked by anonymous 19.05.2018 / 22:35

1 answer

2

In the same api 'Web Speech API' that is using 'Speech recognition' there is also 'Speech synthesis',

A good reading can be obtained at: link

As an example implementation:

function falar(texto){
  var text  = new SpeechSynthesisUtterance();
      text.lang = "pt-BR";
      text.text = texto;
    
        //voices = window.speechSynthesis.getVoices();
      text['voiceURI'] = 'Google português do Brasil'; //discovered after dumping getVoices()
      text.lang = "pt-BR";
      text['localService'] = true;
      
  speechSynthesis.speak(text);
}

falar("Aperte a tecla Enter para falar");
    
31.05.2018 / 06:06