Pratyu Final

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 63

Virtual System Assistant Using

Artificial Intelligence
A Project Report submitted for the partial fulfilment of the requirement for the
award of the degree in
Bachelor of Technology
in
COMPUTER SCIENCE AND ENGINEERING
submitted by

P. GANESH 18525A0505
P. MOUNICA SAI 17521A0514
BHAVANI BEHARA 17521A0506
K.BANGARU KRISHNAVENI 18525A0504
B. ADI NARAYANA 18525A0502

Under the esteemed guidance of


Mr. N P Patnaik
Assistant Professor, Dept. of CSE

Mr. N P Patnaik
Professor & HOD, Dept. of CSE

Department of Computer Science and Engineering


VISWANADHA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Mindivanipalem (V), Anandapuram (M),
Visakhapatnam (D) Approved by A.I.C.T.E.,
affiliated to J.N.T.U.K., Kakinada
2021
1
VISWANADHA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Mindivanipalem (V), Anandapuram (M), Visakhapatnam (D)
Approved by A.I.C.T.E., affiliated to J.N.T.U.K., Kakinada

CERTIFICATE
This is to certify that the project report titled “Virtual System Assistant Using

Artificial Intelligence”, is being submitted by

P. GANESH 18525A0505
P. MOUNICA SAI 17521A0514
BHAVANI BEHARA 17521A0506
K. BANGARU KRISHNAVENI 18525A0504
B. ADI NARAYANA 18525A0502

In partial fulfilment for the award of the Degree of Bachelor of Technology in Computer
Science and Engineering to the J.N.T.U.K., Kakinada is a record of bonafied work carried
out under my guidance and supervision. The results embodied in this project report have not
been submitted to any other University or Institute for the award of any Degree or Diploma.

Project Guide Head of the Department

Mr. N P PATNAIK Mr. N P PATNAIK


Assistant Professor, Dept. of CSE Professor & HoD, Dept. of C

Mr. N P PATNAIK
Professor & HoD, Dept. of CSE

2
DECLARATION

We hereby declare that this project report entitled “Virtual System


Assistant Using Artificial Intelligence” submitted to the department of
Computer Science and Engineering, Viswanadha Institute of Technology and
Management, affiliated to J.N.T.U.K., Kakinada is a bonafied work done by us
under the guidance of Mr. N P PATNAIK, Professor & Head of the Department
of Computer Science and Engineering in the fulfilment of the degree of Bachelor
of Technology is our own and it has not previously formed the basis for any
degree/diploma or the other similar title submitted to any university.

Project Associates
P. GANESH 18525A0505
P. MOUNICA SAI 17521A0514
BHAVANI BEHARA 17521A0506
K. BANGARU KRISHNAVENI 18525A0504
B. ADI NARAYANA 18525A0502
ACKNOWLEDGEMENT

We would like to take this opportunity to say, that this project would never
have taken shape but for co-operation extended to us by many individuals. Though
it is not possible to name all of them, we mention some of the very important
persons.
We have been fortunate in getting generous help, motivation and constant
encouragement from our guide “Mr. N P PATNAIK” leading to successful
completion of project. We thank for valuable support, timely help and guidance
given to us.
We sincerely thank to our Head of the Department “Mr. N P PATNAIK”
for allowing us to use resources available in our college and for his valuable
advice and encouragement extended to us in completion of our project.
We sincerely thank to our principal “Dr. M GOVINDA RAJU” for
allowing us to use resources available in our college and for his valuable advice
and encouragement extended to us in doing our project.
Finally, a special thanks to our PARENTS and FACULTY MEMBERS
of Computer Science and Engineering department for their support and
encouragement throughout our life and this course. Thanks to all our friends and
well-wishers for their constant support.

Project Associates
P. GANESH 18525A0505
P. MOUNICA SAI 17521A0514
BHAVANI BEHARA 17521A0506
K. BANGARU KRISHNAVENI 18525A0504
B. ADI NARAYANA 18525A0502
ABSTRACT

Voice assistants:-
These are automated software applications that assist the user by understanding
natural language in spoken form. The key here is voice. A voice assistant is a digital
assistant that uses voice recognition, speech synthesis, and natural language processing
(NLP) to provide a service through a particular application.Voice assistants are software
agents that can interpret human speech and respond via synthesized voices. Apple’s Siri,
Amazon’s Alexa, Microsoft’s Cortana, and Google’s Assistant are the most popular
voice assistants.This is software that can assist people with basic tasks, usually using
natural language. Intelligent personal assistants can go online and search for an answer
to a user’s question. Either text or voice can trigger an action.
VoiceAssiatant is a multi-functional AI software that allows you to interact with
your computer using voice commands .
Artificial intelligence makes it possible for us to control our computer using
natural language commands and makes our life easier.This is similar to Siri, Alexa but is
implemented in desktops rather than in mobile phones.It is a multi-functional artificial
intelligence software that provides a single window environment to control our computer
and perform wide range of tasks using voice commands.It can take a dictation (speech to
text), search information on the Internet, it can play the songs we want to hear, it can
open or search files on our computer, it can do mathematical calculations, remember
notes for us, automate various computer tasks and much more
Many devices we use every day utilize voice assistants. They’re on our
smartphones and inside smart speakers in our homes. Many mobile apps and operating
systems use them. Additionally, certain technology in cars, as well as in retail,
education, healthcare, and telecommunications environments, can be operated by voices.

4
OBJECTIVE

