Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Voice Assistant

Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

DEPARTMENT OF COMPUTER ENGINEERING

ABHINAV EDUCATION SOCIETY’S


COLLEGE OF ENGINEERING &TECHNOLOGY (POLYTECHNIC),
WADWADI.
( 2022-2023 )

PROJECT REPORT ON

“ Voice Assistant ”

SUBMITTED TO

MAHARAHSTRA STATE BOARD OF TECHNICAL EDUCATION, MUMBAI


IN PARTIAL FULFILLMENT OF THE REQUIREMENTS
FOR THE AWARD OF DIPLOMA IN
( INFORMATION TECHNOLOGY )

BY

Mr. Ladkat Saurabh Satish ( 2108480384)


Mr. Powar Saumitra Sunil ( 2008480239)
Mr. Kokare Tushar Pandurang ( 2000300178)
Mr. Pawar Jayjeet Ashok ( 2008480137)

Under the guidance of

Prof. Bhosale .S.D


DEPARTMENT OF COMPUTER ENGINEERING
ABHINAV EDUCATION SOCIETY’S

COLLEGE OF ENGINEERING &TECHNOLOGY (POLYTECHNIC), WADWADI

CERTIFICATE
This is to certify that the dissertation report entitled
“Voice Assistant”
Submitted by:

Mr. Ladkat Saurabh Satish ( 2108480384)


Mr. Powar Saumitra Sunil ( 2008480239)
Mr. Kokare Tushar Pandurang ( 2000300178)
Mr. Pawar Jayjeet Ashok ( 2008480137)

Is a certify work carried out by him under the supervision of Prof. Bhosale S.D and it
is submitted towards the partial fulfillment of the requirement of Maharashtra State
Board
Of Technical Education, Mumbai for the award of the diploma of Engineering
(Information Technology/Computer Engineering)

Prof. Bhosale.S.D Prof. Shivtare A.D


Internal Guide Head of Department
Department of Information Technology Department of Computer Engineering

Seal/Stamp of the College B.Giri


Date: Principal
ACKNOWLEDGEMNT

We are happy to present this project after completing it successfully. This


project would not have been possible without the guidance, assistance and suggestions of
many individuals. We would like to express our deep sense of gratitude and indebtedness to
each and everyone who has helped us make this project a success. We heartily thank our
Principal, Dr. Prashant Patil Abhinav Education Society College of Engineering &
Technology for his constant encouragement and inspiration in taking up this project. We
heartily thank our Head of Department & Project Guide Prof. Shivtare A.D. Dept. of
Computer Engineering Abhinav Education Society College of Engineering & Technology for
his constant encouragement and inspiration in taking up this project and for his constant
follow up and advice throughout the course of the Project work .Special thanks to all the staff
members of Computer Engineering Department & Information Technology for their help and
kind co-operation.

Lastly we thanks our parents and friends for their encouragement and support given to
us in order to finish this precious work.

Group members:

Mr. Ladkat Saurabh Satish ( 2108480384)


Mr. Powar Saumitra Sunil ( 2008480239)
Mr. Kokare Tushar Pandurang ( 2000300178)
Mr. Pawar Jayjeet Ashok ( 2008480137)
INDEX

Sr Page No
No Description

INTRODUCTION TO PROJECT
1.1 Introduction
1.2 Need and scope of Computer System 1-3
01 1.3 Existing system
PROPOSED SYSTEM
2.1 Objectives
02 4-6
2.2 Innovative ideas of project
2.3 Requirement Engineering
a) Software b)Hardware requirement
SYSTEM ANALYSIS
3.1 Data Flow Diagram (DFD)
03 7-10
3.2 UseCase Diagram
3.3 Activity Diagram
3.4 Flowchart
IMPLEMENTATION
4.1 System Requirement
04 11-14
4.2 Hardware
4.3 Software
4.4 User Guideline
SYSTEM DESIGN
5.1 Output
05 15-25
5.2 Input Design & its samples
CONCLUSION
6.1 Conclusion
06 26
6.2 limitations
ANNEXURE
7.1 Source code
07 27-41

