Python
Python
ON
Virtual Assistance using Python
Submitted By
Harsh Chaudhary (1901920100113)
Vivek Payla (1901920100331)
Sarvesh Singh (1901920100257)
Ayush Mishra (1901920100071)
2022-2023
1
Declaration
We hereby declare that the project work presented in this report entitled “Virtual
Assistant using Python”, in partial fulfillment of the requirement for the award of
the degree of Bachelor of Technology in Computer Science & Engineering,
submitted to A.P.J. Abdul Kalam Technical University, Lucknow, is based on our
own work carried out at Department of Computer Science & Engineering, G.L.
Bajaj Institute of Technology & Management, Greater Noida. The work contained
in the report is true and original to the best of our knowledge and project work
reported in this report has not been submitted by us for award of any other degree
or diploma.
Signature:
Signature:
Signature:
Signature:
2
Name: Ayush Mishra
Date:
3
Certificate
This is to certify that the Project report entitled “Virtual Assistant using Python
”done by Harsh Chaudhary (1901920100113), Vivek Payla (1901920100331),
Sarvesh Singh (1901920100257) and Ayush Mishra (1901920100071) is an
original work carried out by them in Department of Computer Science &
Engineering, G.L. Bajaj Institute of Technology & Management, Greater Noida
under my guidance. The matter embodied in this project work has not been
submitted earlier for the award of any degree or diploma to the best of my
knowledge and belief.
Date:
4
Acknowledgement
The merciful guidance bestowed to us by the almighty made us stick out this
project to a successful end. We humbly pray with sincere heart for his guidance to
continue forever.
We pay thanks to our project guide Mr. Shivam Tiwari who has given guidance
and light to us during this project. His/her versatile knowledge has helped us in the
critical times during the span of this project.
We pay special thanks to our Head of Department Dr. Sansar Singh Chauhan
who has been always present as a support and help us in all possible way during
this project.
We also take this opportunity to express our gratitude to all those people who have
been directly and indirectly with us during the completion of the project.
We want to thanks our friends who have always encouraged us during this project.
At the last but not least thanks to all the faculty of CSE department who provided
valuable suggestions during the period of project.
5
Abstract
6
TABLE OF CONTENT
i) Declaration
ii) Certificate
iii) Acknowledgement
iv) Abstract
Chapter 5. Implementation………….……………………………….…….46-57
v) References ……………………………………………………………………..61
Appendix I …………………………………………………………...…62
Appendix II …….……………………………………………………….63
Appendix III ...……………………………………………………………...…64
7
LIST OF FIGURES
8
Figure 5.1 Code ……………………………………………….……47
9
10
Chapter 1
Introduction
We as of now have different menial helpers. In any case, we scarcely use it. There
are number of individuals who have issues in voice acknowledgment. These
frameworks can figure out English expressions however, they neglect to perceive
in our articulation. Our method of elocution is way particular from theirs.
Likewise, they are not difficult to use on cell phones than work area frameworks.
There is need of a virtual right hand that can grasp English in Indian pronunciation
and work on work area framework.
At the point when a menial helper can't respond to questions precisely, this is on
the grounds that it needs the legitimate setting or doesn't figure out the goal of the
inquiry. Its capacity to reply questions pertinently just occurs with thorough
advancement, including the two people and AI. Consistently guaranteeing strong
quality control methodologies will likewise help make due the gamble of the
remote helper learning undesired terrible ways of behaving. They require
enormous measure of data to be taken care of for it to productively work.
11
Menial helper ought to have the option to show complex assignment conditions
and utilize these models to suggest streamlined plans for the client. It should be
tried for seeing as ideal ways when an undertaking has different sub-errands and
each sub-errand can have its own sub-assignments. In such a case there can be
different answers for ways, and the considering user ought to be capable
inclinations, other dynamic errands, needs to suggest a specific arrangement.
Here's a general overview of the steps involved in creating a virtual assistant using
Python:
· Define the functionality: Define the specific tasks and functions that
your virtual assistant will perform. For example, you may want it to
answer questions, provide information, schedule appointments, play
music, or perform other tasks.
12
· Implement natural language processing: Use natural language
processing (NLP) techniques to analyze user input and extract
relevant information. The NLTK library can be used for this purpose,
providing functions for tokenization, part-of-speech tagging, and
named entity recognition.
· Develop the response system: Based on the user input and the
extracted information, develop a system to generate appropriate
responses. This could involve using pre-built response templates or
generating responses dynamically based on the input.
· Test and refine: Test the virtual assistant and refine it based on user
feedback and usage data.
13
Chapter 2
Literature Survey
2.1 Introduction
A virtual assistant operates devices such as laptops and PCs at your discretion. A
virtual assistant is an application software that can perform functions for users by
understanding natural language via voice instructions. A virtual assistant is used to
perform routine duties such as displaying the date and time, managing emails,
opening apps, and so on. Virtual assistants are currently quite useful to people.
The ability to operate PCs or laptops purely using voice commands simplifies
people's lives. Using it means saving time. We can contribute to multiple projects
while saving time by using a virtual assistant. Virtual assistants are typically
cloud-based applications that require internet-connected devices. The ability to
employ a virtual assistant solely for the services they require. Begin by learning
the principles of Python in order to develop a virtual assistant for your computer.
There are several speech assistants on the market, including Alexa, a Raspberry
Pi-powered smart speaker, Siri for the Apple TV remote, Google Assistant for the
Pixel XL smartphones, and Microsoft Cortana for Windows 10.We created a
virtual assistant for Windows, similar to all other virtual assistants. We apply
artificial intelligence technology for this project. Python can also be used as a
14
programming language because it has several outstanding Main Libraries.
1. Google Search
2. YouTube Search
3. Wikipedia Search
4. YouTube Control
5. Speed Test
8. Screen Shot
9. Translate
15
We will also be including a Graphical User Interface(GUI). The GUI will increase
the convinience of the user in using the software.
Command to be given:-
Output:-
Assistant will read out about the search user just did and also open the browser
with search.
16
11. Youtube Search
Command to be given:-
Output:-
17
Command to be given:
Output:-
Command to be given:
18
Command to be given:-
Output:-
19
Command to be given:
Output:
20
16. Open / Close any App
Command to be given:
Output:
17. Translate
21
Command to be given:
Output:
18. ScreenShot
Command to be given:
22
Many virtual office assistants already exist. This section presents several examples
of virtual assistants currently available on the market, as well as the tasks they can
provide and their shortcomings.
SIRI
SIRI is personal assistant software that communicates with users through a voice
interface, recognizing and responding to commands. It learns to adapt to the user's
voice, improving speech recognition over time. It also tries to talk to the user
when it doesn't recognize the user's request.
It integrates with the device's calendar, contacts, and music library apps, as well as
the device's GPS and camera. It uses location, time, social and task-based context
to customize agent behaviour specific to a user at a given time.
23
Python
Pyttsx
24
Pyttsx3 is a Python library that provides a simple and easy-to-use interface for
converting text to speech. It supports multiple speech engines, including eSpeak,
Festival, and Microsoft Speech API (SAPI). The library allows you to customize
the properties of the speech, such as the rate, volume, and voice. It provides event-
driven and blocking modes for speech output, and can be used with Python 2 and
Python 3.
Using pyttsx3, you can create a pyttsx3 object by calling the init() method, and
then use the say() method to convert text to speech. The runAndWait() method is
used to run the speech. You can also set the properties of the pyttsx3 object, such
as the rate of speech, the volume, and the voice. This allows you to customize the
speech output to better suit your needs.
Speech Recognition
PyAudio: This is a Python library for audio input and output, which can be used in
conjunction with other speech recognition modules to capture audio input.
Web Browser
25
Python has a built-in module called webbrowser that allows you to control the
web browser installed on your computer and open web pages from within a
Python script.
PyAutoGUI
PyAutoGUI also provides methods for typing text, pressing keys, taking
screenshots, and more.
PyWhatKit
26
Pywhatkit is a Python library that permits clients to mechanize a few undertakings
on their PC utilizing Python code. A portion of the undertakings that can be
computerized utilizing Pywhatkit incorporate sending WhatsApp messages,
looking for data on Google, playing YouTube recordings, producing QR codes,
switching message over completely to manually written notes, and some more.
To utilize Pywhatkit, you first need to introduce it on your PC utilizing pip. You
can do this by running the accompanying order in your terminal or order brief:
Whenever you have introduced Pywhatkit, you can bring it into your Python code
and begin utilizing its capabilities. For instance, to send a WhatsApp message
utilizing Pywhatkit, you can utilize the accompanying code:
Pywhatkit gives numerous different capabilities that you can use to robotize
different assignments on your PC.
PyWikiHow
The PyWikiHow module is a Python library that permits clients to get to and
recover how-to articles from the site wikiHow. With the PyWikiHow module, you
can look for how-to articles, recover directions and steps, and concentrate explicit
areas or sentences from the articles.
27
To utilize the PyWikiHow module, you first need to introduce it on your PC
utilizing pip. Whenever you have introduced the PyWikiHow module, you can
bring it into your Python code and begin utilizing its capabilities.
OS
The os module is a built-in Python library that provides a way to interact with the
operating system. With the os module, you can perform various tasks such as file
and directory operations, process management, and environment variables
manipulation.
Wikipedia
The Wikipedia module is a Python library that permits clients to collaborate with
the Wikipedia Programming interface and concentrate data from Wikipedia
articles. With the Wikipedia module, you can look for articles, recover article
synopses, and concentrate explicit areas or sentences from articles. To utilize the
Wikipedia module, you first need to introduce it on your PC utilizing pip. You can
do this by running the accompanying order in your terminal or order brief.
Whenever you have introduced the Wikipedia module, you can bring it into your
Python code and begin utilizing its capabilities. To recover an outline of a
Wikipedia article, you can utilize the rundown() capability.
For instance: This code will recover a rundown of the Wikipedia article on the
Python programming language and print it to the control center. There are
numerous different capabilities that you can use with the Wikipedia module to
extricate data from Wikipedia articles.
28
Tkinter
Tkinter comes pre-installed with most versions of Python, so you don't need to
install anything separately to use it. To get started, you can import Tkinter by
using the following code:
DateTime
datetime is a Python module that provides classes for working with dates, times,
and time intervals. The datetime module contains four main classes: date, time,
datetime, and timedelta.
date: represents a date (year, month, and day) in the Gregorian calendar. You can
create a date object using the date(year, month, day) constructor.
time: represents a time (hour, minute, second, microsecond) without a date. You
can create a time object using the time(hour, minute, second, microsecond)
constructor.
datetime: represents a date and time together. You can create a datetime object
using the datetime(year, month, day, hour=0, minute=0, second=0,
microsecond=0) constructor.
29
SpeedTest
speedtest-cli is a Python package that allows you to test the speed of your internet
connection from the command line. It works by connecting to a nearby server and
measuring the upload and download speeds.
Pygame
Pygame is a Python library that provides functionality for building games and
multimedia applications. It is built on top of the SDL (Simple DirectMedia Layer)
library, which provides low-level access to audio, keyboard, mouse, joystick, and
graphics hardware.
PIL
PIL (Python Imaging Library) is a Python library for working with image files.
PIL provides a number of modules for image processing, including Image,
ImageDraw, ImageEnhance, ImageFilter, and ImageOps.
30
GTTS (Google Text-To –Speech)
GTTS is often used in various applications and services, such as screen readers,
language learning apps, and virtual assistants, among others. It is available in
several languages and can be accessed through an API, making it easy to integrate
with different platforms and devices.
Overall, GTTS is a useful tool for anyone who needs to convert written text into
spoken words quickly and efficiently.
GoogleTrans
Googletrans is a Python library that uses the Google Translate API to provide easy
access to machine translation capabilities. It allows developers to easily translate
text from one language to another using Google's powerful translation engine. The
library supports a wide range of languages and provides advanced features such as
automatic language detection and transliteration. Googletrans can be used for a
variety of purposes, from translating website content to building multilingual
chatbots. However, it's important to note that Google's terms of service limit the
number of translations that can be made using the API without paying for
a subscription.'
31
PlaySound
Playsound is a Python library for playing audio files. It provides a simple interface
for playing WAV files on Windows and Mac operating systems. The library is
easy to install using the pip package manager and can be used in a variety of
applications, such as playing sound effects in games, playing music in a
command-line interface, or providing audio feedback in an interactive application.
The playsound library works by launching an external media player program (e.g.,
Windows Media Player on Windows or QuickTime Player on Mac) and
instructing it to play the audio file. This means that the behavior of the library may
vary depending on the media player installed on the user's system.
Pynput
Pynput is a Python module for controlling and monitoring input devices such as
keyboards and mice. It provides a simple interface for interacting with input
devices, making it simple to automate and handle numerous computer operations.
Pynput allows you to imitate keystrokes and mouse clicks, read and monitor
keyboard and mouse inputs, and manipulate the location of the mouse pointer.
This library has several uses, including automation, gaming, and accessibility
tools.
Pynput supports two basic input device control and monitoring classes: keyboard
and mouse. The keyboard class handles delivering keystrokes and hotkeys,
whereas the mouse class handles managing the mouse pointer's location and
clicking mouse buttons.
32
Chapter 3
Problem Formulation
As we all know, everyone has unique characteristics and every developer has their
own approach and approach to product development.
One assistant can synthesize speech more qualitatively, another can perform tasks
more accurately without additional interpretation or correction, and the other can
perform a narrower range of tasks more accurately depending on the needs of the
audience.
Therefore, there is no wizard that can perform all jobs and tasks in the same way.
The range of qualities of an assistant depends on the areas of development that
receive the most attention. Since all systems are based on machine learning and
use large amounts of data collected from various sources and then trained on it,
the origin of this data plays an important role.
No matter how different methods are used to learn different algorithms, the
fundamentals of creating a voice assistant are the same. Speech recognition,
phonetics education, voice biometrics, conversation managers, natural language
understanding and named entity recognition are technologies used to create voice
assistants that can communicate with people.
33
Chapter 4
Personal assistant software should act as an interface into the digital world,
understanding user requests or commands and translating them into actions or
recommendations based on the agent's understanding of the world.
The JIA focuses on eliminating the need for users to enter text, instead relying on
speech as the user's primary mode of input. The agent then uses a voice
recognition algorithm on that entry and records it. It then uses this entry to call one
of the personal information management applications, such as To-Do List, to save
a new entry, or to search for it on search engines such as Google, Bing, or Yahoo.
The focus is on capturing user input by voice, recognizing the input, and then
executing the task if the agent understands it.
The software interprets this natural language input, making it easier for the user to
grasp what they want to accomplish.
1. Google Search
34
2. Youtube Search
3. Wikipedia Search
4. Youtube Control
5. Speed Test
8. Screen Shot
9. Translate
35
4.2 HARDWARE AND SOFTWARE REQUIREMENTS
Hardware:
Software:
• Chrome Driver
36
4.3 System Design
4.3.1 ER DIAGRAM
Fig 4.1
The diagram above illustrates the entities and relationships of the virtual assistant
system. System users can access their keys and values. It can be used to store all
user related data. Let's say "Jim" is a possible value for the key "name". Users may
wish to keep certain keys in a safe place.
The same user can ask several requests. Each question has its own ID so that it can
be identified with the question and accompanying answers. A user can work on
several things. Each of them should have a unique id and state, or whatever state it
is currently in.
Whether it is a parent task or a subtask of a parent job, a task must also have a
priority value and its category.
37
4.
3.
2
ACTIVITY DIAGRAM
Fig 4.2
38
4.3.3 CLASS DIAGRAM
Fig 4.3
The class user has two attributes: an audio command that it gives and an audio
response that it receives. It works by listening to user commands. After
interpreting it, respond or send a response back in line with it. The command is
present in string form in the question class after interpret class interprets it. Based
on its identity, it delivers it to the general, about, or search functions.
39
4.3.4 USE CASE DIAGRAM
Fig 4.4
One user is all there is in this project. The system receives a command from the
user. The system then understands it and retrieves the response. The user receives
the response in return.
40
4.3.5 SEQUENCE DIAGRAM
Fig 4.5.1
41
4.3.5.2 Sequence diagram for Task Execution
Fig 4.5.2
The user gives an audio command to the virtual assistant. The interpreter receives
the command. It recognises the request made by the user and sends it to the task
executor. The virtual assistant contacts the user again if any information is missing
from the job. The task is completed after the information is received and provided
back to it. Following execution, the user receives feedback.
42
4.6 DATA FLOW DIAGRAM
Fig 4.6.1
43
4.6.2 DFD Level 1
Fig.4.6.2
44
Managing User Data
Fig(4.6.4)
45
4.3.7 COMPONENT DIAGRAM
Fig 4.7
46
Chapter 5
Implementation
1. pyttsx3
2. speech recognition
3. pyautogui
4. os
5. datetime
6. pynput
7. pywhatkit
8. wikipedia
9. webbrowser
10. speedtest
11. googletrans
12. gtts
13. playsound
47
5.2 Code
Fig 5.1
48
Fig 5.2
49
Fig 5.3
50
Fig 5.4
51
Fig 5.5
52
Fig 5.6
53
Fig 5.7
54
Fig 5.8
55
Fig 5.9
56
Fig 5.10
57
Fig 5.11
58
Chapter 6
Virtual assistants are there for you at specific times, so you can always use
them and adapt quickly to changing needs.
Virtual assistants will be at your service, as well as others such as family and
colleagues if their workload allows.
59
Chapter 7
7.1 Conclusion
These are some technological aspects which are required not only in our project
but also in most other virtual assistants.
Whatsapp Automation: WhatsApp automation is the prime future scope for our
project it will not only send and read out your messages but also will be able to
upload status just by using voice command.
60
Google Maps Automation:
As technology advances, the range of virtual assistants using Python will only
grow, and we can expect to see them integrated into every aspect of our daily
lives.
7.3 Limitations
Privacy concerns: Virtual assistants are always listening and recording, which can
raise privacy concerns for some users. There have been instances of virtual
assistants recording conversations without user consent or accidentally activating
in response to background noise.
Despite these limitations, virtual assistants can still be useful tools for many users
and have the potential to become even more sophisticated in the future.
61
References
5. I., Agrawal, H., Singh, N., Kumar, G., Yagyasen, D. D., & Vikram Singh, M.
S. (2021). Research Paper on Voice Assistant Using Python, Retrieved from
https://ijirt.org/Article?manuscript=152099
62