The main objective of the project is to provide hands free operation of the
desktop by using voice commands to it makes the life of computer users and visually
challenged easy. The main task of this voice assistant is to minimize the use of input
devices like keyboard, mouse, touch pens, etc. This will reduce both the hardware
cost and space taken by it.

5
ACKNOWLEDGEMENT

I would like to thank my supervisor Prof. Prasad A.M for his guidance, time and
patience. He has been supportive and co-operative in this whole effort. His valuable
comments have been immensely helpful in enhancing the quality of work. I am also
thankful to WIPRO Technologies for giving me this opportunity and also for making
the required, I am thankful to VIT and the training department for all their efforts in
organizing this course.

6
TABLE OF CONTENTS

Title Page Number


Abstract 4
Objective 5
Keywords and abbreviations 8
List of figures 9
Introduction 10
Overview 12
Literature survey 13
Existing System 13
Proposed System 13
Architecture of the system 16
System Specifications 19
Hardware requirements 19
Software requirements 20
Functional requirements 21
Non functional requirements 21
Use Case Diagram 27
Data flow Diagram 29
Screenshots 46
Testing and Test cases 47
Test case 1 48
Test case 2 49
Test case 3 50
Test case 4 51
Test case 5 52
Test case 6 53
Test case 7 54
Test case 8 55
Test case 9 56
Challenges of testing 57
Conclusions and discussions 58
advantages 58
Disadvantage 60
Future work 61
References 62

7
KEYWORDS

Python script
speech recognition
voice assistant

ABBREVIATIONS
API - Application program interface
NLP - natural language processing
TTS - Text-To-Speech
SST - Speech To Text

8
LIST OF FIGURES

S. NO TITLE PAGE NO
1. Speech recognition mechanism 16
2. Working model of the system 16
3. System Architecture 17
4. Use Case Diagram 1 27
5. Use Case Diagram 2 28
6. Data Flow Diagram 1 29
7. Data Flow Diagram 2 30

9
INTRODUCTION

Using computers these days have been a little difficult task for the users as the
user need to type anything he needs .The result or the corresponding data is not
displayed unless the input is given through the keyboard or mouse or any other input
devices. Visually impaired finds it difficult to use the computer as they need to provide
the input through the key board or any other input devices.

Typing takes time. Searching manually for a file takes time. All the above problems
can be overcome with the help of voice assistant in the personal desktop.

The major advantages of using voice assistant in the desktop are:-

1.Saves time

2.Hands free operations

3.Easy to use

Voice assistants:-
These are automated software applications that assist the user by understanding
natural language in spoken form. The key here is voice. A voice assistant is a digital
assistant that uses voice recognition, speech synthesis, and natural language processing
(NLP) to provide a service through a particular application.

Voice assistants are software agents that can interpret human speech and respond
via synthesized voices. Apple’s Siri, Amazon’s Alexa, Microsoft’s Cortana, and
Google’s Assistant are the most popular voice assistants.

This is software that can assist people with basic tasks, usually using natural
language. Intelligent personal assistants can go online and search for an answer to a
user’s question. Either text or voice can trigger an action.VoiceAssiatant is a multi-
functional AI software that allows you to interact with your computer using voice
commands.

10
Artificial intelligence makes it possible for us to control our computer using natural
language commands and makes our life easier.This is similar to Siri, Alexa but is
implemented in desktops rather than in mobile phones.It is a multi-functional artificial
intelligence software that provides a single window environment to control our computer
and perform wide range of tasks using voice commands.It can take a dictation (speech to
text), search information on the Internet, it can play the songs we want to hear, it can
open or search files on our computer, it can do mathematical calculations, remember
notes for us, automate various computer tasks and much more.Many devices we use
every day utilize voice assistants. They’re on our smart phones and inside smart speakers
in our homes. Many mobile apps and operating systems use them. Additionally, certain
technology in cars, as well as in retail, education, healthcare, and telecommunications
environments, can be operated by voices.

Voice assistants are used everywhere in today’s world. The below statistics
shows how voice assistants are ruling the globe.

Source :- Google 1. Bar graph of voice assistant users

11
PROBLEM STATEMENT

Voice assistants are ruling today’s world. They are seen every where in
mobile phones, home appliances, smart speakers and many furniture at home. But to our
surprise there are no such voice assistants built for desktops and laptops.

The main aim of the project is to build a virtual desktop voice assistant which allows
the users to access the computer i.e the desktop or the laptop only by using voice
commands.

Voice assistants in desktops or laptops are very useful as they saves the time and
the effort to give the input through the input devices such as keyboard ,mouse etc.let us
assume we have a software company running with morethan thousands of employees.a
software user keeps his data in the computer and works continuously on computer.
When he wanted to find for a file that is saved in his computer, he needs to search for the
file in all the drives . At that time the file can be found just by giving a command to the
voice assistant which would search for the file in the computer and finds it for us. Not
only for finding the file that is saved in the system but also many other tasks can be
performed such as saving text file,opens youtube, opens power points etc.

The other problem with the existing system is that visually challenged finds it
difficult to type the keyboard and see the result on the screen that is displayed after a
command is or task is performed. This desktop voice assistant helps the visually
challenged people to use the computer very easily as like as the mobile phones. It may
be an android or an iphone, voice assistants help these people a lot in using the modern
technology and come through the world of science.

12
OVERVIEW

The overview of this project:

Desktop voice assistant is a software that takes your command through your
voice. Also called as artificial agents listen to our voice, to understand what we want,
and then delivers the results.In technical words, a voice assistant is a digital assistant
that uses voice recognition, speech synthesis, and natural language processing (NLP) to
provide service through a particular application in response to the voice command.
Desktop voice assistant makes life easy .It helps in accessing or using the computer very
easy way. The voice command is recognized and the command is executed. The voice
assistant we have developed is a desktop-based built using python modules and libraries.
This assistant is just a basic version that could perform all the basic tasks