REFERENCE
08 8.1 Reference 42
VOICE ASSISTANT

INTRODUCATION

In today era almost all tasks are digitalized. We have smartphone in hands and it is
nothing less than having world at your fingertips. These days we aren’t even using fingers
We just Speak of the task and it is done there exist systems where we can say
Text Dad, I “will be late today”, and the Text is sent. That is the task of a voice Assistant.
.Voice Assistants are software programs that help you ease your day-to-day Tasks, such as
showing weather report ,cheating reminders, making shopping lists etc. They can take
commands via text or by voice .voice based intelligent assistants need an invoking word or
wake word to activate the listener, followed by the command .we have so many virtual
assistants, such as Apple’s siri Amazon Alexa
and Microsoft Cortana are running the market
This system is designed to be used efficiently run on desktop.Purpose of this voice
assistant is to make day today activity of desktop user .It is Personal Software that improves
user productivity by managing routine tasks of the user and by providing information from
online source to the user .It is effortless to use.

Abhinav education society’s college of engineering & technology polytechnic 1


VOICE ASSISTANT

Need And Scope of computer system

The need for a computer system with a voice assistant would depend on the specific purpose
and requirements of the system.
➢ Hands-free operation: A voice assistant can provide a hands-free way of interacting with
a computer system, allowing users to perform tasks and access information without using
their hands.
➢ Accessibility: A voice assistant can make a computer system more accessible to
individuals with disabilities or impairments that affect their ability to use traditional input
devices like a keyboard or mouse.
➢ Multitasking: A voice assistant can enable users to multitask more efficiently by allowing
them to perform tasks while keeping their hands free for other activities.
➢ Convenience: A voice assistant can provide a convenient way for users to access
information and perform tasks without having to navigate through menus or type
commands.
The need for a computer system with a voice assistant can vary depending on the
industry, organization, or individual requirements. It is essential to identify the specific
needs and requirements before designing and implementing a computer system with a
voice assistant to ensure that it meets the intended purpose and delivers the desired
results.

Scope

The scope for a voice assistant system is expanding rapidly, and there are limitless
possibilities for its application. As technology continues to evolve, we can expect to see even
more applications for voice assistants in various industries and domains.
The scope of a computer system can vary depending on its purpose and requirements. It can
range from a small personal computer to a large-scale enterprise system with multiple
servers, networks, and software applications.

Abhinav education society’s college of engineering & technology polytechnic 2


VOICE ASSISTANT

Existing System

• Amazon Alexa: Alexa is a cloud-based voice assistant developed by Amazon. It is


integrated into various Amazon devices such as the Echo, Echo Dot, and Echo Show, and
it can perform a range of tasks such as playing music, setting alarms, controlling smart
home devices, and providing information.
• Google Assistant: Google Assistant is a voice assistant developed by Google. It is
available on various devices, including smartphones, smart speakers, and smart displays.
Google Assistant can perform a variety of tasks such as setting reminders, making phone
calls, and answering questions.
• Apple Siri: Siri is a voice assistant developed by Apple. It is available on various Apple
devices such as the iPhone, iPad, and Apple Watch. Siri can perform tasks such as
sending messages, making phone calls, and setting reminders.
• Microsoft Cortana: Cortana is a voice assistant developed by Microsoft. It is available on
various devices such as Windows 10 computers, Xbox One consoles, and smartphones.
Cortana can perform tasks such as sending emails, setting reminders, and providing news
updates.
• Samsung Bixby: Bixby is a voice assistant developed by Samsung. It is available on
various Samsung devices such as smartphones, smartwatches, and smart TVs. Bixby can
perform tasks such as taking photos, sending texts, and controlling smart home devices.
• Each of these voice assistants has its unique features, advantages, and limitations. They
all use natural language processing (NLP) and machine learning algorithms to interpret
and respond to user requests. They also allow developers to create custom voice-
enabled applications and services using their respective software development kits
(SDKs).

