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
Un script en python qui permet d'automatique bumpée (disboard.org) tout les 2h

auto-bumper Un script en python qui permet d'automatique bumpée (disboard.org) tout les 2h Pour la première utilisation, 1.Lancer Install.bat 2.(faire

!! 1 Jan 09, 2022
This bot uploads telegram files to MixDrop.co,File.io.

What is about this bot ? This bot uploads telegram files to MixDrop.co, File.io. Usage: Send any file, and the bot will upload it to MixDrop.co, File.

Abhijith NT 3 Feb 26, 2022
Pokehandy - Data web app sobre Pokémon TCG que desarrollo durante transmisiones de Twitch, 2022

⚡️ Pokéhandy – Pokémon Hand Simulator [WIP 🚧 ] This application aims to simulat

Rodolfo Ferro 5 Feb 23, 2022
Notebook researcher - Notebook researcher with python

notebook_researcher To run the server, you must follow these instructions: At th

4 Sep 02, 2022
A python script to get your activity

activities A python script to get your activity Not complete Requirements Python (=3.7) Pip (for python = 3.7) Git Pip packages psutil asyncio aioht

StarNumber 3 Nov 07, 2021
edgetest is a tox-inspired python library that will loop through your project's dependencies, and check if your project is compatible with the latest version of each dependency

Bleeding edge dependency testing Full Documentation edgetest is a tox-inspired python library that will loop through your project's dependencies, and

Capital One 16 Dec 07, 2022
Automatically skip sponsor segments in YouTube videos playing on Apple TV.

iSponsorBlockTV Skip sponsor segments in YouTube videos playing on an Apple TV. This project is written in asycronous python and should be pretty quic

David 64 Dec 17, 2022
An example of python package

An example of python package Why use packages? It is a good practice to not code the same function twice, and to reuse common code from one python scr

10 Oct 18, 2022
This is a simple web interface for SimplyTranslate

SimplyTranslate Web This is a simple web interface for SimplyTranslate List of Instances You can find a list of instances here: SimplyTranslate Projec

4 Dec 14, 2022
This repository contains Python games that I've worked on. You'll learn how to create python games with AI. I try to focus on creating board games without GUI in Jupyter-notebook.

92_Python_Games 🎮 Introduction 👋 This repository contains Python games that I've worked on. You'll learn how to create python games with AI. I try t

Milaan Parmar / Милан пармар / _米兰 帕尔马 166 Jan 01, 2023
Python requirements.txt Guesser

Python-Requirements-Guesser ⚠️ This is alpha quality software. Work in progress Attempt to guess requirements.txt modules versions based on Git histor

Jerome 9 May 24, 2022
Discovering local read-level DNA methylation patterns and DNA methylation heterogeneity in intermediately methylated regions

Discovering local read-level DNA methylation patterns and DNA methylation heterogeneity in intermediately methylated regions

1 Jan 11, 2022
Open source stenotype engine

Plover Bringing stenography to everyone. Homepage Releases Wiki Blog Google Group Discord Chat About Installation Getting help Contributing Donations

Open Steno Project 2k Jan 09, 2023
Lags valorant servers by rapidly picking up and throwing shorties.

Lags valorant servers by rapidly picking up and throwing shorties.

Eric Still 9 Dec 30, 2021
A collection of design patterns and idioms in Python (With tests!).

Python Patterns Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayP

5 Sep 12, 2021
Utility to play with ADCS, allows to request tickets and collect information about related objects

certi Utility to play with ADCS, allows to request tickets and collect information about related objects. Basically, it's the impacket copy of Certify

Eloy 185 Dec 29, 2022
Minterpy - Multidimensional interpolation in Python.

minterpy is an open-source Python package for a multivariate generalization of the classical Newton and Lagrange interpolation schemes as well as related tasks.

Center for Advanced Systems Understanding 18 Jan 06, 2023
Python Function to manage users via SCIM

Python Function to manage users via SCIM This script helps you to manage your v2 users. You can add and delete users or groups, add users to groups an

4 Oct 11, 2022
Org agenda in the console

This Python script reads an org agenda file (i.e. a regular org file with some active dates) and displays an interactive and colored year calendar with detailed information for each day when the mous

Nicolas P. Rougier 113 Jan 03, 2023
Assembly example for CadQuery

Spindle and vacuum attachment This is a model of the vacuum attachment for my Workbee CNC router. There is a mist spray coming from the left hand side

Marcus Boyd 20 Sep 16, 2022