It helps in opening the google and search for the requested question.It obeys
the command that was given through the voice and activates the activities.The voice is
converted into speech and the command processed .This system opens brower, saves
notes, opens power point, ms access, sends mails, finds the path and many more.

Features
The System shall be developed to offer the following features:
1) It keeps listening continuously in inaction and wakes up into action when called with
a particular predetermined functionality.
2) Browsing through the web based on the individual’s spoken parameters and then
issuing a desired output through audio and at the same time it will print the output on the
screen

13
LITERATURE SURVEY

EXISTING SYSTEM

Using computers these days have been a little difficult task for the users as the
user need to type everything he needs .The result or the corresponding data is not
displayed unless the input is given through the keyboard or mouse or any other input
devices. Visually impaired finds it difficult to use the computer as they need to
provide the input through the key board or any other input devices.

Typing takes time.

Searching manually for a file takes time

All the above problems can be overcome with the help of voice assistant in the personal
desktop.

PROPOSED SYSTEM

This software can assist people with basic tasks, usually using natural language.
Intelligent personal assistants can go online and search for an answer to a user’s
question. Voice Assiatant is a multi-functional AI software that allows us to interact with
our computer using voice commands

Takes input from the mic

Convert the voice or speech to text

Store the text in a variable or directly take it as user input produce the result.

14
The system design consists of

1. Taking the input as speech patterns through microphone.

2. Audio data recognition and conversion into text.

3. Comparing the input with predefined commands

4. Giving the desired output

The initial phase includes the data being taken in as speech patterns from the
microphone.in the second phase the collected data is worked over and transformed into
textual data . In the next step, this resulting stringified data is manipulated through
Python Script to finalise the required output process. In the last phase, the produced
output is presented either in the form of text or converted from text to speech .

The proposed system will have the following functionality:

(a) The system will keep listening for commands and the time for listening is variable
which can be changed according to user requirements.

(b) If the system is not able to gather information from the user input it will keep asking
again to repeat till the desired no. of times.

(c) The system can have female voices according to user requirements.

(d) Features supported in the current version include playing music, emails, texts,
search on Wikipedia, or opening system installed applications, opening anything on the
web browser, etc.

(e)The system will keep listening for commands and the time for listening is variable
which can be changed according to user requirements.

(f) If the system is not able to gather information from the user input it will keep asking
again to repeat till the desired no. of times.

The tasks that a voice assistant could do are that when we say a command, the sound
or the audio is recognized by the speech recognition API of python and requested task is

15
performed. For example when the user wanted to open google and browse for
something, then voice assistant opens google and finds results for the requested query.
The voice assistant does many other performs such as opens google, opens youtube,
opens notepad, records and saves notes, opens the saved files, plays music, locks down
the monitor, shuts down the system, tells jokes, opens power point, opens excel , send
the cpu information opens command prompt, performs mathematical calculations and so
on.

This project is very useful mainly for visually challenged computer users where one
can access the system only by using the voice commands. The voice assistant responds
back to the command that the user commands it to do. The print statement is printed on
the console to let the user know what task is performed.

2.Working model of voice assistant

16
DESIGN

The overall design of our system consists of the following phases:

(a) Taking input from the user in the form of voice.

(b) Converting the speech into text to be processed by the assistant.

(c) The converted text is now processed to get the required results.

(d) The text contains one or two keywords that determine what query is to be executed.
If the keyword doesn’t match any of the queries in the code then the assistant asks the
user to speak again.

(e) The result which is in the form of text is converted to speech again to give results to
the user.

3. system architecture

Microphone

USER Converts voice into


binary data

Speech
recognition API

Converts the
voice data into
Python script
text form.
Executes the command

17
ARCHITECTURE OF THE SYSTEM

SPEECH RECOGNITION -

The speech recognition module used the program is Google’s Speech


Recognition API which is imported in python using the command “import
speech_recognition as sr”.This module is used to recognize the voice which is given as
input by the user. This is a free API that is provided and supported by Google. This is a
very light API that helps in reducing the size of our application.

TTS & STT -

The voice which is given as input is first converted to text using the
speech recognition module. The text is then processed to give the result of the query
given by the user. The final step is the conversion of the result of the processed query to
speech which is the final output. The most time consuming among the two is STT
because the system first has to listen to the user and different users have different, some
are easy to understand while some are not easily audible. This is the step upon which our
total execution time depends. Once the speech is converted to text executing commands
and giving the results back to the user is not a time-consuming step.

18
1. Speech recognition mechanism

2. working model of the system

19
Microphone
USER Converts voice into
binary data

Speech
recognition API

Converts the
voice data into
text form.

Python script

Executes the command

4.system architecture

20
SYSTEM SPECIFICATIONS

HARDWARE REQUIREMENTS

Operating system - Windows 7 or above

Memory - 100mb

Internet - 100kbps

SOFTWARE REQUIREMENTS

Software tools: Python 3.8.3

Visual Studio Code

FUNCTIONAL REQUIREMENTS:
1. Respond back on the user
2. Take the command
3. If command is not properly listened, ask to repeat the
command.
4. Perform the requested task.
5. If nothing heard for a while, deactivate the assistant.

NON FUNCTIONAL REQUIREMENTS:


1. Easy to use
2. Reliable
3. Portable
4. Should work on any operating system.