Abhinav education society’s college of engineering & technology polytechnic 3


VOICE ASSISTANT

Proposed System

Objective:

Provide a natural and user-friendly interface for interacting with technology


➢ Offer voice-enabled control and automation of devices and systems
➢ Facilitate hands-free communication and access to information
➢ Improve productivity and efficiency through voice-based task management
➢ Support multi-lingual and diverse user populations
➢ Ensure privacy and security of user data and information
➢ Enhance accessibility for people with disabilities or impairments
Support integration with third-party services and devices to enhance functionality and
expand capabilities.

Innovative Ideas of Project:

1. GUI: Easy to use GUI (Graphical User Interface), hence any user with minimal
knowledge of operating a system can use the software.

2. Platform Independence: The messenger operates on any system irrelevant of the


underlying operating system.

Abhinav education society’s college of engineering & technology polytechnic 4


VOICE ASSISTANT

Requirement Engineering

• Requirement Gathering: The first step in the requirement engineering process is to gather
the requirements for the voice assistant system. This can be done through various
techniques, such as surveys, interviews, focus groups, and observation.
• Requirement Analysis: Once the requirements have been gathered, they need to be
analyzed to identify any inconsistencies, conflicts, or missing requirements. This step
ensures that the requirements are complete, accurate, and feasible.
• Requirement Specification: The next step is to specify the requirements for the voice
assistant system. This involves documenting the requirements in a clear and concise
manner using techniques such as use cases, user stories, and requirements documents.
• Requirement Validation: The requirements for the voice assistant system need to be
validated to ensure that they meet the stakeholders' needs and expectations. This can be
done through various techniques, such as prototyping, simulations, and testing.
• Requirement Management: The final step in the requirement engineering process is to
manage the requirements for the voice assistant system throughout the development
lifecycle. This involves ensuring that the requirements remain consistent, traceable, and
prioritized.

Project Objectives:
• Voice recognition: Developing an accurate voice recognition system that can
recognize natural language input from a user and convert it into a text format that can
be used by the system.
• Natural language processing: Developing a natural language processing (NLP) system
that can take the text input and understand the meaning behind it, allowing the system
to carry out various tasks based on the user's requests.
• Task automation: Creating a system that can automate tasks such as setting reminders,
making phone calls, sending messages, controlling smart home devices, and more,
based on the user's voice commands.

Abhinav education society’s college of engineering & technology polytechnic 5


VOICE ASSISTANT

Software requirement

• Visual studio
• Any browser
• Nodejs

Hardware Requirement

• Hard Disk : 50mb.


• Processor : Intel AMD & ARM.
• RAM : 128 MB.
• Monitor Make : HP, or any screens other.

• Microphone/speakers

Abhinav education society’s college of engineering & technology polytechnic 6


VOICE ASSISTANT

System Analysis

DFD Diagram:

Fig.DFD for voice assistant

Abhinav education society’s college of engineering & technology polytechnic 7


VOICE ASSISTANT

UseCase Diagram:

Fig. usecase diagram for voice assistant

Abhinav education society’s college of engineering & technology polytechnic 8


VOICE ASSISTANT

Activity Diagram

Fig.Activity diagram for voice assistant.

Abhinav education society’s college of engineering & technology polytechnic 9


VOICE ASSISTANT

Flowchart

Flowchart for voice Assistant.

Abhinav education society’s college of engineering & technology polytechnic 10


VOICE ASSISTANT

Implementation

System Requirement

a) Hardware Requirements-

• Hard Disk: 100mb


• Ram:2gb
• Processor:2.0 GHz
• Microphone

b) Software Requirements-

• Html,css,javascript
• Node js
• Any browser
• Windows above 10

Abhinav education society’s college of engineering & technology polytechnic 11


VOICE ASSISTANT

Technology used in Project

