Browser talk to user press key

Asked

Viewed 308 times

3

I’m doing a project aimed at blind people, I wanted to know if there is any way to make the browser speak by voice "Hit the ENTER key to talk", I’m using Speechrecognition to recognize the talk of the user, but I haven’t found anywhere that I’ve researched a way to make the browser talk.

  • 2

    I had started a similar project and I used google voices in mp3 format, but I abandoned the project because the voices didn’t get very good. : / But you can use the <audio> tag to do this if you have the mp3 with the voices.

  • Need to check if it’s compatible with all browsers, but has an API for voice synth (text to Speech): Web Speech API - Firefox and Introduction to the Speech

1 answer

2


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

A good reading can be obtained in: https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API

As an Example of 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");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.