21
PYTHON:-
“Python was developed by Guido van Rossum in the late eighties and early
nineties at the National Research Institute for Mathematics and Computer Science in the
Netherlands. Python is derived from many other languages, including ABC, Modula-3,
C, C++, Algol-68, SmallTalk, and Unix shell and other scripting languages.
Python is copyrighted. Like Perl, Python source code is now available under the GNU
General Public License (GPL).Python is now maintained by a core development team
at the institute, although Guido van Rossum still holds a vital role in directing its
progress.”
Python is an interpreted high level programming language.
Its language aim to help programmers write clear, logical code for small and large-scale
projects.
Python is dynamically typed . It supports multiple programming paradigms,
including structured (particularly, procedural) and functional programming.
Python is free and open source.

Features of python:-

Python supports functional and structured programming methods such as oop. It


is also used as a scripting language . Python provides very high level dynamic datatypes
and supports dynamic type checking. It also supports automatic garbage collection.
Python can be easily integrated in other languages such as c, c++, COBRA etc.

Apart from the above mentioned features, the Python language is very
easy to learn as it contains few keywords, simple structure and a clearly defined syntax
which helps us to learn it very quickly. Python code is easy to read as it has more clearly
defined syntaxes. It is also very easy to maintain. It is portable, expandable and scalable.

22
VISUAL STUDIO CODE:-

Visual Studio Code is a free source-code editor made


by Microsoft for Windows, Linux and macOS. Features include support
for debugging, syntax highlighting, intelligent code completion, snippets, code
refactoring, and embedded Git. Users can change the theme, keyboard shortcuts,
preferences, and install extensions that add additional functionality.
It is a free editor which helps the programmer to write code , helps in debugging the
code and auto corrects the mistakes. It features let the user modify the editor as per the
usage, which means, the user is able to download the libraries from the internet and
integrate it with the code as per his requirements.
• Support for multiple programming languages: It supports multiple
programming languages. So earlier, programmers needed Web-Support: a
different editor for different languages, but it has built-in multi-language support.
This also means it easily detects, if there’s any fault or cross-language reference,
it’ll able to detect it easily.
• Intelli-Sense: It can detect if any snippet of code is left incomplete. Also,
common variable syntaxes and variable declarations are made automatically. Ex:
If a certain variable is being used in the program and the user has forgotten to
declare, intelli-sense will declare it for the user.
• Cross-Platform Support: Traditionally, editors used to support either the
Windows or Linux or Mac Systems. But Visual Studio Code is cross-platform.
So it can work on all three platforms. Also, the code works on all three
platforms, else, the open-source and proprietary software codes used to be
different.

• Extensions and Support: Usually supports all the programming languages but, if
the user/programmer wants to use the programming language which is not supported
then, he can download the extension and use it. And performance-wise, the
extension doesn’t slow down the editor as it rums as a different process.

23
• Repository: With ever-increasing demand of the code, secure and timely storage
is equally important. It is connected with Git or can be connected with any other
repository for pulling or saving the instances.

• Web-Support: Comes with built-in support for Web applications. So web-


applications can be built and supported in VSC.

• Hierarchy Structure: The code files are located in files and folders. Along
with the required code files, it also has some files, which may be required for
other complex projects. These files can be deleted as per convenience.

• Improving Code: Some code snippets can be declared a bit differently,


which might help the user in the code. This function prompts the user
wherever necessary to change it to the suggested option.

• Terminal Support: Many of the times, the user needs to start from the root of
the directory to start with a particular action, in-built terminal or console
provides user support to not to switch in-between two screens for the same.
• Multi-Projects: Multiple projects containing multiple files/folders can be opened
simultaneously. These projects/folders might or might not be related to each
other.
• Commenting: A common feature, but some of the languages do not support it.
Commenting the code helps the user to recall or track according to the
sequence he wants.

24
Packages required

To build a personal voice assistant it’s necessary to install the


following packages in your system using the pip command.

1)Speech recognition — Speech recognition is an important feature used in house


automation and in artificial intelligence devices. The main function of this library is it
tries to understand whatever the humans speak and converts the speech to text.

2) pyttsx3 — pyttxs3 is a text to speech conversion library in python. This package


supports text to speech engines on Mac os x, Windows and on Linux. The pyttsx3 is an
offline module that is used for text to speech conversion in Python and it is supported
by both Python 2 & 3. The run and wait functionality is also in this module only. It
determines how much time the system will wait for another input or in other words the
time interval between inputs. This is a free module available in the python community
which can be installed using the pip command just like other modules.

3) wikipedia — Wikipedia is a multilingual online encyclopedia used by many


people from academic community ranging from freshmen to students to professors who
wants to gain information over a particular topic. This package in python extracts data’s
required from Wikipedia.

4) ecapture — This module is used to capture images from your camera

5) datetime — This is an inbuilt module in python and it works on date and time.
The DateTime module is imported to support the functionality of the date and time. For
example, the user wants to know the current date and time or the user wants to schedule a
task at a certain time. In short this module supports classes to manipulate date and time and
perform operations according to it only. This is an essential module, especially in tasks
where we want to keep a track of time. This module is very small in size and helps

25
to control the size of our program. If the modules are too large or heavy then the system
will lag and give slow responses.

6) os — This module is a standard library in python and it provides the function to


interact with operating system

7) time — The time module helps us to display time

8) Web browser — This is an in-built package in python. It extracts data from the
web. Web browser module allows the system to display web-based information to users.
For example, the user wants to open any website and he gives input as “Open Google”. The
input is processed using the web browser module and the user gets a browser with google
opened in it. The browser which will be used is the default set web browser.

