Jarvis and Google Assistant || Voice Assistant Using Python

SpyroAI Avatar
\"Jarvis

As advances in technology have occurred, voice assistants have

developed into an indispensable component of our everyday lives. They are now even more complex and clever. Two well-known voice assistants that have dominated the market are Jarvis and Google Assistant. In this post, we\’ll look at how to use Python to build your own digital assistant that can take on these industry heavyweights.

Jarvis, who is he?

A voice assistant by the name of Jarvis was

inspired by the clever AI assistant from the Iron Man movies. It is a personal assistant that can do a variety of things for you, including live performances, answering inquiries, setting alarms, and controlling home appliances. The nice thing is that you may modify it to meet your needs.

How does Google Assistant work?

On the other side, Google Assistant is a voice assistant with AI that something that built. It is accessible on a lot of gadgets, including smart screens, smart speakers, and smartphones. The Google Assistant is capable of sending texts, making calls, creating reminders, and even managing your smart home appliances.

Making a Voice Assistant

Let\’s go on to the fun phase now. How can Python be employed in order to build your own voice assistant? The steps you must take are as follows:

Install the necessary libraries in Step 1

Installing the required libraries for text-to-speech translation and speech recognition is the first step. Popular libraries include PyAudio, gTTS, and SpeechRecognition.

Step 2: Record Audio

Next, you need to record audio using a microphone. You can use the PyAudio library to record audio in real-time.

Step 3: Speech Recognition

After recording the audio, you need to convert it into text using speech recognition. The SpeechRecognition library can help you achieve this.

Step 4: Text-to-Speech Conversion

Once you have converted the audio into text, you need to convert the text back into speech. The gTTS library can help you achieve this.

Step 5: Perform Actions

Now that you have created a basic voice assistant, it\’s time to add some functionality. You can perform various tasks such as playing music, sending emails, and even controlling your home appliances.

Code

import pyttsx3

import speech_recognition as sr

def take_commands():

r = sr.Recognizer()

with sr.Microphone() as source:
    print(\'Listening\')
    r.pause_threshold = 0.7

    audio = r.listen(source)
    try:
        print(\"Recognizing\")

        Query = r.recognize_google(audio)
        print(\"the query is printed=\'\", Query, \"\'\")
    except Exception as e:
        print(e)
        print(\"Say that again sir\")

        return \"None\"

return Query

def Speak(audio):

engine = pyttsx3.init()

engine.say(audio)
engine.runAndWait()

if name == \’main\’:

while True:
    command = take_commands()
    if \"exit\" in command:
        Speak(\"Sure sir! as your wish, bai\")
        break
    if \"insta\" in command:
        Speak(\"Best python page on instagram is pythonhub\")
    if \"learn\" in command:
        Speak(\"spyroai website is best to learn python\")
    if \"code\" in command:
               Speak(\"You can get this code from spyroai website\")

Conclusion

A fun and engaging project that can teach you new skills and enable you to develop a personalised assistant that meets your needs is building your own smart speaker using Python. You must provide high-quality material that is educational, entertaining, and beneficial to the reader if you want to outrank the competition. You may generate material that will assist you rank better in Google\’s search results by using the advice that this post offers.