Nodejs speech to text 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: Text to Speech in Node.js

/*
    This code comes from Vincent Lab
    And it has a video version linked here: https://www.youtube.com/watch?v=SfeUTOlaWmk
*/

// Import dependencies
const say = require("say");

// Use default system voice and speed
say.speak("Today will make node speak");

// // Set the speed
// say.speak("Hello!", "", 0.5);

// Stop the text currently being spoken
// say.stop();

// Export Voice to file
// const filename = "hello.wav";
// say.export("Hello!", "", 0.75, filename, function (err) {
//     if (err) {
//         return console.error(err);
//     }

//     console.log(`Text has been saved to ${filename}`);
// });

Example 3: speech to text in js

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