9) Subprocess — This is a standard library use to process various system commands


like to log off or to restart your PC.

10) Json- The json module is used for storing and exchanging data.

11) request- The request module is used to send all types of HTTP request. Its accepts
URL as parameters and gives access to the given URL’S.

12) wolfram alpha — Wolfram Alpha is an API which can compute expert-level
answers using Wolfram’s algorithms, knowledge base and AI technology. It is
made possible by the Wolfram Language.

26
5. USE CASE DIAGRAM OF THE SYSTEM

open wikipedia

Send mail

Google search

youtube

Voice input CPU information

Tell joke

Open power point

Open excel

Open MS access

Open command

Open weather repor

Calculate

shutdown

27
6. USE CASE DIAGRAM OF SYSTEM

28
7.DATAFLOW DIAGRAM OF THE SYSTEM

29
8.DATA FLOW DIAGRAM OF THE SYSTEM

START

NO
NO
YES

CHECK IF VALID
ACTIVATION

YES

CHECK IF VALID
COMMAND

YES

EXECUTE COMMAND

STOP

30
IMPLEMENTATION OF THE SYSTEM
Building our own voice assistant is very interesting. This project is developed
on visual studio code by using python 3.8 . Python has a very good feature where it
provides us the many built in useful packages such as speech recognition API, pyjokes
which tells the jokes, web browser which performs we search, ecapture which captures
the image from our camera, Wikipedia which performs wikipedia search, pyttsx3 which
converts the text to speech and other inbuilt packages which makes the voice assistant
work more efficiently.
The DateTime module is imported to support the functionality of the date
and time. For example, the user wants to know the current date and time or the user
wants to schedule a task at a certain time. In short this module supports classes to
manipulate date and time and perform operations according to it only. This is an
essential module, especially in tasks where we want to keep a track of time. This module
is very small in size and helps to control the size of our program. If the modules are too
large or heavy then the system will lag and give slow responses.
Web browser module allows the system to display web-based information
to users. For example, the user wants to open any website and he gives input as “Open
Google”. The input is processed using the web browser module and the user gets a
browser with google opened in it. The browser which will be used is the default set web
browser.
Wikipedia is a library in python which it possible for the virtual assistant to
process the queries regarding Wikipedia and display the results to users. This is an
online library and needs an internet connection to fetch the results. The no. of lines that
the user wants to get as a result can be set manually.
Python has this module for in the standard library for working with emails
& email servers. The SMTPLIB defines an object known as “SMTP client session object”
which is used to send mails by the user. There are 3 steps involved - initialize, sendmail(),
quit. When the optional parameters which are host and port, are provided connect method is
called with these arguments during the first step which is initialization

31
The pyttsx3 is an offline module that is used for text to speech conversion
in Python and it is supported by both Python 2 & 3. The run and wait functionality is
also in this module only. It determines how much time the system will wait for another
input or in other words the time interval between inputs. This is a free module available
in the python community which can be installed using the pip command just like other
modules.
The work flow of the project is as below.
The input from the user is given in the form of voice and it converts the speech into
text to be processed by the assistant. The converted text is now processed to get the
required output. The text contains one or more keywords that determine what query is to
be executed. If the keyword does not match any of the queries in the code then the
assistant asks for user to speak again. The result is then converted to speech again to
give the output to the user.
To start the development of the below project, we need the below packages installed
in our visual code.

pip install wolframaplha


pip install wikipedia
pip install SpeechRecognition
pip install ecapture
pip install twilio
pip install beautifulsoup4

then we have to import the below packages or the libraries.


import subprocess
import winshell
import pyttsx3 #pip intstall pyttsx3
import datetime
import speech_recognition as sr #pip install speechRecognition
import wikipedia #pip install wikipedia

32
import smtplib
import webbrowser as wb
import psutil #pip install psutil
import pyjokes #pip install pyjokes
import os
import pyautogui #pip install pyautogui
import random
import json
import requests
import wolframalpha #pip install wolframalpha
from urllib.request import urlopen
import time
#import ecapture as ec

def speak(audio):

engine.say(audio)
engine.runAndWait()

def time_():
Time=datetime.datetime.now().strftime("%I:%M:%S")# for 12 hours
speak("the current time is: ")
speak(Time)

def date_():
Year=datetime.datetime.now().year
Month=datetime.datetime.now().month
Day=datetime.datetime.now().day
speak("the current date is:")

33
speak(Day)
speak(Month)
speak(Year)

def wishme(): # this is for greetings


speak("Welcome back !")
Hour=datetime.datetime.now().hour
if(Hour>=6 and Hour<=12):
speak("Good morning ! Have a nice day")
elif(Hour>12 and Hour<=18):
speak("Good afternoon r!")
elif(Hour>18 and Hour<=24):
speak("Good Evening !")
else:
speak("Good Night ! Have a Good sleep")
speak("How can I help you..!")

def sendEmail(to,content):
server=smtplib.SMTP('smtp.gmail.com',587)
server.ehlo()
server.starttls()
# for this function you must use the low secured gmail account
server.login('onlyforprojects2020@gmail.com','Projects@123')
server.sendmail('onlyforprojects2020@gmail.com',to,content)
server.close()

def joke():
speak(pyjokes.get_joke())

34
def screenshot():
img=pyautogui.screenshot()
img.save('ss.png')

def TakeCommand(): # taking command from the user


r=sr.Recognizer()
with sr.Microphone() as source:
print("Listening....")
r.pause_threshold = 1
audio = r.listen(source)

