Document of Python Virtual Assistant
Document of Python Virtual Assistant
Index
1. Certificate
2. Acknowledgement
3. Abstract
4. Introduction
5. Objective
6. Methodology of Virtual Assistant Using Python
7. Source Code
8. Future Scope
9. References
CERTIFICATE
Messenger System under the guidance of Dr. Bikramjit Sarkar in partial fulfilment of the
requirements for the award of the Bachelor of Technology in Computer Science and
record of their own work carried out during the academic year 2021-22 and to the best of our
knowledge, this work has not been submitted elsewhere as part of the process of obtaining a
________________________
ACKNOWLEDGEMENT
The analysis of the project work wishes to express our gratitude to Dr. Bikramjit Sarkar
for allowing the degree attitude and providing effective guidance in development of this
project work. Her conscription of the topic and all the helpful hints, she provided,
contributed greatly to successful development of this work, without being pedagogic and
overbearing influence.
We also express our sincere gratitude to Dr. Dharmpal Singh, Head of the Department of
Computer Science and Engineering of JIS College of Engineering and all the respected
faculty members of Department of CSE for giving the scope of successfully carrying out the
project work.
Date: 28.05.2020
Aritra Dey
B. TECH in Computer Science and Engineering
3rd Year/ 5th Semester
University Roll no.-- 123190703207
….…………………………………………………………
Tanmoy Nath
B.TECH in Computer Science and Engineering
3rd Year/ 5th Semester
University Roll no.-- 123180703110
………………….………………………………….
Somnath Maity
B.TECH in Computer Science and Engineering
3rd Year/ 5th Semester
University Roll no.-- 123190703218
…………………………………….……………………
……………………….………………………………….
Ankit Bharati
B.TECH in Computer Science and Engineering
3rd Year/ 5th Semester
University Roll no.-- 123190703202
….…………………………………………………………
ABSTRACT
In this modern era, day to day life became smarter and interlinked with technology. We already
know some voice assistance like google, Siri. etc. Now in our voice assistance system, it can act
as a basic medical prescriber, daily schedule reminder, note writer, calculator and a search tool.
This project works on voice input and give output through voice and displays the text on the
screen. The main agenda of our voice assistance makes people smart and give instant and
computed results. The voice assistance takes the voice input through our microphone (Bluetooth
and wired microphone) and it converts our voice into computer understandable language gives the
required solutions and answers which are asked by the user. This assistance connects with the
world wide web to provide results that the user has questioned. Natural Language Processing
algorithm helps computer machines to engage in communication using natural human language
in many forms.
INTRODUCTION
Today the development of artificial intelligence (AI) systems that can organize a natural human-
machine interaction (through voice, communication, gestures, facial expressions, etc.) are gaining
in popularity. One of the most studied and popular was the direction of interaction, based on the
understanding of the machine by the machine of the natural human language. It is no longer a
human who learns to communicate with a machine, but a machine learns to communicate with a
human, exploring his actions, habits, behaviour and trying to become his personalized assistant.
Virtual assistants are software programs that help you ease your day to day tasks, such as
showing weather reports, creating remainders, making shopping lists etc. They can take
commands via text (online chatbots) or by voice. Voice-based intelligent assistants need an
invoking word or wake word to activate the listener, followed by the command. We have so many
virtual assistants, such as Apple’s Siri, Amazon’s Alexa and Microsoft’s Cortana.
improves user productivity by managing routine tasks of the user and by providing information
This project was started on the premise that there is a sufficient amount of openly available data
and information on the web that can be utilized to build a virtual assistant that has access to
The work started with analysing the audio commands given by the user through the microphone.
This can be anything like getting any information, operating a computer’s internal files, etc. This is
an empirical qualitative study, based on reading above mentioned literature and testing their
examples. Tests are made by programming according to books and online resources, with the
explicit goal to find best practices and a more advanced understanding of Voice Assistant.
Workflow
The above figure shows the workflow of the basic process of the voice assistant. Speech
recognition is used to convert the speech input to text. This text is then fed to the central
processor which determines the nature of the command and calls the relevant script for
execution.
But the complexities don’t stop there. Even with hundreds of hours of input, other factors can play
a huge role in whether or not the software can understand you. Background noise can easily throw
a speech recognition device off track. This is because it does not inherently have the ability to
distinguish the ambient sounds it “hears” of a dog barking or a helicopter flying overhead, from
your voice. Engineers have to program that ability into the device; they conduct data collection of
these ambient sounds and “tell” the device to filter them out. Another factor is the way humans
naturally shift the pitch of their voice to accommodate for noisy environments; speech recognition
Detailed Workflow
The system uses Google’s online speech recognition system for converting speech input to text.
The speech input Users can obtain texts from the special corpora organized on the computer
network server at the information centre from the microphone is temporarily stored in the system
which is then sent to Google cloud for speech recognition. The equivalent text is then received and
Python Backend:
The python backend gets the output from the speech recognition module and then identifies
whether the command or the speech output is an API Call and Context Extraction. The output is
then sent back to the python backend to give the required output to the user.
API calls:
API stands for Application Programming Interface. An API is a software intermediary that allows
two applications to talk to each other. In other words, an API is a messenger that delivers your
request to the provider that you’re requesting it from and then delivers the response back to you.
Content Extraction:
Context extraction (CE) is the task of automatically extracting structured information from
concerns processing human language texts using natural language processing (NLP). Recent
activities in multimedia document processing like automatic annotation and content extraction
Text-to-speech module:
Text-to-Speech (TTS) refers to the ability of computers to read text aloud. A TTS Engine converts written
text to a phonemic representation, then converts the phonemic representation to waveforms that can be
output as sound. TTS engines with different languages, dialects and specialized vocabularies are available
Other modules:
1. Datetime
2. Webbrowser
3. Wikipedia
4. OS
5. Pyjokes
6. Random
Source code
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print(voices[1].id)
engine.setProperty('voice', voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("Good Morning!")
else:
speak("Good Evening!")
speak("hello sir , I am Friday . how may i help you?")
def takeCommand(): #It takes microphone input from the user and returns string
output
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-in')
print(f"User said: {query}\n")
except Exception as e:
# print(e)
speak("Say that again please...")
return "None"
return query
if __name__ == "__main__":
a = ("sir, anything else?")
string = str( )
wishMe()
while True:
# if 1:
query = takeCommand().lower()
elif 'open youtube' in query:
webbrowser.open("youtube.com")
speak (a)
elif 'who are you' in query:
speak('i am Friday , your virtual assistant sir!')
speak (a)
elif 'the time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S")
speak(f"Sir, the time is {strTime}")
speak (a)
elif 'open vs code' in query:
Path = "C:\\Users\\pault\\AppData\\Local\\Programs\\Microsoft VS Code\\
Code.exe"
os.startfile(Path)
speak (a)
elif 'joke' in query:
speak(pyjokes.get_joke())
speak (a)
elif 'play' in query:
song = query.replace('play', '')
#speak('playing ' + song)
py.playonyt(song)
speak (a)
elif 'edge' in query:
path = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
os.startfile(path)
speak (a)
elif 'whatsapp' in query:
path = "C:\\Users\\pault\\AppData\\Local\\WhatsApp\\WhatsApp.exe"
os.startfile(path)
speak (a)
elif 'ip' in query:
ip = get('https://api.ipify.org').text
speak(f"your ip address is {ip}")
speak (a)
elif 'open google' in query:
speak("sir, what should i search on google")
cm = takeCommand().lower()
webbrowser.open(f"{cm}")
speak (a)
Future Scope
1. In this project we have implemented the basic Virtual Assistant using Python. In future we
can add many additional tasks like sending message or sending email etc.
2. We can implement this with GUI and make it fully voice controlled.
4. Additionally, in future add some Healthcare features can be added with this.
Artificial Intelligence.
Conclusion
In this project “Virtual Assistant Using Python” we discussed the design and implementation
of Digital Assistance. The project is built using open source software modules and the help of
Visual Studio.
It not only works on human commands but also give responses to the user based on the
query being asked or the words spoken by the user such as opening tasks and operations. It is
greeting the user the way the user feels more comfortable and feels free to interact with the
voice assistant. The application should also eliminate any kind of unnecessary manual work
required in the user life of performing every task. The entire system works on the verbal input
REFERENCES
www.google.com
www.youtube.com
https://techcrunch.com
R. Belvin, R. Burns, and C. Hein, “Development of the HRL route navigation dialogue system,”
Speech Recognition & Translation: Lectures and Speeches,” in Proceedings of ICASSP, 2006.
Sadun, E., &Sande, S. (2014). Talking to Siri: Mastering the Language of Apple’s Intelligent
Assistant.
THANK YOU