text to speech js

116

javascript voice reader -

var msg = new SpeechSynthesisUtterance();
msg.text = "Hello World";
window.speechSynthesis.speak(msg);

text to Speech in javascript code -

const speak = (msg) => {
  const sp = new SpeechSynthesisUtterance(msg);
  [sp.voice] = speechSynthesis.getVoices();
  speechSynthesis.speak(sp);
}

speak('Hi, Welcome to Javascript Text to Speech. It is really awesome.');

speech to text in js -

function readOutLoud(message) {
  var speech = new SpeechSynthesisUtterance();

  // Set the text and voice attributes.
  speech.text = message;
  speech.volume = 1;
  speech.rate = 1;
  speech.pitch = 1;

  window.speechSynthesis.speak(speech);
}

speech to text in js -

$('#start-record-btn').on('click', function(e) {
  recognition.start();
});

Comments

Submit
0 Comments