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!
Latest posts by Tanmay Sinha (see all)
- Which is the Best Operating System for Programming? Here are 3 OS to Consider - August 24, 2024
- Top 10 Cybersecurity Threats to Watch Out for in 2024 - August 17, 2024
- How Much Do Ethical Hackers Earn in India Per Month (Salary Guide) - August 11, 2024
Pingback: Drink Water Reminder Using Python | Python Projects For Beginners - Mr Programmer