JARVIS Thumbnail 3

Adding Wake Up Feature to Jarvis | HotBar In Jarvis | Jarvis In Python #31 min read

Hey Python Programmers, This is Just a Sequel Of Previous Parts Jarvis Part 1 & Jarvis Part 2.In this We will be Adding a a HotBar to Jarvis. This will Add Wake Up Feature to Jarvis When User’s Says “Wake Up Jarvis” Jarvis will Respond To You.

What Is HotBar?

HotBar is a separate File Created to Make Jarvis Wake when User Says Wake Jarvis. Jarvis Responds To You.

Step 1: Create Separate File HotBar.py

Step 2: Copy the Following Code:

import os
import pyttsx3
import datetime
import speech_recognition as sr

engine = pyttsx3.init('sapi5')
voices  = engine.getProperty('voices')
# print(voices[1].id)
engine.setProperty('voice', voices[0].id)

def speak(audio):
    engine.say(audio)
    engine.runAndWait()

def wish():
    hour  = int(datetime.datetime.now().hour)
    if hour >=0 and hour<12:
        speak("Good Morning Sir!, i am jarvis, how may i help you?")

    elif hour >=12 and hour<18:
        speak("Good Afternoon Sir!, i am jarvis, how may i help you?")

    else:
        speak("Good Evening Sir!, i am jarvis, how may i help you?")


def takeCommand():
   r = sr.Recognizer()
   with sr.Microphone() as source:
    print("Listening...")
    r.pause_threshold = 1
    audio = r.listen(source)

    try:
        print("Recongizing...")
        query = r.recognize_google(audio, language='en-in')
        print(f"User Said: {query}\n")

    except Exception as e:
    #    print(e)
       print("Say that Again")
       return "None"
    return query

while True:

    wake_up = takeCommand()

    if 'wake up' in wake_up:
        os.startfile('C:\\Users\\Tanmay Sinha\\Desktop\\Voice Assitant PTTSX3\\assitant.py')
    else:
        print('Something Went Wrong...')

So This Was it For this Blog, See you In the Next One Till Then Keep Coding Keep Exploring!

DOWNLOAD SOURCE CODE

Tanmay Sinha

Author

  • Tanmay Sinha

    Founder & CEO of MrProgrammer.in | I help Learning Freaks to Step into the World of Programming and Our Mission is to Provide High Quality and Valuable Content to Our Users! We believe that everyone has the potential to learn to code, and we are committed to making that happen. Our courses are designed to be engaging and interactive, and we offer a variety of learning paths to meet the needs of all learners. We are also committed to providing our learners with the support they need to succeed, and we offer a variety of resources to help learners learn at their own pace. If you are interested in learning to code, we encourage you to check out our courses. We are confident that you will find our content to be high-quality, valuable, and makes sense.

One comment

Leave a Reply