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
Kolibri: the offline app for universal education

Kolibri This repository is for software developers wishing to contribute to Kolibri. If you are looking for help installing, configuring and using Kol

Learning Equality 564 Jan 02, 2023
Paxos in Python, tested with Jepsen

Python implementation of Multi-Paxos with a stable leader and reconfiguration, roughly following "Paxos Made Moderately Complex". Run python3 paxos/st

A. Jesse Jiryu Davis 25 Dec 15, 2022
A Pythonic Data Catalog powered by Ray that brings exabyte-level scalability and fast, ACID-compliant, change-data-capture to your big data workloads.

DeltaCAT DeltaCAT is a Pythonic Data Catalog powered by Ray. Its data storage model allows you to define and manage fast, scalable, ACID-compliant dat

45 Oct 15, 2022
Find your desired product in Digikala using this app.

Digikala Search Find your desired product in Digikala using this app. با این برنامه محصول مورد نظر خود را در دیجیکالا پیدا کنید. About me Full name: M

Matin Ardestani 17 Sep 15, 2022
A simple projects to help your seo optimizing has been written with python

python-seo-projects it is a very simple projects to help your seo optimizing has been written with python broken link checker with python(it will give

Amirmohammad Razmy 3 Dec 25, 2021
Wrappers around the most common maya.cmds and maya.api use cases

Maya FunctionSet (maya_fn) A package that decompose core maya.cmds and maya.api features to a set of simple functions. Tests The recommended approach

Ryan Porter 9 Mar 12, 2022
🐍 This snake helps you reconnect the Web, with RSS feeds!

This snake helps you reconnect the Web, with RSS feeds! RSSerpent is an open-source software that create RSS feeds for websites that do not provide an

211 Dec 08, 2022
Blender Add-on to Add Metal Materials to Your Scene

Blender QMM (Quick Metal Materials) Blender Addon to Add Metal Materials to Your Scene Installation Download the latest ZIP from Releases. Usage This

Don Schnitzius 27 Dec 26, 2022
vFuzzer is a tool developed for fuzzing buffer overflows, For now, It can be used for fuzzing plain vanilla stack based buffer overflows

vFuzzer vFuzzer is a tool developed for fuzzing buffer overflows, For now, It can be used for fuzzing plain vanilla stack based buffer overflows, The

Vedant Bhalgama 5 Nov 12, 2022
Blender Add-on That Provides Quick Access to Render Controls

Blender Render Buttons Blender Add-on That Provides Quick Access to Render Controls A Blender 3.0 compatablity update of Blender2.8x-RenderButton v0.0

Don Schnitzius 3 Oct 18, 2022
Morth - Stack Based Programming Language

Morth WARNING! THIS LANGUAGE IS A WORKING PROGRESS. THIS IS JUST A HOBBY PROJECT

Dominik Danner 2 Mar 05, 2022
Tc-python - A Python script to receive message from a twitch chat

Twitch-Chat 📜 I did a script in Python to receive messages from a twitch chat.

miyucode 2 May 31, 2022
A place where one-off ideas/partial projects can live comfortably

A place to post ideas, partial projects, or anything else that doesn't necessarily warrant its own repo, from my mind to the web.

Carson Scott 2 Feb 25, 2022
Earth-to-orbit ballistic trajectories with atmospheric resistance

Earth-to-orbit ballistic trajectories with atmospheric resistance Overview Space guns are a theoretical technology that reduces the cost of getting bu

1 Dec 03, 2021
This is where I learn machine learning

This is where I learn machine learning🤷‍ This means that this repo covers no specific topic of machine learning or a project - I work in here when I want to learn/try something

Wilhelm Berghammer 47 Nov 16, 2022
Tracking stock volatility.

SP500-highlow-tracking Track stock volatility. Being a useful indicator of the stock price volatility, High-Low gap represents the price range of the

Thong Huynh 13 Sep 07, 2022
Research using python - Guide for development of research code (using Anaconda Python)

Guide for development of research code (using Anaconda Python) TL;DR: One time s

Ziv Yaniv 1 Feb 01, 2022
chiarose(XCR) based on chia(XCH) source code fork, open source public chain

chia-rosechain 一个无耻的小活动 | A shameless little event 如果您喜欢这个项目,请点击star 将赠送您520朵玫瑰,可以去 facebook 留下您的(xcr)地址,和github用户名。 If you like this project, please

ddou123 376 Dec 14, 2022
Advanced Variable Manager {AVM} [0.8.0]

Advanced Variable Manager {AVM} [0.8.0] By Grosse pastèque#6705 WARNING : This modules need some typing modifications ! If you try to run it without t

Big watermelon 1 Dec 11, 2021
NeoInterface - Neo4j made easy for Python programmers!

Neointerface - Neo4j made easy for Python programmers! A Python interface to use the Neo4j graph database, and simplify its use. class NeoInterface: C

15 Dec 15, 2022