try:
print("Recognizing....")
query=r.recognize_google(audio,language="en-US")
print(query)

except Exception as e:
print(e)
print("Say that again Plzz.....")
return "None"
return query

def cpu():
usage = str(psutil.cpu_percent())
speak('CPU is at'+usage)

battery = psutil.sensors_battery()
speak('Battery is at')
speak(battery.percent)

35
if __name__ == "__main__":
while True:
commander = TakeCommand().lower()
if 'honey' in commander:
wishme()
while(True):
query = TakeCommand().lower()

if 'time' in query:
time_()

elif 'date' in query:


date_()

elif 'how are you' in query:


speak("I am fine, Thank you")
speak("How are you, Sir")

elif 'fine' in query or "good" in query:


speak("It's good to know that your fine")

elif "what's your name" in query or "What is your name" in query:


speak("I am Honey")

elif "who made you" in query or "who created you" in query:


speak("I have been created by Pratyusha.")

elif "who i am" in query:

36
speak("If you talk then definately your human.")

elif "why you came to world" in query:


speak("Thanks to Pratyusha. further It's a secret")

elif 'is love' in query:


speak("It is 7th sense that destroy all other senses")

elif "who are you" in query:


speak("I am your virtual assistant created by Pratyusha")

elif "Good Morning" in query:


speak("A warm" +query)
speak("How are you Ms.Pratyusha.")

# most asked question from google Assistant


elif "will you be my gf" in query or "will you be my bf" in query:
speak("I'm not sure about, may be you should give me some time")

elif "how are you" in query:


speak("I'm fine, glad you me that")

elif "i love you" in query:


speak("I Love You Too")

elif 'wikipedia' in query:


speak("Searching.....")
query=query.replace('wikipedia','')
result=wikipedia.summary(query,sentences=3)

37
speak("According to the wikipedia...")
print(result)
speak(result)

elif 'send email' in query:


try:
speak("what should I say?")
content = TakeCommand()
speak("Who is the reciever.?")
reciever=input("Enter the Reciever's Email Id:")

to=reciever
sendEmail(to,content)
speak(content)
speak("Email has be sent..")
except Exception as e:
print(e)
speak("Unable to send mail")

elif 'search' in query:


speak("Please Tell what should I search.?")

# chromepath = 'C:/Program Files


(x86)/Google/Chrome/Application/chrome.exe %s'
chromepath = 'chrome'
search = TakeCommand().lower()
wb.get(chromepath).open_new_tab(search +'.com')

elif 'open stackoverflow' in query:

38
speak("Here you go to Stack Over flow.Happy coding")
wb.open("stackoverflow.com")

elif 'youtube' in query:


speak("What should I search?")
search_term=TakeCommand().lower()
speak("Here we go to YOUTUBE!")
wb.open('http://www.youtube.com/results?search_query='+search_term)

elif 'google' in query:


speak("What should I search?")
search_term=TakeCommand().lower()
speak("Searching....")
wb.open('http://www.google.com/search?q='+search_term)

elif 'empty recycle bin' in query:


winshell.recycle_bin().empty(confirm = False, show_progress = False,
sound = True)
speak("Recycle Bin Recycled")

elif 'cpu' in query:


cpu()

elif 'joke' in query:


joke()

elif 'ms word' in query:


speak("Opening MS word...")
ms_word = 'winword'

39
os.startfile(ms_word)

elif 'power point' in query:


speak("Opening MS Power Point...")
ms_ppt = 'powerpnt'
os.startfile(ms_ppt)

elif 'excel' in query:


speak("Opening MS Excel...")
ms_excel = 'excel'
os.startfile(ms_excel)

elif 'ms access' in query:


speak("Opening MS Access...")
ms_access = 'msaccess'
os.startfile(ms_access)

elif 'vlc' in query:


speak("Opening VLC media player...")
vlc = 'vlc'
os.startfile(vlc)

elif 'cmd' in query or 'command prompt' in query or 'terminal' in query:


speak("Opening Command Prompt...")
cp = 'cmd'
os.startfile(cp)

#elif "camera" in query or "take a photo" in query:


# ec.capture(0, "Jarvis Camera ", "img.jpg")

40
elif "hibernate" in query or "sleep" in query:
speak("Hibernating")
subprocess.call("shutdown / h")

elif "weather" in query:

# Google Open weather website


# to get API of Open
weather api_key = "Api key"
base_url = "http://api.openweathermap.org / data / 2.5 / weather?"
speak(" City name ")
print("City name : ")
city_name = TakeCommand()
complete_url = base_url + "appid =" + api_key + "&q =" + city_name
response = requests.get(complete_url)
x = response.json()