Html:
HTML (HyperText Markup Language) is the most basic building block of the Web. It defines
the meaning and structure of web content. Other technologies besides HTML are generally
used to describe a web page's appearance/presentation (CSS) or functionality/behavior
(JavaScript).
"Hypertext" refers to links that connect web pages to one another, either within a single
website or between websites. Links are a fundamental aspect of the Web. By uploading
content to the Internet and linking it to pages created by other
This module sets the stage, getting you used to important concepts and syntax such as
looking at applying HTML to text, how to create hyperlinks, and how to use HTML to
structure a web page.
Multimedia and embedding: This module explores how to use HTML to include
multimedia in your web pages, including the different ways that images can be included, and
how to embed video, audio, and even...

Css:
CSS stands for Cascading Style Sheets. It is a style sheet language which is used to describe
the look and formatting of a document written in markup language. It provides an additional
feature to HTML. It is generally used with HTML to change the style of web pages and user
interfaces. It can also be used with any kind of XML documents including plain XML, SVG
and XUL.

CSS is used along with HTML and JavaScript in most websites to create user interfaces for
web applications and user interfaces for many mobile applications.

Node-Js:
Node.js is an open-source and cross-platform JavaScript runtime environment. It is a popular
tool for almost any kind of project!

Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser.
This allows Node.js to be very performant.

Abhinav education society’s college of engineering & technology polytechnic 12


VOICE ASSISTANT

A Node.js app runs in a single process, without creating a new thread for every request.
Node.js provides a set of asynchronous I/O primitives in its standard library that prevent
JavaScript code from blocking and generally, libraries in Node.js are written using non-
blocking paradigms, making blocking behavior the exception rather than the norm.

When Node.js performs an I/O operation, like reading from the network, accessing a database
or the filesystem, instead of blocking the thread and wasting CPU cycles waiting, Node.js
will resume the operations when the response comes back.

This allows Node.js to handle thousands of concurrent connections with a single server
without introducing the burden of managing thread concurrency, which could be a significant
source of bugs.

Node.js has a unique advantage because millions of frontend developers that write JavaScript
for the browser are now able to write the server-side code in addition to the client-side code
without the need to learn a completely different language.

In Node.js the new ECMAScript standards can be used without problems, as you don't have
to wait for all your users to update their browsers - you are in charge of deciding which
ECMAScript version to use by changing the Node.js version, and you can also enable
specific experimental features by running Node.js with flags.

Feature of node.js

1. Asynchronous programming: Node.js allows developers to write asynchronous code,


which enables them to handle multiple requests and operations simultaneously. This
feature makes Node.js ideal for building scalable, high-performance applications.
2. Server-side programming: Node.js is primarily used for server-side programming, which
allows developers to build web applications and APIs that can handle a large number of
requests.
3. Cross-platform: Node.js is compatible with multiple operating systems such as Windows,
macOS, and Linux. This makes it easy for developers to write code on one platform and
run it on another.
4. Lightweight and fast: Node.js is built on the V8 JavaScript engine, which makes it fast
and efficient. It also has a small footprint, which means it can be used in resource-
constrained environments.
5. Package management: Node.js comes with its own package manager, called npm (Node
Package Manager), which makes it easy for developers to install, manage, and share
packages and modules.
6. Real-time applications: Node.js is well-suited for building real-time applications such as
chat apps, online games, and streaming services

Abhinav education society’s college of engineering & technology polytechnic 13


VOICE ASSISTANT

User Guidelines

1. Speak Clearly and Slowly:


When using a voice assistant, it is essential to speak clearly and slowly. This will help the
voice assistant understand your commands more accurately. Avoid speaking too fast, using
slangs or regional language as it may lead to misinterpretation by the voice assistant.
2. Use the Right Trigger Word:
Voice assistants typically respond to a trigger word such as "Hey Siri," "OK Google," or
"Alexa." When giving commands to your voice assistant, ensure you use the correct trigger
word to activate the assistant. It's also essential to avoid using similar trigger words for other
assistants as it may cause confusion or activate the wrong assistant.
3. Be Specific with Your Commands:
Voice assistants are becoming more intelligent every day, but they are still limited in their
ability to understand and interpret commands. When giving commands, try to be as specific
as possible. For example, instead of saying "Play some music," say "Play music from the
90s."
4. Keep Background Noise to a Minimum:
Background noise can interfere with the voice assistant's ability to understand your
commands accurately. When giving commands, try to minimize background noise as much as
possible.
5. Use Natural Language:
Voice assistants are designed to understand natural language, which means you can speak to
them as if you were speaking to a human being. Avoid using overly formal or robotic
language when giving commands.
6. Check the Results:
After giving a command, it's important to check the results to ensure that the voice assistant
has understood your command correctly. If the results are not what you expected, try
rephrasing your command or giving more specific instructions.

Abhinav education society’s college of engineering & technology polytechnic 14


VOICE ASSISTANT

System Design

Output

Abhinav education society’s college of engineering & technology polytechnic 15


VOICE ASSISTANT

Input & their Outputs:

Abhinav education society’s college of engineering & technology polytechnic 16


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 17


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 18


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 19


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 20


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 21


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 22


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 23


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 24


VOICE ASSISTANT

Abhinav education society’s college of engineering & technology polytechnic 25


VOICE ASSISTANT

Conclusion:

creating a voice assistant project in JavaScript can be a challenging experience. By


utilizing technologies such as Web Speech API and Natural Language Processing, developers
can create an interactive and responsive voice assistant that can perform a wide range of
tasks.
Some of the key considerations when developing a voice assistant in JavaScript include
designing an intuitive and user-friendly interface, ensuring accuracy and reliability of the
speech recognition and response mechanisms, and optimizing performance for different
devices and browsers.
Ultimately, the success of a voice assistant project in JavaScript will depend on careful
planning, testing, and iteration. By leveraging the power of JavaScript and other cutting-edge
technologies, developers can create voice assistants that are intelligent, useful, and enjoyable
to use.

Limitations:

1. Speech recognition accuracy: While the Web Speech API provides a robust speech
recognition system, it is not always 100% accurate. Accurate speech recognition is critical
for the voice assistant to understand and respond to user commands correctly.
2. Natural language processing limitations: Natural language processing (NLP) is required
for the voice assistant to understand and respond to complex user commands. However,
NLP is still an emerging field, and there are limitations to the accuracy and capabilities of
current NLP technologies.
3. Performance limitations: JavaScript is a client-side language, and the performance of the
voice assistant project can be affected by the processing power and memory of the user's
device. In addition, the performance of the voice assistant can be impacted by network
latency and bandwidth limitations.
4. Privacy and security concerns: The voice assistant project may require access to sensitive
user information, such as location data or personal information. It is important to ensure
that appropriate security measures are in place to protect user data.
5. Accessibility limitations: Voice assistants may not be accessible to users with disabilities,
such as those with hearing impairments or speech difficulties. It is important to consider
accessibility when developing a voice assistant project

Abhinav education society’s college of engineering & technology polytechnic 26


VOICE ASSISTANT

ANNEXURE

Abhinav education society’s college of engineering & technology polytechnic 27


VOICE ASSISTANT

Source code

Index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="YZ-youth zone">
<link rel="icon" type="image/x-icon" href="1.png">
<title>Jenni - The smart AI</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/5.15.3/css/all.min.css">
</head>
<body>
<header>
<div class="image-container">
<div class="image">
<img src="1.png" alt="jenni" height="30" width="30">
<span class="title"> I am Jenni </span>
</div>
</div>
</header>
<section class="main">
<div class="input-container">
<div class="image-container">
<div class="image">

Abhinav education society’s college of engineering & technology polytechnic 28


VOICE ASSISTANT

<img src="1.png" id="microphone" height="100" width="100">


<span><label id="k1">Click here to Speak</label></span>
</div>
</div>
<textarea id="write" rows="8" cols="50" placeholder="I am Jenni"></textarea>
</div>
</section>
<script src="app.js"></script>
<script
src="https://apis.google.com/js/api.js?key=AIzaSyCbzbNBoxHPjjvtrEQMNGYw4CaynrWrl
v0">
</script>
</body>
</html>

