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
Python template for Advent of Code event

Advent of Code Python Starter A tamplate for Advent of Code write in Python. Usage The project use poetry for project manager. Clone this repository a

Leonardo Gago 6 Dec 31, 2022
A Python feed reader library.

reader is a Python feed reader library. It aims to allow writing feed reader applications without any business code, and without enforcing a dependenc

266 Dec 30, 2022
Beancount Importers for DKB (Deutsche Kredit Bank) CSV Exports

Beancount DKB Importer beancount-dkb provides an Importer for converting CSV exports of DKB (Deutsche Kreditbank) account summaries to the Beancount f

Siddhant Goel 24 Aug 06, 2022
Scripts used in the RayStation medical radiation dosimetry treatment planning system

Med Phys Scripts These are scripts that I, the medical physics assistant at Cookeville Regional Medical Center, wrote for use in our radiation therapy

Kaley White 2 Oct 19, 2022
Simple control of Thorlabs Elliptec devices from Python.

Elliptec Simple control of Thorlabs Elliptec devices. No docs yet » Get started · Report a bug · Request a feature About The Project ThorLabs Elliptec

David Roesel 8 Sep 22, 2022
Just some mtk tool for exploitation, reading/writing flash and doing crazy stuff

Just some mtk tool for exploitation, reading/writing flash and doing crazy stuff. For linux, a patched kernel is needed (see Setup folder) (except for read/write flash). For windows, you need to inst

Bjoern Kerler 1.1k Dec 31, 2022
Aerospace utilities: flight conditions package, standard atmosphere model, and more.

Aerospace Utilities About Module that contains commonly-used aerospace utilities for problem solving. Flight Condition: input altitude to compute comm

1 Jan 03, 2022
Whatsapp Messenger master

Whatsapp Messenger master

Swarup Kharul 5 Nov 21, 2021
Code for the manim-generated scenes used in 3blue1brown videos

This project contains the code used to generate the explanatory math videos found on 3Blue1Brown. This almost entirely consists of scenes generated us

Grant Sanderson 4.1k Jan 02, 2023
Open slidebook .sldy files in Python

Work in progress slidebook-python Open slidebook .sldy files in Python To install slidebook-python requires Python = 3.9 pip install slidebook-python

The Institute of Cancer Research 2 May 04, 2022
Better firefox bookmarks script for rofi

rofi-bookmarks Small python script to open firefox bookmarks with rofi. Features Icons! Only show bookmarks in a specified bookmark folder Show entire

32 Nov 10, 2022
Tie together `drf-spectacular` and `djangorestframework-dataclasses` for easy-to-use apis and openapi schemas.

Speccify Tie together drf-spectacular and djangorestframework-dataclasses for easy-to-use apis and openapi schemas. Usage @dataclass class MyQ

Lyst 4 Sep 26, 2022
Your Google Recon is Now Automated

GRecon : GRecon (Greei-Conn) is a simple python tool that automates the process of Google Based Recon AKA Google Dorking The current Version 1.0 Run 7

adnane-tebbaa 189 Dec 21, 2022
A script where you execute a script that generates a base project for your gdextension

GDExtension Project Creator this is a script (currently only for linux) where you execute a script that generates a base project for your gdextension,

Unknown 11 Nov 17, 2022
Return-Parity-MDP - Towards Return Parity in Markov Decision Processes

Towards Return Parity in Markov Decision Processes Code for the AISTATS 2022 pap

Jianfeng Chi 3 Nov 27, 2022
A set of scripts for a two-step procedure to measure the value of access to destinations across several modes of travel within a geographic area.

A set of scripts for a two-step procedure to measure the value of access to destinations across several modes of travel within a geographic area.

Institute for Transportation and Development Policy 2 Oct 16, 2022
Easy to use phishing tool with 65 website templates. Author is not responsible for any misuse.

PyPhisher [+] Description : Ultimate phishing tool in python. Includes popular websites like facebook, twitter, instagram, github, reddit, gmail and m

KasRoudra 1.1k Dec 31, 2022
📜Generate poetry with gcc diagnostics

gado (gcc awesome diagnostics orchestrator) is a wrapper of gcc that outputs its errors and warnings in a more poetic format.

Dikson Santos 19 Jun 25, 2022
Magenta: Music and Art Generation with Machine Intelligence

Magenta is a research project exploring the role of machine learning in the process of creating art and music. Primarily this involves developing new

Magenta 18.1k Jan 05, 2023
BridgeWalk is a partially-observed reinforcement learning environment with dynamics of varying stochasticity.

BridgeWalk is a partially-observed reinforcement learning environment with dynamics of varying stochasticity. The player needs to walk along a bridge to reach a goal location. When the player walks o

Danijar Hafner 6 Jun 13, 2022