text to speech with javascript code example
Example 1: how to do text to speech in javascript
var msg = new SpeechSynthesisUtterance();
msg.text = "Hello World";
window.speechSynthesis.speak(msg);
Example 2: speech to text in js
function readOutLoud(message) {
var speech = new SpeechSynthesisUtterance();
speech.text = message;
speech.volume = 1;
speech.rate = 1;
speech.pitch = 1;
window.speechSynthesis.speak(speech);
}
Example 3: speech to text in js
$('#start-record-btn').on('click', function(e) {
recognition.start();
});
Example 4: speech to text in js
var mobileRepeatBug = (current == 1 && transcript == event.results[0][0].transcript);
if(!mobileRepeatBug) {
noteContent += transcript;
noteTextarea.val(noteContent);
}
Example 5: speech to text in js
$('#pause-record-btn').on('click', function(e) {
recognition.stop();
});
Example 6: speech to text in js
recognition.onresult = function(event) {
var current = event.resultIndex;
var transcript = event.results[current][0].transcript;
noteContent += transcript;
noteTextarea.val(noteContent);
}