Virtual Assistant Using Python

Overview

-Virtual-Assistant-Using-Python

Virtual desktop assistant is an awesome thing. If you want your machine to run on your command like Jarvis did for Tony. Yes it is possible. It is possible using Python. Python offers a good major library so that we can use it for making a virtual assistant. Windows has Sapi5 and Linux has Espeak which can help us in having the voice from our machine. It is a weak A.I.

Modules needed pyttsx3: pyttsx is a cross-platform text to speech library which is platform independent. The major advantage of using this library for text-to-speech conversion is that it works offline. To install this module type the below command in the terminal. pip install pyttsx3 SpeechRecognition: It allow us to convert audio into text for further processing. To install this module type the below command in the terminal. pip install SpeechRecognition webbrowser: It provides a high-level interface which allows displaying Web-based documents to users. To install this module type the below command in the terminal. pip install webbrowser Wikipedia: It is used to fetch a variety of information from the Wikipedia website. To install this module type the below command in the terminal. pip install wikipedia Methods used for Virtual Assistant

  1. Speak Method Speak Method will help us in taking the voice from the machine. Here is the code explanation of Speak Method Python3

def speak(audio):

engine = pyttsx3.init()
# getter method(gets the current value
# of engine property)
voices = engine.getProperty('voices')
  
# setter method .[0]=male voice and 
# [1]=female voice in set Property.
engine.setProperty('voice', voices[0].id)
  
# Method for the speaking of the the assistant
engine.say(audio)  
  
# Blocks while processing all the currently
# queued commands
engine.runAndWait()
  1. Take query method This method will check for the condition. If the condition is true it will return output. We can add any number if conditions for it and if the condition satisfy we will get the desired output.

Python3

def Take_query():

# calling the Hello function for 
# making it more interactive
Hello()
  
# This loop is infinite as it will take
# our queries continuously until and unless
# we do not say bye to exit or terminate 
# the program
while(True):
      
    # taking the query and making it into
    # lower case so that most of the times 
    # query matches and we get the perfect 
    # output
    query = takeCommand().lower()
    if "open geeksforgeeks" in query:
        speak("Opening GeeksforGeeks ")
          
        # in the open method we just to give the link
        # of the website and it automatically open 
        # it in your default browser
        webbrowser.open("www.geeksforgeeks.com")
        continue
      
    elif "open google" in query:
        speak("Opening Google ")
        webbrowser.open("www.google.com")
        continue
          
    elif "which day it is" in query:
        tellDay()
        continue
      
    elif "tell me the time" in query:
        tellTime()
        continue
      
    # this will exit and terminate the program
    elif "bye" in query:
        speak("Bye. Check Out GFG for more exicting things")
        exit()
      
    elif "from wikipedia" in query:
          
        # if any one wants to have a information
        # from wikipedia
        speak("Checking the wikipedia ")
        query = query.replace("wikipedia", "")
          
        # it will give the summary of 4 lines from 
        # wikipedia we can increase and decrease 
        # it also.
        result = wikipedia.summary(query, sentences=4)
        speak("According to wikipedia")
        speak(result)
      
    elif "tell me your name" in query:
        speak("I am Jarvis. Your deskstop Assistant")
  1. takeCommand method This method is for taking the commands and recognizing the command from the speech_Recognition module

Python3

this method is for taking the commands

and recognizing the command from the

speech_Recognition module we will use

the recongizer method for recognizing

def takeCommand():

r = sr.Recognizer()

# from the speech_Recognition module 
# we will use the Microphone module
# for listening the command
with sr.Microphone() as source:
    print('Listening')
      
    # seconds of non-speaking audio before 
    # a phrase is considered complete
    r.pause_threshold = 0.7
    audio = r.listen(source)
      
    # Now we will be using the try and catch
    # method so that if sound is recognized 
    # it is good else we will have exception 
    # handling
    try:
        print("Recognizing")
          
        # for Listening the command in indian
        # english we can also use 'hi-In' 
        # for hindi recognizing
        Query = r.recognize_google(audio, language='en-in')
        print("the command is printed=", Query)
          
    except Exception as e:
        print(e)
        print("Say that again sir")
        return "None"
      
    return Query

*)tellTime method Python3

code

def tellTime(self):

This method will give the time

time = str(datetime.datetime.now())
  # the time will be displayed like this "2020-06-05 17:50:14.582630"
# nd then after slicing we can get time
print(time)
hour = time[11:13]
min = time[14:16]
self.Speak(self, "The time is sir" + hour + "Hours and" + min + "Minutes")     

""" This method will take time and slice it "2020-06-05 17:50:14.582630" from 11 to 12 for hour and 14-15 for min and then speak function will be called and then it will speak the current time """ 4) Hello method This is just used to greet the user with a hello message.

