Jarvis and Google Assistant || Voice Assistant Using Python

Jarvis and Google Assistant || Voice Assistant Using Python

Today we are going to make a Voice Assistant Using Python which can behave as Jarvis like assistant or Google assistant.

This assistant can talk to you or communicate with you using your voice like Google Assistant or Jarvis.
But, this will not be that much advanced, this will totally depend on the if..else.. condition which we will use inside our Program.
There are three requirements–

1. PyAudio — to install pyaudio, go to terminal and type,

pip install pyaudio

2. SpeechRecognition — to install SpeechRecognition, go to terminal and type,

pip install speechrecognition

3. Pyttsx3 — to install Pyttsx3, go to terminal and type,

pip install pyttsx3


# importing pyttsx3
import pyttsx3
# importing speech_recognition
import speech_recognition as sr
# creating take_commands() function which
# can take some audio, Recognize and return
# if there are not any errors
def take_commands():
    # initializing speech_recognition
    r = sr.Recognizer()
    # opening physical microphone of computer
    with sr.Microphone() as source:
        r.pause_threshold = 0.7
        # storing audio/sound to audio variable
        audio = r.listen(source)
            # Recognizing audio using google api
            Query = r.recognize_google(audio)
            print("the query is printed='", Query, "'")
        except Exception as e:
            print("Say that again sir")
            # returning none if there are errors
            return "None"
    # returning audio as text
    return Query
# creating Speak() function to giving Speaking power
# to our voice assistant 
def Speak(audio):
    # initializing pyttsx3 module
    engine = pyttsx3.init()
    # anything we pass inside engine.say(),
    # will be spoken by our voice assistant

# Driver Code
if __name__ == '__main__':
    # using while loop to communicate infinitely
    while True:
        command = take_commands()
        if "exit" in command:
            Speak("Sure sir! as your wish, bai")
        if "insta" in command:
            Speak("Best python page on instagram is pythonhub")
        if "learn" in command:
            Speak("copyassignment website is best to learn python")
        if "code" in command:
            Speak("You can get this code from copyassignment website")


We have used three modules of Python here, pyaudio is working in the background and is necessary to be installed.

Here, we have made the take_command() function so that it can be used here as the ear of our voice assistant in Python which ultimately uses the speech_recognition module.

Similarly, we have made the Speak() function so that it can be used here as the mouth of our voice assistant in Python which ultimately uses the pyttsx3 module.


Watch the video for more:

Also Read:

Create Language Translator Using Python

Covid-19 Tracker Application Using Python

YouTube Video Downloader Application Using Python

GUI Calendar using Python

GUI Application To See wifi password in Python

Get WiFi Passwords With Python

Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at [email protected] Thank you

12 thoughts on “Jarvis and Google Assistant || Voice Assistant Using Python

  1. ERROR: Command errored out with exit status 1:
    command: ‘c:\users\risha\pycharmprojects\shortner\venv\scripts\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘”‘”‘C:\\Users\\risha\\AppData
    \\Local\\Temp\\pip-install-fsk2jhzj\\pyaudio\\setup.py’”‘”‘; __file__=’”‘”‘C:\\Users\\risha\\AppData\\Local\\Temp\\pip-install-fsk2jhzj\\pyaudio\\setup.py’”‘”‘;f=get
    attr(tokenize, ‘”‘”‘open’”‘”‘, open)(__file__);code=f.read().replace(‘”‘”‘\r\n’”‘”‘, ‘”‘”‘\n’”‘”‘);f.close();exec(compile(code, __file__, ‘”‘”‘exec’”‘”‘))’ install –
    -record ‘C:\Users\risha\AppData\Local\Temp\pip-record-dzj167aq\install-record.txt’ –single-version-externally-managed –compile –install-headers ‘c:\users\risha\py
    cwd: C:\Users\risha\AppData\Local\Temp\pip-install-fsk2jhzj\pyaudio\
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    copying src\pyaudio.py -> build\lib.win-amd64-3.9
    running build_ext
    building ‘_portaudio’ extension
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ERROR: Command errored out with exit status 1: ‘c:\users\risha\pycharmprojects\shortner\venv\scripts\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0]
    = ‘”‘”‘C:\\Users\\risha\\AppData\\Local\\Temp\\pip-install-fsk2jhzj\\pyaudio\\setup.py’”‘”‘; __file__=’”‘”‘C:\\Users\\risha\\AppData\\Local\\Temp\\pip-install-fsk2j
    hzj\\pyaudio\\setup.py’”‘”‘;f=getattr(tokenize, ‘”‘”‘open’”‘”‘, open)(__file__);code=f.read().replace(‘”‘”‘\r\n’”‘”‘, ‘”‘”‘\n’”‘”‘);f.close();exec(compile(code, __fi
    le__, ‘”‘”‘exec’”‘”‘))’ install –record ‘C:\Users\risha\AppData\Local\Temp\pip-record-dzj167aq\install-record.txt’ –single-version-externally-managed –compile –i
    nstall-headers ‘c:\users\risha\pycharmprojects\shortner\venv\include\site\python3.9\pyaudio’ Check the logs for full command output.

    1. You can install pyaudio by Unofficial binary of python download pyaudio same as python version then install by opening command prompt in the folder where it downloaded and write pip install then pyaudio file name

  2. The way you write make it especially trouble-free to read. And the design you use, wow. Its a really good combination. And I am wondering what is the name of the theme you use?

  3. I think youve created some actually interesting points. Not as well many people would basically think about this the way you just did. Im truly impressed that theres so very much about this topic thats been uncovered and you did it so nicely, with so a lot class. Superior one you, man! Actually excellent things here.

Comments are closed.