Start Working with Voice Driven Application with Nodejs

Start Working with Voice Driven Application with Nodejs

Start Working with Voice Driven Application with Nodejs - An article to create a voice driven application in Node.js application. Here I will explain to create the application step by step.

Start Working with Voice Driven Application with Nodejs - An article to create a voice driven application in Node.js application. Here I will explain to create the application step by step.

Artificial intelligence has the potential to offer $15.7 trillion to the global economy by 2030. We all already encounter it every day. Simply think the scenerios of daily life when Amazon recommended a book to you or Netflix suggested a film or TV show. All these recommendations are based on algorithms that examine what you've bought or watched or on the base of other activity we do over internet. The algorithms learn from those purchases, using them to suggest other things you might enjoy. Artificial intelligence lies behind those algorithms.

Simple artificial intelligence even filters your incoming emails, diverting spam away from your inbox. It works better than software rules because it learns what could be spam based on the content of the email. The artificial intelligence even builds a model based on your preferences -- what is spam to you may not be spam to another user.

Artificial intelligence goes so much further than recommending a book or filtering your emails.

So, In this article, I am going to create a demo application in Node.js to manage the video play, stop and other activity with voice. The voice manipulation gets easier for web pages by Javascript API for speech recognition.

Let's Get Started

Step 1: Create Node.js Application

// make project directory

mkdir voice-driven-nodejs-app

// move to project folder

cd voice-driven-nodejs-app

// initialize the npm

npm init --yes

// install required package

npm install
 https express

Step 2: Generate Private key and certificate

openssl genrsa -out privatekey.pem 1024 
openssl req -new -key privatekey.pem -out certrequest.csr 
openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem

Step 3: Create Server File for Nodejs application

Create file with **touch server.js **and put the below code inside this file

 const fs = require("fs");
const https = require('https');
const express = require('express');
const app = express();
app.use(express.static(__dirname + '/public'));
var privateKey = fs.readFileSync('privatekey.pem').toString();
var certificate = fs.readFileSync('certificate.pem').toString();
const httpOptions = {key: privateKey, cert: certificate};
https.createServer(httpOptions, app).listen(8000, () => {
console.log(">> Serving on " + 8000);
app.get('/', function(req, res) {
res.sendFile(__dirname + '/public/index.html');

Step 4: Create index.html

Create a file under public directory

// create a public/index.html file
mkdir public && cd public && touch index.html

Open the file and put below code inside the body tag of the html page

 <video id="video" controls="" preload="none" muted=”muted”poster="">
<source id="mp4" src="" type="video/mp4">
<source id="webm" src="" type="video/webm">
<source id="ogv" src="" type="video/ogg">
<p>Your user agent does not support the HTML5 Video element.</p>
Say : Play / Stop / Mute / Unmute
<script src='RemoteControl.js'></script>
<script src='main.js'></script>

Step 5: Create main.js under the public directory

Create file with **touch main.js **and put below code inside it.

 var video = document.querySelector("#video");
var remoteControl = new RemoteControl(video);
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.lang = "en-US";
recognition.continuous = true;
recognition.onresult = function(event) {
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
if (event.results[i][0].transcript.trim() == "play") {;
if (event.results[i][0].transcript.trim() == "stop") {
if (event.results[i][0].transcript.trim() == "mute") {
if (event.results[i][0].transcript.trim() == "unmute") {
}`You said : ${event.results[i][0].transcript}`);

Step 7: Create RemoteControl.js under the public directory

create a new file with **touch RemoteControl.js **and put below code insite it

class RemoteControl {
constructor(element) {
this.videoElement = element;
play() {;
stop() {
this.videoElement.currentTime = 0;
mute() {
this.videoElement.muted = true;
unmute() {
this.videoElement.muted = false;

Final Step: Run the App

Run the app with below command

node server.js

Now navigate to URL: https://localhost:8000/ over browser. A Page will open like below:

Click on advanced:

And then Proceed to localhost (unsafe)

Now we can access the video by saying play/stop/mute/unmute


So in this demo, We tried to Start Working with Voice Driven Application in Nodejs Application. You can also find other demos of Nodejs Sample Application here to start working on enterprise level application. Credit for the demo goes to : click here to see

** **That’s all for now. Thank you for reading and I hope this demo will be very helpful how AI can be integrated with Node.js and about the use of AI in our daily life.

Top Vue.js Developers in USA

Top Vue.js Developers in USA

Vue.js is an extensively popular JavaScript framework with which you can create powerful as well as interactive interfaces. Vue.js is the best framework when it comes to building a single web and mobile apps.

We, at HireFullStackDeveloperIndia, implement the right strategic approach to offer a wide variety through customized Vue.js development services to suit your requirements at most competitive prices.

Vue.js is an open-source JavaScript framework that is incredibly progressive and adoptive and majorly used to build a breathtaking user interface. Vue.js is efficient to create advanced web page applications.

Vue.js gets its strength from the flexible JavaScript library to build an enthralling user interface. As the core of Vue.js is concentrated which provides a variety of interactive components for the web and gives real-time implementation. It gives freedom to developers by giving fluidity and eases the integration process with existing projects and other libraries that enables to structure of a highly customizable application.

Vue.js is a scalable framework with a robust in-build stack that can extend itself to operate apps of any proportion. Moreover, vue.js is the best framework to seamlessly create astonishing single-page applications.

Our Vue.js developers have gained tremendous expertise by delivering services to clients worldwide over multiple industries in the area of front-end development. Our adept developers are experts in Vue development and can provide the best value-added user interfaces and web apps.

We assure our clients to have a prime user interface that reaches end-users and target the audience with the exceptional user experience across a variety of devices and platforms. Our expert team of developers serves your business to move ahead on the path of success, where your enterprise can have an advantage over others.

Here are some key benefits that you can avail when you decide to hire vue.js developers in USA from HireFullStackDeveloperIndia:

  • A team of Vue.js developers of your choice
  • 100% guaranteed client satisfaction
  • Integrity and Transparency
  • Free no-obligation quote
  • Portal development solutions
  • Interactive Dashboards over a wide array of devices
  • Vue.js music and video streaming apps
  • Flexible engagement model
  • A free project manager with your team
  • 24*7 communication with your preferred means

If you are looking to hire React Native developers in USA, then choosing HireFullStackDeveloperIndia would be the best as we offer some of the best talents when it comes to Vue.js.

Learn Node.js - Node.js API Development for Beginners

Learn Node.js API Development from absolute scratch. This video is for complete beginners getting started guide!

In this video you will learn the core fundamentals of Node JS so that you can start building API using Node JS. You will learn Modern JavaScript, Node JS event loop, Asynchronous programming, using node modules, npm modules and creating your own modules, creating server, connect to database and sending json responses.

Learn More

Node.js With Passport Authentication | Full Project

Full Stack Developers: Everything You Need to Know

MEAN Stack Tutorial MongoDB, ExpressJS, AngularJS and NodeJS

How to Perform Web-Scraping using Node.js

Moving from NodeJS to Go

Authenticate a Node ES6 API with JSON Web Tokens

The Complete Node.js Developer Course (3rd Edition)

Angular & NodeJS - The MEAN Stack Guide

NodeJS - The Complete Guide (incl. MVC, REST APIs, GraphQL)

Node.js: The Complete Guide to Build RESTful APIs (2018)