if x["cod"] != "404":
y = x["main"]
current_temperature = y["temp"]
current_pressure = y["pressure"]
current_humidiy = y["humidity"]
z = x["weather"]
weather_description = z[0]["description"]
print(" Temperature (in kelvin unit) = " +str(current_temperature)+"\n
atmospheric pressure (in hPa unit) ="+str(current_pressure) +"\n humidity (in
percentage) = " +str(current_humidiy) +"\n description = " +str(weather_description))

41
else:
speak(" City Not Found ")

elif 'write a note' in query:


speak("What should I write! Sir?")
notes = TakeCommand()
file = open('notes.txt','w')
speak('Sir! Should I include Date and Time?')
ans=TakeCommand()
if 'yes' in ans or 'sure' in ans:
strTime=datetime.datetime.now().strftime("%H:%M:%S")
file.write(strTime)
file.write(':-')
file.write(notes)
speak('Done Taking notes..!')
else:
file.write(notes)
speak('Done Taking notes..!')

elif 'show note' in query:


speak("showing notes")
file = open('notes.txt','r')
print(file.read())
speak(file.read())

elif 'screenshot' in query:


screenshot()
speak("Screenshot Done!")

42
elif 'play music' in query or 'play song' in query:
song_dir = 'D:/songs'
music = os.listdir(song_dir)
speak("What should I play?")
ans = TakeCommand().lower()
while('number' not in ans and ans != 'random' and ans != 'you choose'):
speak('I could not understand you. please Try again..!')
ans = TakeCommand().lower()
if 'random' or 'you choose' in ans:
no = random.randint(1,100)
elif 'number' in ans:
no = int(ans.replace('number',''))
os.startfile(os.path.join(song_dir,music[no]))

elif 'remember that' in query:


speak("What should I remember Sir?")
memory = TakeCommand()
remember = open('memory.txt','w')
remember.write(memory)
remember.close()

elif 'do you remember anything' in query:


remember = open('memory.txt','w')
speak('You asked me to remember that'+remember.read())

elif 'news' in query:


try:
jsonObj = urlopen('http://newsapi.org/v2/top-headlines?
country=us&category=entertainment&apiKey=API_KEY')

43
data = json.load(jsonObj)
i=1
speak('Here are some top headlines fromm Entertainment')
print("============TOP HEADLINES=============")
for items in data['articles']:
print(str(i)+'. '+items['title']+'\n')
print(items['description']+'\n')
speak(items['title'])
i+=1
except Exception as e:
print(str(e))

elif 'where is' in query:


query = query.replace('where is','')
location=query
speak('You asked to locate'+location)
wb.open_new_tab('https://www.google.com/maps/place'+location)

elif 'calculate' in query:


client = wolframalpha.Client(wolframalpha_app_id)
indx = query.lower().split().index('calculate') query
= query.split()[indx +1: ] res =
client.query(''.join(query))
answer = next(res.results).text
print('The Answer is'+answer)
speak('The Answer is'+answer)

elif 'what is' in query or 'who is' in query:


client = wolframalpha.Client(wolframalpha_app_id)

44
res = client.query(query)
try:
print(next(res.results).text)
speak(next(res.results).text)
except StopIteration:
print('No results...')

elif 'stop listening' in query or 'dont listening' in query:


speak('For how many seconds you want me to stop listening to
your commands?')
ans = int(TakeCommand())
time.sleep(ans)
print(ans)

elif 'restart' in query:


os.system('system /r /t 1')

elif 'shutdown' in query:


os.system('system /s /t 1')

elif 'thank you' in query:


speak("You are Welcome sir.. Honey is Signing off")
exit()

45
below screenshot shots how the packages are imported

The main method of the program looks as below

46
TESTING AND TEST CASES.
Virtual assistants are difficult to test. As the project is completely dependent on
the voice commands , manual testing needs to done to check whether the assistant
is working or not.

We have performed both positive test scenarios and negative test scenarios for testing
the project. Below are the few unit test cases which are performed on the project before
converting it into an executable file.

UNIT TESTING

This type of test is targeted to voice assistant by the developers. unit testing is done to
ensure the code is working correctly in isolation. As we perform unit testing while
coding, we need it to be fast, so it doesn’t interrupt our coding pace. Unit testing is
focused on making sure our code and logic are correct .

47
Below are the few test cases that were performed to test the voice assistant.

Test case 1:-


Objective - To check if voice assistant is activated.

Steps to be performed – plug in the microphone or headset.


Run the file or application.
Say “hi honey”.
Expected output – voice assistant responds back with ” Good afternoon”

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

“Good afternoon” is heard from the assistant.

Test result - pass

Screenshot –

48
Test case 2:-
Objective - To check if voice assistant can save notes in notepad.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “I need to write notes”.

Say “present I am in a typical situation I need your help”.

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

Notes should save on the notepad .

“ Done taking notes” is printed on the console output

Test result - pass

Screenshot –

49
Test case 3:-
Objective - To check if voice assistant can tell us the date and time.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “I need to current date”

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

6/02/2021 is printed on console output .

Voice assistant responds back telling the current date.

Test result - pass

Screenshot –

50
Test case 4:-
Objective - To check if voice assistant can tell us the weather report of Visakhapatnam.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “I need to weather report”

Say name of the city you wish to look into.

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

Responds back asking the city name.

Voice assistant speaks about the weather about the city.

Weather report is printed on the console output.

Test result - pass

Screenshot :-

51
Test case 5:-
Objective - To check if voice assistant can tell us the latest new headlines.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “I need to latest news”

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

Voice assistant reads the latest news headlines.

News is printed on the console output.

Test result - pass

Screenshot -

52
Test case 6:-
Objective - To check if voice assistant can perform mathematical calculations.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “calculate sin 45”

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

Voice assistant tells the result.

Result is printed on the console output.

Test result - pass

screenshot -

53
Test case 7:-
Objective - To check if voice assistant can tell a joke.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “tell me a joke”

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

Voice assistant tells the joke.

Joke should be printed on the console output.

Test result - pass

Screenshot -

54
Test case 8:-
Objective - To check if voice assistant can open a stop watch.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “open stop watch”

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

Voice assistant opens stop watch.

Stop watch is opened.

Test result - pass

Screenshot:-

55
Test case 9:-
Objective - To check if voice assistant can tell about the cpu status.

Steps to be performed – plug in the microphone or headset.

Run the file or application.

Say “I need my cpu status”

Expected output – voice assistant responds back

“Listening…..” is printed on the console output.

“Recognizing……” is printed on the console output.

Voice assistant tells us the current battery of the cpu.

Current status is printed on the console output..

Test result - pass

56
CHALLENGES FACED WHILE TESTING
There are many different types of testing — unit, system, integration, performance,
endurance, etc. These all carry over to Voice, but there are challenges to be ready for

While testing the voice assistant the below points needs to be considered.

Language and accents: It is obvious that people speak different languages in different
regions. Therefore, voice assistants need to be able to understand and answer queries
in various languages.
Time required For manual testing - Currently Voice testing is carried out
manually.we have to do trial and error methods to find suitable test strategies
However,this process is extremely time-consuming, especially when the number of
test cases are more.
Make sure your devices have good connectivity - the device should be connected to
strong internet connection. Poor connection will may raise bugs . Though, Sometime due
to poor connection application cannot get proper command and in return we do not get
proper response as we accepted. When only voice is our medium of communication
make sure that it sounds soothing to the device and conversation should be kept simple.
It’s important to test multiple phrases that can be used to call an intent within your voice
app.Need to have control on speech of pace, have a balance between our breath and our
voice, need to have a right places for better impact. Should have perfect distance
between ourself and device we are testing so your voice can be recognized properly.

A lot of issues can be found only during manual testing because people speak
differently in voice and text channels, and various speech-to-text issues may show
more issues.

Devices such as Echo or Home should be tested across the room. Test with
high ambient background noise.

57
CONCLUSION AND DISCUSSIONS
In this project we have developed a Voice Activated Personal Assistant
developed using python. This assistant currently works online and performs basic tasks
like weather updates, stream music, search Wikipedia, open desktop applications, etc.
The functionality of the current system is limited to working online only. The upcoming
updates of this assistant will have machine learning incorporated in the system which
will result in better suggestions with IoT . The usage of the assistant will get offline also
for features that don’t require an internet connection.
The basic commands that the voice assistant could perform are to open any
software that is installed in the desktop or the laptop. It can respond back to any query
that the users asks for such as the current time, date, weather report , news etc.
It can open power point, ms access, notepad, you tube, and many more.
It can also perform various other activities such as locking a system , shutting down the
system, logging off , restarting the system.
The voice assistant we have developed is a desktop-based built using python
modules and libraries. This assistant is just a basic version that could perform all the basic tasks
which have been mentioned above but current technology is although good in it is still to be
merged with Machine Learning and Internet Of Things(IoT) for better enhancements. All you
need to do is give a command to the assistant and the rest will be performed by the assistant.
With the help of voice-activated virtual assistants, there will be no need to write long codes to
perform a task, the system will do so for us.

ADVANTAGES OF THIS PROJECT:-


A virtual voice assistant is developed using python speech recognition API
which performs the various tasks using only voice commands. Visually challenged
people, children, old and middle aged people or the group of people who are having
eye sight issues and IT employees are most benefitted with the desktop voice assistant.

58
Few tasks that the voice assistant can perform are:

1. checks weather updates


2. Sends mails
3. Search on Wikipedia
4. Open applications
5. Provides CPU status
6. Tells jokes
7. Reads latest news.
8. Opens youtube
9. Plays songs
10. Opens notepad/text files
11. Opens goggle and browses
12. Empties the recycle bin
13. Opens ms access
14. Opens Microsoft power point
15. Shows notes
16. Takes screenshots
17. Reads news
18. Locates words in the large file
19. Restarts the system
20. Shut downs the system
21. Locks the system

59
DISADVANTAGES :
As we have advantages for any softwares, we equally or less have
disadvantages too. The below are the disadvantages I found while developing the
project.

The desktop voice assistant needs internet to run. If there is no internet connection
then desktop assistant will not get activated even if the activation code is said by the
user many times. The other disadvantage is that the voice assistant activates to any voice
irrespective of the who the owner of the desktop or laptop is. So every body is able to
access any desktop using the voice commands.

60
FUTURE WORK
The understanding and reliability of the current systems need to be improved a lot.
The assistants developed now is not much reliable in critical scenarios. We can make
their assistant more efficient by using other technologies like Machine learning, neural
networks , IoT ets.. With the involvement of IoT, it will be possible to control other
smart devices that will in-turn interact among themselves over the internet. So with a
capable virtual assistant, we will be able to control many things around us single-
handedly with only one platform.

A greater UI can be designed . the UI which is not concentrated in many of the


virtual assistants these days, also needs an attractive UI when it comes to mobile voice
assistants or the desktop voice assistants. Improve python langhements in the UI can be
done in future for tha voice assistants by using python language itself.

Currently the voice assistant that we developed works online gTTS (Google
Text to Speech) requires the data to be activated and to convert the text into speech.

This can also be overcome with other technologies like neural networking in future.

61
REFERENCES:

1. Artificial Intelligence: A Modern Approach” by Stuart Russell and Peter Norvig


2. Udemy
3. Google
4. en.wikipedia.org/wiki/Artificial_intelligence
5. youtube – artificial intelligence by
6. Applications of AI". www-formal.stanford.edu. Archived from the original on 28
August 2016. Retrieved 25 September 2016

7. Artificial Intelligence Full Course | Artificial Intelligence Tutorial for Beginners |


Edureka

8. https://www.codespeedy.com/get-voice-input-with-microphone-in-python-using-
pyaudio-and-speechrecognition

9. International Journal of Recent Technology and Engineering (IJRTE) ISSN:


2277-3878, Volume-9 Issue-2, July 2020

62

You might also like