You are on page 1of 18

JIS College of Engineering

Department of Computer Science and Engineering


____________________________________________________

PROJECT ON: Virtual Assistant Using Python


(Project Submitted in partial fulfilment of the requirements for the Degree of Bachelor of Technology in the field
of Computer Science and Engineering.)

Title of the Project Virtual Assistant Using Python


Academic Year 2018 – 2022

Semester / Year 7th Semester / 4rd Year

Name of the Students ANKIT BHARTI Roll No 123190703202

ARITRA DEY 123190703207

SOMNATH MAITY 123190703218

TANMOY KUMAR PAUL 123180703109

TANMOY NATH 123180703110

Name of the Supervisor Dr. Bikramjit Sarkar


JIS College of Engineering
Dept. of Computer Science and Engineering

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

This is to certify that Aritra Dey (123190703207), Tanmoy Nath (123180703110),

Somnath Maity(123190703218),Tanmoy Kumar Paul(123180703109),Ankit Bharati

(123190703202) has completed his/her/their project entitled Android Based Secure

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

Engineering from JIS college of Engineering (An Autonomous Institute) is an authentic

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

degree, diploma, fellowship or any other similar title.

________________________

Signature of the Supervisor


JIS College of Engineering
Dept. of Computer Science and Engineering

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

…………………………………….……………………

Tanmoy Kumar Paul


B.TECH in Computer Science and Engineering
3rd Year/ 5th Semester
University Roll no.-- 123180703109

……………………….………………………………….

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.

This system is designed to be used efficiently on desktops. Personal assistants software

improves user productivity by managing routine tasks of the user and by providing information

from an online source to the user.

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

making intelligent decisions for routine user activities.


OBJECTIVE (proposed work)

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

systems can be sensitive to these pitch changes.


Methodology of Virtual Assistant Using Python

Detailed Workflow

Speech Recognition module:

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

fed to the central processor.

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

unstructured and/or semi-structured machine-readable documents. In most cases, this activity

concerns processing human language texts using natural language processing (NLP). Recent

activities in multimedia document processing like automatic annotation and content extraction

out of images/audio/video could be seen as context extraction TEST RESULTS.

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

through third-party publishers.

Other modules:

The others modules that are used in this project are:

1. Datetime

2. Webbrowser

3. Wikipedia

4. OS

5. Pyjokes
6. Random

Source code

import pyttsx3 #pip install pyttsx3


import speech_recognition as sr #pip install speechRecognition
import datetime
import wikipedia #pip install wikipedia
import webbrowser
import os
import pyjokes
import pywhatkit as py
import random
from requests import get

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!")

    elif hour>=12 and hour<18:


        speak("Good Afternoon!")  

    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()

        # Logic for executing tasks based on query


        if 'who is' in query:
            speak('Searching Wikipedia...')
            query = query.replace("wikipedia", "")
            results = wikipedia.summary(query, sentences=2)
            speak("According to Wikipedia")
            print(results)
            speak(results)
            speak (a)

       
        elif 'open youtube' in query:
            webbrowser.open("youtube.com")
            speak (a)
     

        elif 'open chrome' in query:


            webbrowser.open("chrome")
            speak (a)  

       
        elif 'who are you' in query:
            speak('i am Friday , your virtual assistant sir!')
            speak (a)

        elif  'music' in query:


            music_dir = 'F:\\Songs'
            songs = os.listdir(music_dir)
            rd = random.choice(songs)  
            os.startfile(os.path.join(music_dir, rd))
            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 'terminal' in query:


            path = "C:\\WINDOWS\\system32\\cmd.exe"
            os.startfile(path)
            speak (a)
       
       
        elif 'vlc' in query:
            path = "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"
            os.startfile(path)
            speak (a)
       
       
        elif 'geek' in query:
            webbrowser.open("www.geekforgeeks.com")
            speak (a)
       
       
        elif 'torrent' in query:
            path = "D:\\torrent"
            os.startfile(path)
            speak (a)
       
       
        elif 'movie' in query:
            path = "D:\\torrent\\GvK\\GvK.mp4"
            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)
       

        elif 'no thanks' in query:


            speak("thanks for using me. have a good day!!!")
            exit()

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.

3. Then we can integrate with Windows application or Mobile application.

4. Additionally, in future add some Healthcare features can be added with this.

5. Therefore, the search behaviour can be changed in future.


6. In future, it can be used in solving maths and various types of problem with the help of

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

rather than the next one.

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,”

in Proceedings of ACL-HLT, 2001


 V. Zue, S. Seneff, J. R. Glass, J. Polifroni, C. Pao, T.J.Hazen,and L.Hetherington, “JUPITER: A

Telephone Based Conversational Interface for Weather Information,” IEEE Transactions on

Speech and Audio Processing, vol. 8, no. 1, pp. 85–96, 2000.

 M. Kolss, D. Bernreuther, M. Paulik, S. St¨ucker, S. Vogel, and A. Waibel, “Open Domain

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

You might also like