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
Retrieve bank transactions and categorize for budgeting use

Budgeting After trying out some budgeting software, I decided to make my own. selenium_scraper Using the selenium package, this script runs an instanc

Marc 1 Nov 10, 2021
DRF magic links

drf-magic-links Installation pip install drf-magic-links Add URL patterns # urls.py

Dmitry Kalinin 1 Nov 07, 2021
A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python

Windel Bouwman 277 Dec 26, 2022
Decentralized intelligent voting application.

DiVA Decentralized intelligent voting application. Hack the North 2021. Inspiration Following the previous US election, many voters were fearful that

Ali Shariatmadari 4 Jun 05, 2022
An Android app that runs Elm in a webview. And a Python script to build the app or install it on the device.

Requirements You need to have installed: the Android SDK Elm Python git Starting a project Clone this repo and cd into it: $ git clone https://github.

Benjamin Le Forestier 11 Mar 17, 2022
A small program to vote for Councilors at 42 Heilbronn.

This Docker container is build to run on server an provide an easy to use interface for every student to vote for their councillors. To run docker on

Kevin Hirsig 2 Jan 17, 2022
[CVPR 2020] Rethinking Class-Balanced Methods for Long-Tailed Visual Recognition from a Domain Adaptation Perspective

Rethinking Class-Balanced Methods for Long-Tailed Visual Recognition from a Domain Adaptation Perspective [Arxiv] This is PyTorch implementation of th

Abdullah Jamal 22 Nov 19, 2022
Structured, dependable legos for Starknet development.

cairomate • Structured, dependable legos for starknet development. Directory Structure contracts ├─ defi │ ├─ ChainlinkPriceOracle — "Simple price or

andreas 127 Nov 23, 2022
Vector tile server for the Wildfire Predictive Services Unit

wps-tileserver Vector tile server for the Wildfire Predictive Services Unit Overview The intention of this project is to: provide tools to easily spin

Province of British Columbia 6 Dec 20, 2022
Anti VirusTotal written in Python.

How it works Most of the anti-viruses on VirusToal uses sandboxes or vms to scan and detect malicious activity. The code checks to see if the devices

cliphd 3 Dec 26, 2021
This is the Halloween edition of my Flask Greeting App - HAPPY HALLOWEEEN EVERYONE! :)

HalloweenGreetingApp HAPPY HALLOWEEN EVERYONE! :) This is the Halloween Edition of my Flask Greeting App! Please note, this application is mean to be

Mariya 2 Feb 04, 2022
Persistent/Immutable/Functional data structures for Python

Pyrsistent Pyrsistent is a number of persistent collections (by some referred to as functional data structures). Persistent in the sense that they are

Tobias Gustafsson 1.8k Dec 31, 2022
Make pack up python files easier.

python-easy-pack make pack up python files easier. 目前只提供了中文环境 如何使用? 将index.py复制到你的项目文件夹,或者把.py文件拷贝到这个文件夹。 打开你的cmd或者powershell 切换到程序所在目录,输入python index

2 Dec 15, 2021
Life Dynamics for python

Daphny_counter run command must be like this: /usr/bin/python3 /home/nmakagonov/Daphny/daphny_counter/Daphny_counter.py -o /home/nmakagonov/Daphny/out

12 Sep 05, 2022
tool to automate exploitation of android degubg bridge vulnerability

DISCLAIMER DISCLAIMER: ANY MALICIOUS USE OF THE CONTENTS FROM THIS ARTICLE WILL NOT HOLD THE AUTHOR RESPONSIBLE HE CONTENTS ARE SOLELY FOR EDUCATIONAL

6 Feb 12, 2022
It's like Forth but in Python

It's like Forth but written in Python. But I don't actually know for sure since I never programmed in Forth, I only heard that it's some sort of stack-based programming language. Porth is also stack-

Tsoding 619 Dec 21, 2022
A simple IDA Pro plugin to show all HexRays decompiler comments written by user

XRaysComments A simple IDA Pro plugin to show all HexRays decompiler comments written by user Installation Copy the file xray_comments.py to the plugi

Nox 20 Dec 27, 2022
Step by step development of a vending coffee machine project, including tkinter, sqlite3, simulation, etc.

Step by step development of a vending coffee machine project, including tkinter, sqlite3, simulation, etc.

Nikolaos Avouris 2 Dec 05, 2021
A webdav demo using a virtual filesystem that serves a random status of whether a cat in a box is dead or alive.

A webdav demo using a virtual filesystem that serves a random status of whether a cat in a box is dead or alive.

Marshall Conover 2 Jan 12, 2022
A simple watcher for the XTZ/kUSD pool on Quipuswap

Kolibri Quipuswap Watcher This repo holds the source code for the QuipuBot bot deployed to the #quipuswap-updates channel in the Kolibri Discord Setup

Hover Labs 1 Nov 18, 2021