Python3

Owner
Bade om
ombade/README.md Hey , I'm Om About Me 🚀 🎓 I’m an Open-Source enthusiast & a junior pursuing my Bachelors in Computer Science & Engineering.
Bade om
Expense-manager - Expense manager with python

Expense_manager TO-DO Source extractor: Credit Card, Wallet Destination extracto

1 Feb 13, 2022
A collection of software that serve no purpose other than waste your time. Forking is encouraged!

the-useless-collection A collection of software that serve no purpose other than waste your time. Forking is encouraged! Requires Python 3.9. Usage Go

Imsad2 1 Mar 16, 2022
Structured Exceptions for Python

XC: Structured exceptions for Python XC encourages a structured, disciplined approach to use of exceptions: it reduces the overhead of declaring excep

Bob Gautier 2 May 28, 2021
Experimental proxy for dumping the unencrypted packet data from Brawl Stars (WIP)

Brawl Stars Proxy Experimental proxy for version 39.99 of Brawl Stars. It allows you to capture the packets being sent between the Brawl Stars client

4 Oct 29, 2021
Hypothesis strategies for generating Python programs, something like CSmith

hypothesmith Hypothesis strategies for generating Python programs, something like CSmith. This is definitely pre-alpha, but if you want to play with i

Zac Hatfield-Dodds 73 Dec 14, 2022
This project recreates the R-based RCy3 Cytoscape Automation library as a Python package.

Python library for calling Cytoscape Automation via CyREST

Cytoscape Consortium 40 Dec 22, 2022
A novel dual model approach for categorization of unbalanced skin lesion image classes (Presented technical paper 📃)

A novel dual model approach for categorization of unbalanced skin lesion image classes (Presented technical paper 📃)

1 Jan 19, 2022
Mmr image postbot - Бот для создания изображений с новыми релизами в сообщество ВК MMR Aggregator

Mmr image postbot - Бот для создания изображений с новыми релизами в сообщество ВК MMR Aggregator

Max 3 Jan 07, 2022
Shows VRML team stats of all players in your pubs

VRML Team Stat Searcher Displays Team Name, Team Rank (Worldwide), and tier of all the players in your pubs. GUI WIP: Only username search works (for

Hamish Burke 2 Dec 22, 2022
Random Turkish name generator with realistic probabilities.

trnames Random Turkish name generator with realistic probabilities. Based on Trey Hunner's names package. Installation The package can be installed us

Kaan Öztürk 20 Jan 02, 2023
Project 2 for Microsoft Azure on WUT

azure-proj2 Project 2 for Microsoft Azure on WUT Table of contents Team Tematyka projektu Architektura Opis rozwiązania Demo dzałania The Team Krzyszt

1 Dec 07, 2021
HatAsm - a HatSploit native powerful assembler and disassembler that provides support for all common architectures

HatAsm - a HatSploit native powerful assembler and disassembler that provides support for all common architectures.

EntySec 8 Nov 09, 2022
A web-based chat application that enables multiple users to interact with one another

A web-based chat application that enables multiple users to interact with one another, in the same chat room or different ones according to their choosing.

3 Apr 22, 2022
WriteAIr is a website which allows users to stream their writing.

WriteAIr is a website which allows users to stream their writing. It uses HSV masking to detect a pen which the user writes with. Plus, users can select a wide range of options through hand gestures!

Atharva Patil 1 Nov 01, 2021
Hartree-Fock Workshop for the Han-sur-Lesse Winterschool of 2021

Hartree-Fock course for the Han-sur-Lesse Winterschool of 2021 Requirements For going through these exercises, please install the Anaconda suite. Next

Ivo Filot 2 Nov 16, 2022
Automated moth pictures for biodiversity research

Automated moth pictures for biodiversity research

Ludwig Kürzinger 1 Dec 16, 2021
Snack Rice - A Rice University servery finder, customized for your needs!

Snack Rice - A Rice University servery finder, customized for your needs!

Aidan Gerber 3 Sep 25, 2022
An easy way to access to your EPITECH subjects based on the Roslyn's database.

An easy way to access to your EPITECH subjects based on the Roslyn's database.

Mathias 1 Feb 09, 2022
This repository contains all the data analytics projects that I've worked on in python.

93_Python_Data_Analytics_Projects This repository contains all the data analytics projects that I've worked on in python. No. Name 01 001_Cervical_Can

Milaan Parmar / Милан пармар / _米兰 帕尔马 267 Jan 06, 2023
Regular Expressions - Use regular expressions to detect date format

A list of all the resources used https://regex101.com/ - To test regex https://w

Ravika Nagpal 1 Jan 04, 2022