Make a personal assitant like jarvis in Python – Make Jarvis using Python code

Here I am going to share some code in python which uses library function to make Jarvis using Python codes. This will help you learning python.

Make Jarvis using Python

Mark Zuckerberg has developed his own personal assistant that works like Ironman’s Jarvis. He is a big man with so many resources you can also build one useful for you.

Python is a very advance language which is helpful in many task. Well here we can use the TTS libraries, speech recognition and synthesis that will help you to create personal assistant.

I learnt this from a blog post of Gurwinder Gulati who shared the code with Internet. He made a personal assistant for himself. He named it Samwise & explains his code. The code is divided into two parts i.e. Jarvis’s Mouth, Jarvis’s Ears, and Jarvis’s Brain.

Also Read : Know about the Developer preview of Android O

  1. Mouth: does the text-to-speech conversion process.
  2. Ears:  Does speech recognition.
  3. Jarvis’s Brain. : process the speech & do corresponding actions.

As all the resources are collected now. According to this now you need to assemble the resources & code.

The code for this written here. You can assemble all the code & libraries with some research.

Jarvis code download –  Python  speech recognition offline

import speech_recognition
import pyttsx
speech_engine = pyttsx.init(‘sapi5’) # see http://pyttsx.readthedocs.org/en/latest/engine.html#pyttsx.init
speech_engine.setProperty(‘rate’, 150)
def speak(text):
speech_engine.say(text)
speech_engine.runAndWait()
recognizer = speech_recognition.Recognizer()
def listen():
with speech_recognition.Microphone() as source:
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
return recognizer.recognize_sphinx(audio)
# or: return recognizer.recognize_google(audio)
except speech_recognition.UnknownValueError:
print(“Could not understand audio”)
except speech_recognition.RequestError as e:
print(“Recog Error; {0}”.format(e))
return “”
speak(“Say something!”)
speak(“I heard you say ” + listen())

If you made it & start using the assistant, you can write us in the comment box to let us know. Thank you for the support. Like us on Facebook for more Updates. Thank You.

1 Comment

  1. Aibel
    May 13, 2019

    File “jarvis.py”, line 4
    SyntaxError: Non-ASCII character ‘\xe2’ in file jarvis.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Leave a Comment