Abhinav education society’s college of engineering & technology polytechnic 29


VOICE ASSISTANT

app.js

const btn = document.querySelector('#microphone');


const content = document.querySelector('#write');

function speak(sentence)
{
const text_speak = new SpeechSynthesisUtterance(sentence);

text_speak.rate = 1;
text_speak.pitch = 1;

window.speechSynthesis.speak(text_speak);
}

function wishMe()
{
const day = new Date();
const hr = day.getHours();

let greeting;

if (hr >= 0 && hr < 12)


{
greeting = "Good morning";
}
else if (hr === 12)

Abhinav education society’s college of engineering & technology polytechnic 30


VOICE ASSISTANT

{
greeting = "Good noon";
}
else if (hr > 12 && hr <= 17)
{
greeting = "Good afternoon";
}
else
{
greeting = "Good evening";
}

speak(`${greeting}, sir`);
}

window.addEventListener('load', () => {
speak("Activating jenni");
speak("Going online. How can I help you?");
wishMe();
});

const SpeechRecognition = window.SpeechRecognition ||


window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();

btn.addEventListener('click', () => {
recognition.start();
document.getElementById("k1").innerHTML="recognizing...";
});

Abhinav education society’s college of engineering & technology polytechnic 31


VOICE ASSISTANT

recognition.onresult = (event) => {


const current = event.resultIndex;
const transcript = event.results[current][0].transcript;
console.log('transcript');
content.textContent = transcript;
speakThis(transcript.toLowerCase())
};

function textback()
{
document.getElementById("k1").innerHTML="Click here to speak";
}

