Full Doc Major Project Groop
Full Doc Major Project Groop
On
BACHELOR OF TECHNOLOGY
In
By
i
2020-2024
CERTIFICATE
This is to certify that the MAJOR PROJECT work entitled “AI Powered Personal
Assistant” is carriedout by MUTHOJU SRIYA (20N31A04F3), PENDYALA NIKHILANAND
(20N31A04G6), PURALASETTY SAI KIRAN (20N31A04H5) in partial fulfillment for the
award of degree of BACHELOR OF TECHNOLOGY in Electronics and communication
Engineering, Jawaharlal Nehru Technological University , Hyderabad during the
academic year 2023-2024.
EXTERNAL EXAMINER
i
DECLARATION
I hereby declare that the Major Project titled “AI Powered Personal Assistant” submitted
to Malla Reddy College of Engineering and Technology (UGC Autonomous), affiliated to
Jawaharlal Nehru Technological University Hyderabad (JNTUH) for the award of the
degree of Bachelor of Technology in, Electronics and Communication Engineering is a
result of original research carried-out in this thesis. It is further declared that the Major
Project report or any part thereof has not been previously submitted to any University or
Institute for the award of degree or diploma.
i
ACKNOWLEDGEMENTS
I feel myself honored and privileged to place my warm salutation to my college Malla
Reddy College of Engineering and Technology (UGC-Autonomous) and to our Director
Dr. VSK Reddy and Principal Dr.S.Srinivasa Rao and Dr.T Venugopal Dean-students
Welfare who gave us the opportunity to have experience in engineering and profound
technical knowledge.
I express our heartiest thanks to Prof. P. Sanjeeva Reddy, Dean International Studies
and Dr. K. Mallikarjuna Lingam, Head of the Department of Electronics and
Communication Engineering for encouraging me in every aspect of my project and
helping me realize my full potential.
I would like to thank Dr.Sadand Yadav, MAJOR PROJECT Coordinator, for his valuable
guidance and encouragement during my dissertation work. I would like express my
sincere gratitude to the PRC Members Dr.Sadand Yadav, and Mrs.N.Saritha , for their
valuable suggestions in the Project Reviews.
I would like to thank our internal guide Mrs. K. Vijaya Bharathi (Assistant Professor) for
her regular guidance and constant encouragement.I are extremely grateful to her
valuable suggestions and unflinching co-operation throughout project work.
I would also like to thank all the supporting staff of the Department of ECE and all other
departments who have been helpful directly or indirectly in making my project a
success. I am extremely grateful to my parents for their blessings and prayers for the
completion of our project that gave us strength to do my project.
By
Muthoju Sriya - 20N31A04F3
Pendyala Nikhilanand - 20N31A04G6
Puralasetty Sai kiran - 20N31A04H5
i
CONTENTS
1.1 Overview 2
1.2 Design 3
3.4 Software 10
3.5 Libraries 10
3.6.1 Python 11
3.6.2 Domain 12
Chapter 4 – Methodolgy 18
References 31
LIST OF FIGURES
AI-powered voice assistants have become an integral part of our lives, intertwining
technology and daily tasks. A Personal Virtual Assistant allows a user to command or ask
questions in the same manner that they would do with another human and are even
capable of doing some basic tasks like opening apps, doing Wikipedia searches without
opening a browser, playing music etc, with just a voice command. In the current days, a
voice assistant is everywhere which is a lot useful in these busy days. Nowadays, almost
everyone in the current world is using voice assistant because it’s everywhere starting
from Google smartphone assistant which even 5 years old kids will know how to use
because of the current world pandemic which makes them use smartphones till
Amazon's Alexa which will be very useful to do works starting from entertaining the
users till turning on and off the household products (Internet of Things). This project
presents the development of a personal desktop assistant using Python, aiming to
provide convenience, automation, and assistance to users in their computer-related
activities.The assistant differentiates itself from existing solutions by offering a highly
customizable and extensible platform.The user interface is designed to be intuitive and
user-friendly, providing a seamless experience for both novice and experienced users.
Key words: Automation, Integration, Functionality,Convenience.
Page 1
Malla Reddy College of Engineering & Technology Department of ECE
CHAPTER 1
INTRODUCTION
1.1 OVERVIEW
The very first voice activated product was released in 1922 as Radio Rex. This toy
was very simple, wherein a toy dog would stay inside a dog house until the user
exclaimed its name, “Rex” at which point it would jump out of the house. This was all
done by an electromagnet tuned to the frequency similar to the vowel found in the word
Rex, and predated modern computers by over 20 years.
In the 21st century, human interaction is being replaced by automation very quickly.
One of the main reasons for this change is performance. There’s a drastic change in
technology rather than advancement. In today’s world, we train our machines to do
their tasks by themselves or to think like humans using technologies like Machine
Learning, Neural Networks, etc. Now in the current era, we can talk to our machines
with the help of virtual assistants.
Nowadays almost all jobs are done digitally. We have Smartphones in our hands and
nothing less than having the world in our hands. These days we don't even use our
fingers. We are just talking about work and it is done. There are plans where we can say
to the Father of the Scriptures, "I'll be late today." Text is also sent. That is the work of
the Visible Assistant. It also supports specialized functions such as booking a flight, or
getting the cheapest book online from various e-commerce sites and provides an order
booking link, which facilitates automatic search, discovery, and online ordering services.
Wise assistants based on the word need a persuasive word or a wake-up call to make
the listener active, which is followed by a command. In my project the rising name is
MAX. We have many visible assistants, such as Apple's Siri, Amazon's Alexa, and
Microsoft's Cortana. In this project, the wake-up name is selected for MAX.
Virtual Assistants can provide several services including,
• The weather.
• Scheduling appointment time.
• Trip planning.
• Play music, movies, etc.
• Indicates the time of day.
• Manage emails.
• Open applications..
1.2 DESIGN
a) The voice assistant takes an input word which is called as "signal word" to be
activated. so, it takes in the signal word and starts operating for the user
commands.
b) Converting the speech into text will be processed by the assistant.
c) The converted text is now processed to get the required results.
d) The text given by the user should contain 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) Finally, the output to the user's query will be given by converting speech to text.
1.5WHERE TO USE IT
Voice search has been a hot topic of discussion. Voice visibility will undoubtedly be a
challenge. This is due to the lack of a visual interface for voice assistants. Users cannot see or
interact with a voice interface unless it is linked to the Alexa or Google Assistant app. Search
behavior patterns will change dramatically as a result.
Brands are currently undergoing a transformation in which touchpoints are transforming
into listening points, and organic search will be the primary means of brand visibility.
Advertising agencies are becoming more popular as voice search grows in popularity. Voice
assistants will also continue to offer more individualized experiences as they get better at
differentiating between voices. The number of people using voice assistants is expected to
grow. According to the Voice bot Smart Speaker Consumer Adoption Report 2018, almost ten
percent of people who do not own a smart speaker plan to purchase one. If this holds true,
the user base of smart speaker users will grow 50 percent, meaning a quarter of adults in the
United States will own a smart speaker.
CHAPTER 2
LITERATURE REVIEW
➢ Nivedita Singh (2021) et al. proposed a voice assistant using python speech to
text (STT) module and had performed some api calls and system calls which has
led to developing a voice assistant using python which allows the user to run
any type of command through voice without interaction of keyboard. This can
also run on hybrid platforms. Therefore, this paper lacks in some parts like the
system calls that aren’t much supported.
with a SQLite DB with the use of Python. This Project has a Database connection
and a query framework but lacks API call and System calls features.
➢ V. Geetha (2021) et al. presented a project named The Voice Enabled Personal
Assistant for Pc using Python. This Author has proposed assistant project with
python as a backend and features like turning our PC off, or restarting it, or
reciting some latest news, are just one voice command away. Also, this project
has well supported library not every API will have the capability to convert the
raw JSON data into text. And there is a delay in processing request calls.
➢ Rahul Kumar (2020) et al. has proposed Power Efficient Smart Home with voice
assistant by which we can say that a Voice Assistant is one of the important
part of the Smart home which is becoming one of the major things in the
current world as it can operate the Home Appliances just with voice which also
increase the home security because of the smart locks but it requires a reliable
internet connection which is crucial and sometimes, the user might lock
themselves out of their own house.
➢ Tae-Kook Kim (2020) el at. has proposed a Short Research on Voice Control
System Based on Artificial Intelligence Assistant which states AI assistant
system using open API artificial intelligence, and the conditional auto-run
system, IFTTT (IF This, Then That). It can control the system using the Raspberry
PI board but it lacks system calls.
CHAPTER 3
METHODOLOGY
Then we define the speak function to enable the program to speak the outputs. After that
we will define a function to take voice commands using the system microphone. The main
function is then defined where all the capabilities of the program are defined.
(d) Features supported in the current version include playing music, texts, search on
Wikipedia, or opening system installed applications, opening anything on the web
browser, etc.
3.5 LIBRARIES
➢ Serial- This module encapsulates the access for the serial port. It provides
backends for Python running on Windows, OSX, Linux, BSD and Iron Python. The
module named “serial” automatically selects the appropriate backend. Command
to install :- pip install pyserial
➢ Time- This module provides many ways of representing time in code, such as
objects, numbers, and strings. It also provides functionality other than
representing time, like waiting during code execution and measuring the
efficiency of our code. This is a built-in module so the installation is not necessary.
➢ Wikipedia :-This is a Python library that makes it easy to access and parse data
from Wikipedia. Search Wikipedia, get article summaries, get data like links and
images from a page, and more. Wikipedia is a multilingual online encyclopedia.
Command to install :- pip install Wikipedia.
➢ Pyttsx3- It is a text to speech conversion library in python which is used to convert
the text given in the parenthesis to speech. It is compatible with python 2 and 3.
An application invokes the pyttsx3.init() factory function to get a reference to a
pyttsx3. it is a very easy to use tool which converts the entered text into speech.
The pyttsx3 module supports two voices first is female and the second is male
which is provided by “sapi5” for windows. Command to install: - pip install pyttsx3
It supports three TTS engines: - sapi5- To run on windows nsss -
NSSpeechSynthesizer on Mac OS X espeak – eSpeak on every other platform
➢ Speech_recognition- It allows computers to understand human language. Speech
recognition is a machine's ability to listen to spoken words and identify them. We
can then use speech recognition in Python to convert the spoken words into text,
make a query or give a reply. Python supports many speech recognition engines
and APIs, including Google Speech Engine, Google Cloud Speech API.
Command to install :- pip install SpeechRecognition
➢ WolfarmAlpha- Wolfram Alpha is an API which can compute expert-level answers
using Wolfram's algorithms, knowledgebase and AI technology. It is made
possible by the Wolfram Language. The WolfarmAlpha API provide a web-based
API allowing the computational and presentation capabilities of WolframAlpha to
be integrated into web, mobile and desktop applications.
Command to install :- pip install wolframalpha
➢ Randfacts- Randfacts is a python library that generates random facts. We can use
randfacts.get_fact() to return a random fun fact.
Command to install :- pip install randfacts
➢ Pyjokes- Pyjokes is a python library that is used to create one-line jokes for the
users. Informally, it can also be referred as a fun python library which is pretty
simple to use. Command to install :- pip install pyjokes
➢ Datetime- This module is used to get the date and time for the user. This is a built-
in module so there is no need to install this module externally. Python Datetime
module supplies classes to work with date and time. Date and datetime are an
3.6.2 DOMAIN
• The internet of things, or IoT, is a system of interrelated computing devices,
mechanical and digital machines, objects, animals or people that are provided with
unique identifiers (UIDs) and the ability to transfer data over a network without
requiring human-to-human or human-to-computer interaction.
• A thing in the internet of things can be a person with a heart monitor implant, a
farm animal with a biochip transponder, an automobile that has builtin sensors to
alert the driver when tire pressure is low or any other natural or man-made object
that can be assigned an Internet Protocol (IP) address and is able to transfer data
over a network.
• Increasingly, organizations in a variety of industries are using IoT to operate more
efficiently, better understand customers to deliver enhanced customer service,
improve decision-making and increase the value of the business.
• An IoT ecosystem consists of web-enabled smart devices that use embedded
systems, such as processors, sensors and communication hardware, to collect,
send and act on data they acquire from their environments.
• IoT devices share the sensor data they collect by connecting to an IoT gateway or
other edge device where data is either sent to the cloud to be analysed or analysed
locally. Sometimes, these devices communicate with other related devices and act
on the information they get from one another. The devices do most of the work
without human intervention, although people can interact with the devices -- for
instance, to set them up, give them instructions or access the data.
CHAPTER 4
METHODOLGY
✓ In this project there is only one user. The user queries command to the system.
System then interprets it and fetches answer. The response is sent back to the
user.
✓ The main component here is the Virtual Assistant. It provides two specific
service, executing Task or Answering your question.
✓ The user sends command to virtual assistant in audio form. The command is
passed to the interpreter. It identifies what the user has asked and directs it to
task executer. If the task is missing some info, the virtual assistant asks user back
about it. The received information is sent back to task and it is accomplished.
After execution feedback is sent back to user.
✓ The above sequence diagram shows how an answer asked by the user is being
fetched from internet. The audio query is interpreted and sent to Web scraper.
The web scraper searches and finds the answer. It is then sent back to speaker,
where it speaks the answer to user
1. Technical feasibility: It includes finding out technologies for the project, both
hardware and software. For virtual assistant, user must have microphone to convey
their message and a speaker to listen when system speaks. These are very cheap now
a days and everyone generally possess them. Besides, system needs internet
connection. While using, make sure you have a steady internet connection.
3. Economic feasibility: Here, we find the total cost and benefit of the proposed
system over current system. For this project, the main cost is documentation cost.
User also, would have to pay for microphone and speakers. Again, they are cheap and
available. As far as maintenance is concerned, it won’t cost too much.
• Open:
The assistant will open some of the folders and applications which the user asks the
assistant to open.
Keyword: Open
• Date and Time:
If the user asks for the date or time, the assistant tells it.
Keyword: date or time or date and time
• Calculate:
The assistant will calculate the equations which the user tells it to calculate using
wolframalpha API key.
Keyword : calculate (along with the equation).
4.4 ALGORITHM
Speech Recognition module:
In the realm of personal assistants powered by Python, the Speech Recognition
module emerges as a cornerstone technology, enabling seamless communication between
users and their digital companions through the medium of spoken language. At its core, the
Speech Recognition module serves as the auditory gateway through which users convey their
commands, queries, and requests to the personal assistant, transforming spoken words into
actionable data that the system can comprehend and execute upon.
The Speech Recognition module operates on a sophisticated blend of algorithms and
machine learning models meticulously trained on diverse datasets to decipher the intricacies
of human speech. By harnessing techniques such as acoustic modeling, language modeling,
and pattern recognition, this module endeavors to discern the phonetic nuances, linguistic
structures, and contextual cues embedded within spoken utterances, thereby enabling
accurate and reliable transcription of speech into text.
Moreover, the Speech Recognition module offers remarkable versatility and
adaptability, capable of accommodating diverse accents, dialects, and languages with
remarkable proficiency. Through continual refinement and optimization, it endeavors to
enhance its accuracy and robustness across various linguistic landscapes, ensuring inclusivity
and accessibility in user interactions.
In the context of a personal assistant powered by Python, the Speech Recognition
module serves as the foundational element that bridges the gap between human users and
the digital realm. Whether it be issuing voice commands to retrieve information, dictate
messages, or perform tasks, users rely on the Speech Recognition module to accurately
capture their spoken input and translate it into actionable commands that the personal
assistant can comprehend and act upon.
The process of executing user commands within a personal assistant system involves several
key steps:
Command Parsing and Interpretation: Upon receiving user input in textual form, the personal
assistant parses and interprets the command to discern the user's intent and identify the
relevant action to be taken.
Action Execution: Once the user's intent has been determined, the personal assistant
proceeds to execute the corresponding action or sequence of actions required to fulfill the
user's request. This may involve accessing relevant data sources, performing computations,
interfacing with external APIs or services, or invoking system functionalities to carry out the
desired task.
Feedback and Response Generation: Following the execution of the command, the personal
assistant generates a suitable response to provide feedback to the user. This response may
take the form of spoken output (utilizing Text to Speech conversion) or textual output
displayed on a user interface, conveying the results of the command execution or requesting
further input from the user if necessary.
Error Handling and Resilience: In the event of errors or unforeseen issues encountered during
command execution, the personal assistant employs robust error handling mechanisms to
gracefully handle such situations. This may involve providing informative error messages to
the user, offering alternative suggestions or pathways to achieve their goals, or escalating the
issue to a human operator for further assistance if needed.
User Interaction and Dialogue Management: Throughout the process of executing user
commands, the personal assistant engages in a dynamic dialogue with the user, soliciting
additional input, clarifying requests, and maintaining context across multiple interactions.
This dialogue management aspect ensures a fluid and coherent user experience, fostering
effective communication and collaboration between the user and the personal assistant.
In essence, the process of executing user commands within a personal assistant system
encompasses a multifaceted interplay of linguistic understanding, computational processing,
and interactive dialogue, culminating in seamless and intuitive interactions between users
and their digital companions. As personal assistant technologies continue to evolve and
mature, the refinement of these processes holds the promise of unlocking new frontiers in
human-computer interaction, enriching the lives of users and empowering them to achieve
their goals with greater ease and efficiency.
CHAPTER 5
RESULTS DISCUSSION
The project work of the voice assistant has been clearly explained in this report, how
useful it is and how we can rely on a voice assistant for performing any/every task which
the user needs to complete and how the assistant is developing everyday which we can
hope that it'll be one of the biggest technology in the current technological world.
Development of the software is almost completed form our side and it's working fine as
expected which was discussed for some extra development. So, maybe some
advancement might come in the near future where the assistant which we developed
will be even more useful than it is now.
5.1. WORKING
It starts with a signal word. Users say the names of their voice assistants for the
same reason. They might say, “Hey Siri!” or simply, “Alexa!” Whatever the signal word
is, it wakes up the device. It signals to the voice assistant that it should begin paying
attention. After the voice assistant hears its signal word, it starts to listen. The device
waits for a pause to know you’ve finished your request.
The voice assistant then sends our request over to its source code. Once in the source
code, our request is compared to other requests. It’s split into separate commands that
our voice assistant can understand. The source code then sends these commands back
to the voice assistant. Once it receives the commands, the voice assistant knows what
to do next. If it understands, the voice assistant will carry out the task we asked for. For
example, “Hey NOVA! What’s the weather?” NOVA reports back to us in seconds.
The more directions the devices receive, the better and faster they get at fulfilling
our requests. The user gives the voice input through microphone and the assistant is
triggered by the wake up word and performs the STT (Speech to Text) and converts it
into a text and understands the Voice input and further performs the task said by the
user repeatedly and delivers it via TTS (Text to Speech) module via AI Voice.
These are the important features of the voice assistant but other than this, we can do
an plenty of things with the assistant.
List of features that can be done with the assistant:
✓ Playing some video which, the user wants to see.
✓ Telling some random fact at the start of the day with which the user can do their
work in an informative way and the user will also learn something new.
✓ One of the features which will be there in every assistant is playing some game
so that the user can spend their free time in a fun way.
✓ In the busy world, everything should do quick else, our schedule will get
changed and sometimes we need assistance of someone to complete that task
quickly but, if we have a voice assistant, we can complete that task in right away
in a hustle freeway. For example, let's say the user is doing some
documentation but after a while, he needs some file for reference and he goes
searching for that file which wastes a lot of time and he ends up missing the
deadline but, with a voice assistant we can do the searching part in a quick way
by commanding the assistant to open the folder. So, by this we can say that it
is one of the important features of a voice assistant.
Must provide the user any information which they ask for: -
✓ The user might need any information which will be available on the internet
but searching for that information and reading that takes a lot of time but with
the help of a voice assistant, we can complete that task of getting the
information sooner than searching and reading it. So, this is a small proof that
a voice assistant helps the user to save time
CHAPTER 6
CONCLUSIONS & FUTURE SCOPE
6.1. CONCLUSION
As stated before, "voice assistant is one of the biggest problem solver" and you
can see that in the proposals with the examples that it is in fact one of the biggest
problem solver of the current world. We can see that voice assistant is one of the major
evolving artificial intelligence in the current world once again on seeing the proposal
examples because at the past, the best feature which a voice assistant had was telling
the date and searching the web and giving the results but now look at the functions
that it can do so with this, we can say that it is a evolving software in the current world.
• The main idea is to develop the assistant even more advanced than it is now
and make it the best ai in the world which will save an ample of time for its
users. I would like to conclude with the statement that we will try our best and
give one of the best voice assistants which we are able to.
• Virtual Personal Assistants are a very effective way to organize your program.
There are now many Smart Personal Digital Assistant apps available on the
market for various device platforms. These new Software apps work much
better than PDA devices as they provide all the features of your smartphone.
VPAs are also more reliable than Personal Assistants because VPAs are
portable and you can use them at any time. And they have more information
than any assistant as they are connected to the internet.
assistant, we let someone else worry about the organization and prioritize our
schedule while we focus on the work.
3) Improved Interface of a voice assistant (VUI):
Voice user interfaces (VUIs) allow users to interact with a system by
speaking commands. VUIs include virtual assistants like Amazon's Alexa and
Apple's Siri. The real advantage of a VUI is that it allows users to interact with a
product without using their hands or their eyes while focusing on anything else.
REFERENCES
[1] K. Noda, H. Arie, Y. Suga, T. Ogata, Multimodal integration learning of robot behavior
using deep neural networks, Elsevier: Robotics and Autonomous Systems, 2014.
[2] Artificial intelligence (AI), sometimes called machine intelligence.
https://en.wikipedia.org/wiki/Artificial_intelligence.
[3] Deepak Shende, RiaUmahiya, Monika Raghorte, AishwaryaBhisikar, AnupBhange, “AI
Based Voice Assistant Using Python”, Journal of Emerging Technologies and Innovative
Research (JETIR), February 2019, Volume 6, Issue 2.
[4] J. B. Allen, “From lord rayleigh to shannon: How do humans decode speech,” in
International Conference on Acoustics, Speech and Signal Processing, 2002.
[5] John Levis and Ruslan Suvorov, “Automatic Speech Recognition”.
[6] B.H. Juang and Lawrence R. Rabiner, “Automatic Speech Recognition - A Brief History
of the Technology Development”.
[7] AbhayDekate, ChaitanyaKulkarni, RohanKilledar, “Study of Voice Controlled Personal
Assistant Device”, International Journal of Computer Trends and Technology (IJCTT) –
Volume 42 Number 1 – December 2016.
APPENDIX-A
SOURCE CODE
def there_exists(terms):
for term in terms:
if term in voice_data:
return True
try :
voice_data = r.recognize_google(audio) # convert audio to text
except sr.RequestError:
speak('Sorry, the service is down') # error: recognizer is not connected
except sr.UnknownValueError: # error: recognizer does not understand
print('Recognizing..')
print(f">> {voice_data.lower()}") # print what user said
return voice_data.lower()
def respond(voice_data):
# 1: greeting
if there_exists(["hey","hi","hello","wake up","hai"]):
greetings = ["hey", "hey, what's up? ", " how can I help you","I'm listening","hello"]
greet = greetings[random.randint(0,len(greetings)-1)]
speak(greet)
# 2: name
if there_exists(["your name","what i call you","what is your good name"]):
name= record_audio("my name is Vavo stand for virtual assistance version One. what's
your name?")
speak('Nice to meet you '+ name )
speak('how can i help you ' + name)
# 3: Origin
if there_exists(["who are you","your inventor","invented you","created you","who is your
developer"]):
greetings = ["I am Virtual Voice Assistant","I am developed by mr.abhijeet as a voice
assistance"] # You can Add your name
greet = greetings[random.randint(0,len(greetings)-1)]
speak(greet)
def ai(prompt):
openai.api_key = apikey
text = f"OpenAI response for Prompt: {prompt} \n *************************\n\n"
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
temperature=0.7,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
# todo: Wrap this inside of a try catch block
# print(response["choices"][0]["text"])
text += response["choices"][0]["text"]
if not os.path.exists("Openai"):
os.mkdir("Openai")
def say(text):
os.system(f'say "{text}"')
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
# r.pause_threshold = 0.6
audio = r.listen(source)
try:
print("Recognizing...")
query = r.recognize_google(audio, language="en-in")
print(f"User said: {query}")
return query
except Exception as e:
return "Some Error Occurred. Sorry from Jarvis"
if __name__ == '__main__':
print('Welcome to Jarvis A.I')
say("Jarvis A.I")
while True:
print("Listening...")
query = takeCommand()
# todo: Add more sites
sites = [["youtube", "https://www.youtube.com"], ["wikipedia",
"https://www.wikipedia.com"], ["google", "https://www.google.com"],]
for site in sites:
if f"Open {site[0]}".lower() in query.lower():
rate = engine.getProperty('rate')
voices = engine.getProperty('voices')
volume = engine.getProperty('volume')
engine.setProperty('rate', 180)
engine.setProperty('voice', voices[1].id)
engine.setProperty('volume', 0.8)
# Speak function
def speak(text):
engine.say(text)
engine.runAndWait()
print(text)
# Wishing in the beginning
def wish(text):
engine.say(text)
engine.runAndWait()
# Wishing user
def wishme():
hour = int(datetime.datetime.now().hour)
if hour >= 0 and hour < 12:
wish('good morning sir. how are you')
elif hour >= 12 and hour < 16:
wish('good afternoon sir. how are you')
else:
wish('good evening sir. how are you')
# Taking voice input
def takecommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Listening...')
audio = r.listen(source)
r.energy_threshold = 800
r.dynamic_energy_threshold = True
r.dynamic_energy_adjustment_damping = 0.2
try:
text1 = r.recognize_google(audio)
text = text1.lower()
print('You: ' + text)
except:
return ""
return text
def sleep():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Listening...')
audio = r.listen(source)
r.energy_threshold = 500
try:
text1 = r.recognize_google(audio)
text = text1.lower()
print('You: ' + text)
except:
return "none"
return text
# Logic of the program
text = ''
question = ''
type_sentence = ''
running = True
time.sleep(5)
wishme()
while running:
text = takecommand()
question = text
query4 = ''
query3 = ''
query1 = ''
query5 = ''
query2 = ''
page1 = ''
page2 = ''
wakeup_txt = ''
if 'good evening' in text or 'good morning' in text or 'good afternoon' in text:
speak('how may i help you sir?')
if 'search' in text and 'in wikipedia' in text or 'search about' in text and 'in wikipedia' in
text or 'wikipedia' in text:
query1 = text.replace('wikipedia', '')
query3 = query1.replace('about', '')
query4 = query3.replace('in', '')
query5 = query4.replace('for', '')
query2 = query5.replace('search', '')
query6 = query2
speak('do you want me to narrate or open webpage sir?')
answer = takecommand()
if 'narrate' in answer or 'direct' in answer:
results = wikipedia.summary(query6, sentences=1, auto_suggest=False)
speak('according to wikipedia ' + results)
elif 'web page' in answer or 'website' in answer or 'webpage' in answer:
page1 = wikipedia.page(query2, auto_suggest=False)
print(page1)
page2 = page1.url
print(page2)
speak('redirecting to webpage')
webbrowser.get().open_new_tab(page2)
print(page2)
elif text == '':
speak('sorry sir. can you say that again?')
elif 'search' in text and 'in google' in text:
query1 = text.replace('in google', '')
query2 = query1.replace('search', '')
speak('searching ' + query2 + ' in google')
wb.get().open_new_tab('www.google.com/search?gx&q=' + query2)
elif 'search' in text and 'in youtube' in text:
query1 = text.replace('in youtube', '')
query2 = query1.replace('search for', '')
speak('searching ' + query2 + ' in youtube')
wb.get().open_new_tab('https://www.youtube.com/results?search_query=' + query2)
elif 'search' in text:
abc1 = text.replace('search', '')
abc2 = abc1.replace('about', '')
abc3 = abc2.replace('for', '')
speak('do you want me to search in google, wikipedia or youtube sir?')
answer3 = takecommand()
if 'google' in answer3:
speak('searching for ' + abc3 + ' in google')
wb.get().open_new_tab('www.google.com/search?gx&q=' + abc3)
print(page1)
page2 = page1.url
print(page2)
speak('redirecting to webpage')
webbrowser.get().open_new_tab(page2)
print(page2)
elif 'youtube' in answer3:
speak('searching for ' + abc3 + 'in youtube')
wb.get().open_new_tab('https://www.youtube.com/results?search_query=' + abc3)
'Himanshu Chandola is a student from Graphic Era. As a practice and a small project,
he created me and I am talking to you.')
elif 'thank you' in text or 'thanks' in text:
speak('You are welcome! enything else sir?')
elif 'roll' in text and 'dice' in text:
r = random.randint(1, 6)
dice = str(r)
speak('you got ' + dice)
elif 'open instagram' in text:
speak('ok. opening instagram')
wb.get().open_new_tab('https://instagram.com')
elif text == 'quit' or text == 'panda bye' or text == 'panda quit' or text == 'bye' or 'bye' in
text or 'quit' in text:
speak('bye bye sir. thanks for your time')
running = False
sys.exit()
elif 'open youtube' in text:
speak('ok. opening youtube')
wb.get().open_new_tab('https://www.youtube.com')
elif 'open facebook' in text:
speak('ok. opening facebook')
wb.get().open_new_tab('https://www.facebook.com')
elif text == 'sing a song' or text == 'sing me a song' or 'sing a song' in text:
speak(
'I am not a good singer but I hope you will like this. Goin out tonight, changes into
something red, Her mother, doesnt like that kind of dress, Everything she never had, she
showin off')
elif 'open chrome' in text or 'open google chrome' in text:
speak('ok. opening google chrome')
os.startfile('C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Google
Chrome.lnk')
elif 'yes' in text:
wb.get().open_new_tab('www.google.com/search?gx&q=' + text)
elif 'wikipedia' in answer4:
speak('do you want me to narrate or open webpage sir?')
answer2 = takecommand()
if 'narrate' in answer2 or 'direct' in answer2:
results = wikipedia.summary(text, sentences=1, auto_suggest=False)
speak('according to wikipedia ' + results)
elif 'web page' in answer2 or 'website' in answer2 or 'webpage' in answer2:
page1 = wikipedia.page(text, auto_suggest=False)
print(page1)
page2 = page1.url
print(page2)
speak('redirecting to webpage')
webbrowser.get().open_new_tab(page2)
print(page2)
elif 'youtube' in answer4:
speak('searching for ' + text + 'in youtube')
wb.get().open_new_tab('https://www.youtube.com/results?search_query=' + text)
else:
speak('ok. anything else sir?')
APPENDIX-B
WORKING SNAPS