function speakThis(message)
{
let speech = new SpeechSynthesisUtterance();

if (message.includes('hey') || message.includes('hello'))
{
speech.text = "Hello, sir.";
}

else if (message.includes('how are you'))


{
speech.text = "I am fine, thank you.";
}

else if (message.includes('name'))

Abhinav education society’s college of engineering & technology polytechnic 32


VOICE ASSISTANT

{
speech.text = "My name is yz.";
}

else if (message.includes('open google'))


{
window.open("https://google.com", "_blank");
speech.text = "Opening Google.";
}

else if (message.includes('open instagram'))


{
window.open('Instagram:///');
speech.text = "Opening Instagram.";
}

else if (message.includes('open facebook'))


{
window.open("facebook:///");
speech.text = "Opening Facebook.";
}

else if (message.includes('open spotify'))


{
window.open("Spotify:///");
speech.text = "Opening Spotify.";
}

else if (message.includes('open file'))


{

Abhinav education society’s college of engineering & technology polytechnic 33


VOICE ASSISTANT

window.open("FileExplorer:///");
speech.text = "Opening File.";
}

else if (message.includes('what is') || message.includes('who is') || message.includes('what


are')
||message.includes('search'))
{
window.open(`https://www.google.com/search?q=${encodeURIComponent(message)}`,
"_blank");
speech.text = `This is what I found on the internet regarding ${message}.`;
}

else if (message.includes('wikipedia'))
{

window.open(`https://en.wikipedia.org/wiki/${encodeURIComponent(message.replace("wiki
pedia", ""))}`, "_blank");
speech.text = `This is what I found on Wikipedia regarding ${message}.`;
}

else if (message.includes('time'))
{
const time = new Date().toLocaleString(undefined, { hour: "numeric", minute: "numeric"
});
speech.text = `The current time is ${time}.`;
}

else if (message.includes('are you married'))


{
speech.text = ` no i am still single`;
}

Abhinav education society’s college of engineering & technology polytechnic 34


VOICE ASSISTANT

else if (message.includes('date'))
{
const date = new Date().toLocaleString(undefined, { month: "short", day: "numeric" });
speech.text = `Today's date is ${date}.`;
}

else if (message.includes('calculator'))
{
window.open('Calculator:///');
speech.text = "Opening calculator.";
}

else if (message.includes('play'))
{
const YOUTUBE_API_KEY = "AIzaSyCbzbNBoxHPjjvtrEQMNGYw4CaynrWrlv0";

const videoName = message.replace('play', '').trim();


const url =
`https://www.googleapis.com/youtube/v3/search?part=snippet&q=${encodeURIComponent(
videoName)}&key=${YOUTUBE_API_KEY}`;

fetch(url)
.then(response => response.json())
.then(data => {
const videoId = data.items[0].id.videoId;
window.open(`https://www.youtube.com/watch?v=${videoId}`);
speech.text = `Playing ${videoName} on YouTube.`;
window.speechSynthesis.speak(speech);
})
.catch(error => {

Abhinav education society’s college of engineering & technology polytechnic 35


VOICE ASSISTANT

speech.text = `Sorry, an error occurred while searching for ${videoName} on


YouTube.`;
window.speechSynthesis.speak(speech);
});
}

else if (message.includes('open whatsapp'))


{
window.open('whatsapp:///');
speech.text = "Opening WhatsApp";
}

else if (message.includes('get battery level') || message.includes('get battery percentage'))


{
navigator.getBattery().then(function(battery)
{
const level = battery.level * 100;
speech.text = `The battery level is ${level} percent.`;
window.speechSynthesis.speak(speech);
});
}

else if (message.includes('call'))
{
const number = message.replace('call', '').trim();
window.location.href = `tel:${number}`;
speech.text = `Calling ${number}`;
}

else
{

Abhinav education society’s college of engineering & technology polytechnic 36


VOICE ASSISTANT

speech.text = "I did not understand what you said. Please try again.";
}
textback();
speech.volume = 1;
speech.pitch = 1;
speech.rate = 1;
window.speechSynthesis.speak(speech);
}

Abhinav education society’s college of engineering & technology polytechnic 37


VOICE ASSISTANT

Style.css

.main
{
background-color: #050505;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
max-width: 3000px;
margin: 0 auto;
}

.input-container
{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 80vh;
}

.talk
{
margin-bottom: 20px;
background-color: #fff;
border: none;
border-radius: 50%;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease-in-out;

Abhinav education society’s college of engineering & technology polytechnic 38


VOICE ASSISTANT

cursor: pointer;
}

.talk:hover
{
transform: translateY(-5px);
}

.content
{
font-size: 28px;
font-weight: 500;
color: #333;
margin-bottom: 20px;
text-align: center;
}

#spoken-text
{
margin-bottom: 20px;
border: 2px solid #ddd;
border-radius: 5px;
padding: 10px;
font-size: 16px;
font-family: Arial, sans-serif;
color: #333;
width: 100%;
max-width: 500px;
resize: vertical;
}

Abhinav education society’s college of engineering & technology polytechnic 39


VOICE ASSISTANT

body
{
background-color: rgb(9, 9, 9);
margin: 0;
padding: 0;
}

label
{
color: white;
font-size: 1rem;
font-family: Arial, sans-serif;
margin-right: 0.1rem; /* Change to the desired margin */
display: inline-block;
vertical-align: middle;
}

.image img
{
vertical-align: middle;
}
textarea
{
padding: 10px;
font-size: 16px;
border: 2px solid #ccc;
border-radius: 20px;

Abhinav education society’s college of engineering & technology polytechnic 40


VOICE ASSISTANT

resize: vertical;
}

.title
{
color: white;
font-size: 1rem;
font-family: Arial, sans-serif;
margin-right: 0.1rem; /* Change to the desired margin */
display: inline-block;
vertical-align: middle;
}

Abhinav education society’s college of engineering & technology polytechnic 41


VOICE ASSISTANT

References

➢ www.w3school.com
➢ www.youtube.com
➢ www.google.com
➢ www.github.com
➢ www.tutorialpoint.com
➢ StakOverflow
➢ ChatGpt

Abhinav education society’s college of engineering & technology polytechnic 42

You might also like