I was building a human following 4 wheel powered car which would follow you where ever you go. It is powered by battery and it contains a Bluetooth module and I have made a python code of my personal assistant which works on a PC but we can’t carry our laptop everywhere so the car would follow you and do thing by your voice commands.
Tools used:
Hardware:
- Arduino UNO
- IR sensors
- Ultrasonic sensors
- Servo motor
- motor
- Motor Driver Shield
- Bluetooth
- Microphone
- Speaker
Software:
1\. Python
2\. Arduino IDE
The personal assistant can send whatsapp messages, search on google, play music, tell about weather, show your saved networks with password, join classes on google meet with account login, tell news, read pdf, set alarm, tell your location, open apps and websites, tell time, talk to you, open folders, shut down restart hibernate the system and many more things.
code:
from email import message
from itertools import count
from math import trunc
from re import A
import string
from urllib.request import Request
import bs4
import pyttsx3
import datetime
from pywhatkit.help import shutdown
import selenium
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote import webelement
from selenium.webdriver.remote.webelement import WebElement
import speech_recognition as sr
from urllib3 import request
import wikipedia
import webbrowser
import os
import pywhatkit as kit
import pyautogui
from wikipedia import exceptions
name=""
import smtplib
import time
from plyer import notification
import pyyoutube
import pyjokes
import requests
from bs4 import BeautifulSoup
import psutil
import speedtest
import twilio
from geopy.geocoders import Nominatim
import pyowm
import keyboard
import json
import urllib
import phonenumbers
from phonenumbers import geocoder
from phonenumbers import carrier
import geocoder
from configparser import ConfigParser
import requests
from tkinter import *
from tkinter import messagebox
import random
import socket
import subprocess
import re
from twilio.rest import Client
import pyqt5_tools
engine = pyttsx3.init(‘sapi5’)voices = engine.getProperty(‘voices’)
engine.setProperty(‘voice’, voices[0].id)engine.setProperty(‘rate’, 185)def speak(audio): engine.say(audio) engine.runAndWait()def wishMe(): hour= int(datetime.datetime.now().hour) if hour>=0 and hour<=12: speak(“Good Morning!”) elif hour>=12 and hour<=0: speak(“Good Afternoon!”) else: speak(“Good Evening”) speak(“Sir, I am JARVIS . How can I help you”)def takeCommand(): r = sr.Recognizer()
with sr.Microphone() as source: print(“Listening…”) r.pause_threshold=0.5 audio = r.listen(source)
try: print(“Recognizing…”) query = r.recognize_google(audio) print(f"User said:{query}\n ")
except Exception as e: print(e) #speak(“Say that Again Please”) print(“Say that Again Please…”) return “None” return query
def saved_wifi():
# now we will store the profiles data in “data” variable by # running the 1st cmd command using subprocess.check_output data = subprocess.check_output([‘netsh’, ‘wlan’, ‘show’, ‘profiles’]).decode(‘utf-8’).split(‘\n’)
# now we will store the profile by converting them to list profiles = [i.split(“:”)[1][1:-1] for i in data if “All User Profile” in i]
# using for loop in python we are checking and printing the wifi # passwords if they are available using the 2nd cmd command for i in profiles: # running the 2nd cmd command to check passwords results = subprocess.check_output([‘netsh’, ‘wlan’, ‘show’, ‘profile’, i, ‘key=clear’]).decode(‘utf-8’).split(‘\n’) # storing passwords after converting them to list results = [b.split(“:”)[1][1:-1] for b in results if “Key Content” in b] # printing the profiles(wifi name) with their passwords using # try and except method try: print (“{:<30}| {:<}”.format(i, results[0])) except IndexError: print (“{:<30}| {:<}”.format(i, ""))
def news(): main_url=‘[Login to see the link]’
main_page=requests.get(main_url).json() articles=main_page[“articles”] head=[] day=[“first”,“second”,“third”,“forth”,“fifth”,“sixth”,“seventh”,“eighth”,“ninth”,“tenth”] for ar in articles: head.append(ar[“title”]) for i in range: speak(f"today’s{day} news is:{head}" )
def pdf_reader(): book=open()
def alarm(): time_to_open=open(‘C:\\Users\\Lenovo\\Documents\\HTML\\main.py\\Voice Assistant\\data.txt’) time_to_open.write(query) time_to_open.close os.startfile('')
def tracker(): speak(“Write the phone number to track”) number = input() ch_number = phonenumbers.parse(number,‘CH’) s_num = phonenumbers.parse(number,‘RO’) print(carrier.name_for_number(s_num,“en”)) speak(carrier.name_for_number(s_num,“en”))
def location(): g = geocoder.ip(‘me’) print(g.latlng)
def speedtest(): st = speedtest.Speedtest() ds = st.download() us = st.upload() speak(f"Sir,, the download speed is {ds} bytes per second and upload speed is {us} bytes per second") try: os.system(‘cmd /k “speedtest”’)
except: speak(“There is no internet connection”)
while True: wakeup=takeCommand() if(‘wake up’) in wakeup: break
while True:
if name == “main”: wishMe()
query = takeCommand().lower() if ‘wikipedia’ in query: speak(“Searching wikipedia…”) query= query.replace(“wikipedia”,"") results=wikipedia.summary(query,sentences=4) speak(“According to wikipedia”) print(results) speak(results)
elif(“we are”) in query: hostname = socket.gethostname() Ip = socket.gethostbyname(hostname) print(“Your Computer Name is:” + hostname) print(“Your Computer IP Address is:” + Ip) elif(‘weather’) in query: headers = {‘User-Agent’: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3’}
def weather(city): city=city.replace(“ ”,“+”) res = requests.get(f’[Login to see the link]) print(“Searching in google……\n”) soup = BeautifulSoup(res.text,‘html.parser’) location = soup.select(‘#wob_loc’)[0].getText().strip() time = soup.select(‘#wob_dts’)[0].getText().strip() info = soup.select(‘#wob_dc’)[0].getText().strip() weather = soup.select(‘#wob_tm’)[0].getText().strip() print(location) print(time) print(info) print(weather+“°C”) if(info==‘Haze’): info=‘not clear and it might rain’ speak(f"The sky is {info} and the temperature is {weather} degree celsius")
print(“Tell me the city name of which you want to know the weather”) speak(“Tell me the city name of which you want to know the weather”) city=takeCommand() city=city+“ weather” weather(city)
elif ‘open youtube’ in query: webbrowser.open(“youtube.com”) elif ‘open unacademy’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘schedule of unacademy’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘open my website’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘mera website kholo’ in query: webbrowser.open(“[Login to see the link]”) elif ‘open whatsapp’ in query: webbrowser.open(“web.whatsapp.com”)
elif ‘whatsapp kholo’ in query:
webbrowser.open(“web.whatsapp.com”)
elif ‘open telegram’ in query: webbrowser.open(“web.telegram.com/k/”)
elif ‘telegram kholo’ in query: webbrowser.open(“web.telegram.com/k/”)
elif ‘open my mail’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘open my school mail’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘mera school mail kholo’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘mera mail kholo’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘mera microsoft mail kholo’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘open my microsoft mail’ in query: webbrowser.open(“[Login to see the link]”)
elif ‘open google’ in query: webbrowser.open(“google.com”)
elif (‘what is the time’) in query: strTime = datetime.datetime.now().strftime(“%H’hour’ %M’minutes’ %S’seconds’”) speak(f"Sir, the time is{strTime}")
elif ‘open google and search’ in query: speak=“What do you want me to search” webbrowser.open(f"google.com/search?q={query}") elif(‘hey jarvis’) in query: speak(“Hello sir, What can I do for you”)
elif (‘how are’) in query: speak(“I am fine sir how are you”)
elif (‘you born’) in query: speak(“I was born on second of july twenty twenty one” )
elif (‘fine’) in query: speak(“Tell me what can I do for you”)
elif (‘who are you’) in query: speak(“sir, I am jarvis your personal assistant”)
elif(‘you know me’) in query: speak(“what should I call you sir, please tell me your name”) name= takeCommand() speak(f"Welcome Mister{name}“) elif(‘what is my name’) in query: if(name==”"): speak(“you never told me your name, please tell me your name”) name=takeCommand().lower() speak(“welcome mister”) speak(name) else: speak(name)
elif(‘open my folder’) in query: myfolderPath= “C:\\Users\\Lenovo\\Desktop\\HARSH” os.startfile(myfolderPath)
elif(‘open java’) in query: java_dir= “C:\\Program Files\\BlueJ” java=os.listdir(java_dir) os.startfile(os.path.join(java_dir, java[5]))
elif(‘exit’) in query: speak(“Okay .,sir Call me when ever you need I will be there for you”) break
elif(‘go to sleep’) in query: speak(“Okay sir,. Call me, whenever you need I will be there for you”) while True: hotword=takeCommand().lower() if(‘wake up’) in hotword: wishMe() break elif(‘hibernate my system’) in query: speak(“Are you sure you want to put your system on hibernate?”) sleep_pc=takeCommand().lower() if(‘yes’) in sleep_pc: speak(“Okay sir,,, Your system will go to hibernate in 10 seconds”) time.sleep(10) os.system(“rundll32.exe powrprof.dll,SetSuspendState 0,1,0”)
elif(‘switch window’) in query: pyautogui.keyDown(“alt”) pyautogui.press(“tab”) time.sleep(1) pyautogui.keyUp(“alt”)
elif(‘search youtube’) in query: speak(‘What do you want me to search’) search_yt=takeCommand() speak(‘okay sir’) pyyoutube.SearchResult(search_yt)
elif(‘play youtube’) in query: speak(“Okay sir”) kit.playonyt(“feded”)
elif(‘relaxing music on youtube’) in query: speak(“Okay sir”) kit.playonyt(“[Login to see the link]”)
elif(‘relaxing music’) in query: speak(“Okay sir”) kit.playonyt(“[Login to see the link]”)
elif(‘play music’) in query: speak(“Which song do you want me to play?”) song_play=takeCommand() speak(“Okay sir”) song_play=str(song_play) from selenium import webdriver from selenium.webdriver.chrome.options import Options import time from selenium.webdriver.common.keys import Keys import pyautogui opt=Options() opt.add_argument(“start-maximized”) driver=webdriver.Chrome(chrome_options=opt, executable_path=‘C:\\Users\\Lenovo\\Documents\\HTML\\main.py\\Voice Assistant\\chromedriver.exe’) time.sleep(10) driver.get(“[Login to see the link]”) time.sleep(8) search_song=driver.find_element_by_xpath(‘//*[@id=“layout”]/ytmusic-nav-bar/div[2]/ytmusic-search-box/div/div[1]/tp-yt-paper-icon-button[1]’) search_song.click() search_song.send_keys(song_play) time.sleep(1) pyautogui.press(“enter”) time.sleep(1) pyautogui.leftClick(461,407) time.sleep(5) pyautogui.click()
elif(‘help me relax’) in query: speak(“Okay sir”) kit.playonyt(“[Login to see the link]”)
elif(‘me concentrate’) in query: speak(“Okay sir”) kit.playonyt(“[Login to see the link]”)
elif(‘to concentrate’) in query: speak(“Okay sir”) kit.playonyt(“[Login to see the link]”)
elif(‘search on google’) in query: speak(“what do you want me to search”) google_search = takeCommand() kit.search(google_search)
elif(‘good night’) in query: speak(“Okay sir,. Call me when ever you need I will be there for you”) break
elif(‘open my photography form’) in query: form_dir=“C:\\Users\\Lenovo\\Desktop\\HARSH\\PHOTO…..IDENTITY” forms= os.listdir(form_dir) print(forms) os.startfile(os.path.join(form_dir, forms[4]))
elif(‘leave me alone’) in query: speak(“okay sir I will automatically appear after 30 minutes”) time.sleep(30*60)
elif(‘open edge’) in query: speak(“okay sir”) edge_dir=“C:\\Program Files (x86)\Microsoft\\Edge\\Application” edge=os.listdir(edge_dir) os.startfile(os.path.join(edge_dir,edge[2]))
elif(‘open microdoft edge’) in query: speak(“okay sir”) edge_dir=“C:\\Program Files (x86)\Microsoft\\Edge\\Application” edge=os.listdir(edge_dir) os.startfile(os.path.join(edge_dir,edge[2]))
elif(‘open microsoft browser’) in query: speak(“okay sir”) edge_dir=“C:\\Program Files (x86)\Microsoft\\Edge\\Application” edge=os.listdir(edge_dir) os.startfile(os.path.join(edge_dir,edge[2]))
elif(‘shut down’) in query: speak(“Are you sure you want to shutdown?”) shutdown_pc=takeCommand().lower() if(‘yes’) in shutdown_pc: speak(“Have you saved your work? Please say yes or no”) save_work=takeCommand().lower() elif(‘yes’) in save_work(): speak(“Okay sir shutting down your pc”) os.system(“shutdown /s /t1”) elif(‘no’) in save_work: speak(“Please save your work and say, yes”) hotword_shutdown=takeCommand().lower() if(‘yes’) in hotword_shutdown: os.system(“shutdown /s /t1”) else: speak(“Please save your work and say, yes”) hotword_shutdown=takeCommand().lower() if(‘yes’) in hotword_shutdown: os.system(“shutdown /s /t1”)
elif(‘shut down’) or (‘shutdown’) in query: speak(“Are you sure you want to shutdown?”) shutdown_pc=takeCommand().lower() if(‘yes’) in shutdown_pc: speak(“Have you saved your work? Please say yes or no”) save_work=takeCommand().lower() elif(‘yes’) in save_work(): speak(“Okay sir shutting down your pc”) os.system(“shutdown /s /t1”) elif(‘no’) in save_work: speak(“Please save your work and say, yes”) hotword_shutdown=takeCommand().lower() if(‘yes’) in hotword_shutdown: os.system(“shutdown /s /t1”) else: speak(“Please save your work and say, yes”) hotword_shutdown=takeCommand().lower() if(‘yes’) in hotword_shutdown: os.system(“shutdown /s /t1”) elif(‘schedule’) in query: day=datetime.datetime.now() day=day.strftime(‘%A’) speak(“Today is”+day) print(day) if day==‘Monday’: speak(“you have three classes in school today. Mathematics at from seven thirty to eight thirty….Computer science from nine thirty to ten thirty..and Physics from eleven thirty to twelve thirty ”) if day==‘Tuesday’: speak(“you have three classes in school today. Computer science at from seven thirty to eight thirty….Mathematics from nine thirty to ten thirty..and Physics from eleven thirty to twelve thirty”) if day==‘Wednesday’: speak(“you have three classes in school today. English at from seven thirty to eight thirty….Chemistry from nine thirty to ten thirty..and Physics from eleven thirty to twelve thirty”) if day==‘Thursday’: speak(“you have three classes in school today. Physics at from seven thirty to eight thirty….English from nine thirty to ten thirty..and Chemistry from eleven thirty to twelve thirty”) if day==‘Friday’: speak(“you have three classes in school today. Mathematics at from seven thirty to eight thirty….Chemistry from nine thirty to ten thirty..and Computer Science from eleven thirty to twelve thirty”) if day==‘Saturday’: speak(“you have three classes in school today. Chemistry at from seven thirty to eight thirty….English from nine thirty to ten thirty..and Mathematics from eleven thirty to twelve thirty”) if day==‘Sunday’: speak(“you don’t have any class today”) elif(“whatsapp”) in query: speak(“tell me the exact contact name to send the message”) person_to_send=takeCommand() speak(“What message should I send”) message_to_send=takeCommand() webbrowser.open(‘[Login to see the link]’) pyautogui.position(1294,404) time.sleep(1) pyautogui.click() time.sleep(10) pyautogui.press(“tab”)
pyautogui.typewrite(person_to_send) time.sleep(5) pyautogui.press(“tab”) time.sleep(5) pyautogui.press(“enter”) pyautogui.typewrite(message_to_send) time.sleep(5) pyautogui.press(“enter”) speak(“message sent successfully”)
elif(‘want information’) in query: speak(“What information do you want from me?”) information=takeCommand() speak(kit.info(information))
elif(‘volume up’) in query: speak(“With how much should I increase the volume. For example increase the volume by 10”) vol_increase=(str(takeCommand())) vol_increase=int(re.search(r’\d+', vol_increase).group()) vol_increase= int(vol_increase) for x in range(vol_increase): pyautogui.keyDown(“volumeup”) pyautogui.keyUp(“volumeup”) speak(“what else can I do for you”) query=takeCommand()
elif(‘want to sleep’) in query: speak(“Sir after how much time should I wake you up?”) go_sleep=(str(takeCommand())) if(‘minutes’) in go_sleep: num = ''.join(filter(lambda i: i.isdigit(), go_sleep)) speak(“Okay sir I will wake you up”) num=int(num) time.sleep(num*60) speak(“sir please wake up”) while True: speak(“Sir please wake up now,,,, Time is up and you should resume your work,,,,, Please say okay to stop”) work_resume=takeCommand() if(‘okay’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand() if(‘ok’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand() else: speak(“Sir please wake up now,,,, Time is up and you should resume your work,,,,, Please say okay to stop”)
if(‘hours’) in go_sleep: num = ''.join(filter(lambda i: i.isdigit(), go_sleep)) speak(“Okay sir I will wake you up”) num=int(num) time.sleep(num*60*60) speak(“sir please wake up”) while True: speak(“Sir please wake up now,,,, Time is up and you should resume your work,,,,, Please say okay to stop”) work_resume=takeCommand() if(‘okay’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand() if(‘ok’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand()
if(‘minute’) in go_sleep: num = ''.join(filter(lambda i: i.isdigit(), go_sleep)) speak(“Okay sir I will wake you up”) num=int(num) time.sleep(num*60) speak(“sir please wake up”) while True: speak(“Sir please wake up now,,,, Time is up and you should resume your work,,,,, Please say okay to stop”) work_resume=takeCommand() if(‘okay’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand() if(‘ok’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand() else: speak(“Sir please wake up now,,,, Time is up and you should resume your work,,,,, Please say okay to stop”)
if(‘hour’) in go_sleep: num = ''.join(filter(lambda i: i.isdigit(), go_sleep)) speak(“Okay sir I will wake you up”) num=int(num) time.sleep(num*60*60) speak(“sir please wake up”) while True: speak(“Sir please wake up now,,,, Time is up and you should resume your work,,,,, Please say okay to stop”) work_resume=takeCommand() if(‘okay’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand() if(‘ok’) in work_resume: speak(“Okay sir,,,, Please tell me what can I do”) query=takeCommand() else: speak(“Sir please wake up now,,,, Time is up and you should resume your work,,,,, Please say okay to stop”)
elif(‘join meeting’) in query: speak(“okay sir., Please type out the meeting code”) code_meet=input(string) from selenium import webdriver from selenium.webdriver.chrome.options import Options import time from selenium.webdriver.common.keys import Keys opt=Options() opt.add_argument(“start-maximized”) opt.add_argument(“–disable-extentions”) opt.add_experimental_option(“prefs”,{ “profile.default_content_setting_values.media_strem_mic”: 1, “profile.default_content_setting_values.media_strem_camera”:1, “profile.default_content_setting_values.geolocation”:1, “profile.default_content_setting_values.notification”:1, })
driver=webdriver.Chrome(chrome_options=opt, executable_path=‘C:\\Users\\Lenovo\\Documents\\HTML\\main.py\\Voice Assistant\\chromedriver.exe’) driver.get(‘[Login to see the link]’) username=driver.find_element_by_xpath(‘//*[@id=“identifierId”]’) username.click() username.send_keys(‘[Login to see the link]’)
next=driver.find_element_by_xpath(‘//*[@id=“identifierNext”]/div/button’) next.click()
time.sleep(5) password=driver.find_element_by_xpath(‘//*[@id=“password”]/div[1]/div/div[1]/input’) #password.send_keys() password.send_keys(‘hrdr211170@#’) next=driver.find_element_by_xpath(‘//*[@id=“passwordNext”]/div/button/span’) next.click()
time.sleep(8)
driver.get(‘[Login to see the link]’)
time.sleep(6) code=driver.find_element_by_xpath(‘//*[@id=“i3”]’) code.send_keys(code_meet) join_meet=driver.find_element_by_xpath(‘//*[@id=“yDmH0d”]/c-wiz/div/div[2]/div/div[1]/div[3]/div/div[2]/div[2]/button’) join_meet.click()
time.sleep(5) dismiss=driver.find_element_by_xpath(‘//*[@id=“yDmH0d”]/div[3]/div/div[2]/div[3]/div/span/span’) dismiss.click() time.sleep(10) pyautogui.leftClick(380, 222) time.sleep(5) pyautogui.click() time.sleep(5) pyautogui.position(380, 222) time.sleep(5) pyautogui.click time.sleep(5) cam_off=driver.find_element_by_xpath(‘//*[@id=“yDmH0d”]/c-wiz/div/div/div[9]/div[3]/div/div/div[4]/div/div/div[1]/div[1]/div/div[4]/div[2]/div/div/span’) cam_off.click()
time.sleep(2)
mic_off=driver.find_element_by_xpath(‘//*[@id=“yDmH0d”]/c-wiz/div/div/div[9]/div[3]/div/div/div[4]/div/div/div[1]/div[1]/div/div[4]/div[1]/div/div/div/span/span’) mic_off.click()
time.sleep(10)
join_class=driver.find_element_by_xpath(‘//*[@id=“yDmH0d”]/c-wiz/div/div/div[9]/div[3]/div/div/div[4]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span/span’) join_class.click()
time.sleep(5) speak(“meeting joined successfully”)
elif(‘leave meeting’) in query: speak(“Okay sir”) leave_class=driver.find_element_by_xpath(‘//*[@id=“ow3”]/div[1]/div/div[9]/div[3]/div[10]/div[2]/div/div[6]/span/button’) leave_class.click() elif(‘turn on microphone’) in query: speak(“Okay sir”) mic_off=driver.find_element_by_xpath(‘//*[@id=“ow129”]/div/span/button’) mic_off.click()
elif(‘turn off microphone’) in query: speak(“Okay sir”) mic_off=driver.find_element_by_xpath(‘//*[@id=“ow129”]/div/span/button’) mic_off.click()
elif(‘refresh’) in query: speak(“okay sir”) pyautogui.keyDown(“ctrl”) pyautogui.press(“r”) pyautogui.keyUp(“ctrl”)
elif(‘news’) in query: speak(“Fetching latest news”) news()
elif(‘camera on’) in query: speak(“Okay sir”) join_class=driver.find_element_by_xpath(‘//*[@id=“ow3”]/div[1]/div/div[9]/div[3]/div[10]/div[2]/div/div[2]/div/span/button/div[2]’) join_class.click()
elif(‘camera on’) in query: speak(“Okay sir”) join_class=driver.find_element_by_xpath(‘//*[@id=“ow3”]/div[1]/div/div[9]/div[3]/div[10]/div[2]/div/div[2]/div/span/button/div[2]’) join_class.click()
elif(‘save work’) in query: speak(“Saving your work”) pyautogui.keyDown(“ctrl”) pyautogui.press(“s”) time.sleep(1) pyautogui.keyUp(“ctrl”)
elif(‘mute’) in query: speak(“okay sir”) pyautogui.keyDown(“ctrl”) pyautogui.press(“m”) time.sleep(1) pyautogui.keyUp(“ctrl”)
elif(‘unmute’) in query: speak(“okay sir”) pyautogui.keyDown(“ctrl”) pyautogui.press(“m”) time.sleep(1) pyautogui.keyUp(“ctrl”)
elif(‘switch tab’) in query: pyautogui.keyDown(“ctrl”) pyautogui.press(“tab”) time.sleep(1) pyautogui.keyUp(“ctrl”)
elif(‘joke’) in query: speak(“okay sir”) joke=pyjokes.get_joke() print(joke) speak(joke) laugh_dir=“C:\\Users\\Lenovo\\Documents\\HTML\\main.py\\Voice Assistant” laugh= os.listdir(laugh_dir) print(laugh) os.startfile(os.path.join(laugh_dir, laugh[5]))
elif(“saved wifi”) in query: saved_wifi()
elif(‘battery’) in query: battery = psutil.sensors_battery() plugged = battery.power_plugged percent = str(battery.percent) plugged = “Plugged In” if plugged else “Not Plugged In” print(“We have ”+percent+ “% battery left”) print(“and it is ”+plugged) speak(“We have ”+percent+“ percent battery left”) speak(“and it is ”+plugged) percent=(int(percent)) if percent<=95 & plugged==‘Plugged In’: speak(“Your battery is enough charged but your device is still plugged., please remove your charger., avoid overcharging and save energy”) if plugged==‘Not Plugged In’: if (percent<=30): speak(“You should charge your system now”) elif plugged==‘Pluggged In’: speak(“your system is charging”)
elif(‘track’) in query: tracker()
elif(‘speed’) in query: speedtest()
elif(“hangman”) in query: speak(“okay sir”)
# Funtion to clear te terminal def clear(): os.system(“clear”) def print_hangman(values): print() print(“\t +——–+”) print(“\t | | |”) print(“\t {} | |”.format(values[0])) print(“\t{}{}{} | |”.format(values[1], values[2], values[3])) print(“\t {} | |”.format(values[4])) print(“\t{} {} | |”.format(values[5],values[6])) print(“\t | |”) print(“ ____________||”) print(“ `````````````````````”) print() # Function to print the hangman after winning def print_hangman_win(): print() print(“\t +——–+”) print(“\t | |”) print(“\t | |”) print(“\t O | |”) print(“\t/|\\ | |”) print(“\t | | |”) print(“ __/\\_||”) print(“ `````````````````````”) print() # Function to print the word to be guessed def print_word(values): print() print(“\t”, end="“) for x in values: print(x, end=”") print() # Function to check for win def check_win(values): for char in values: if char == ‘’: return False return True # Function for each hangman game def hangman_game(word): clear() # Stores the letters to be displayed word_display = [] # Stores the correct letters in the word correct_letters = [] # Stores the incorrect guesses made by the player incorrect = [] # Number of chances (incorrect guesses) chances = 0 # Stores the hangman’s body values hangman_values = [‘O’,‘/’,‘|’,‘\\’,‘|’,‘/’,‘\\’] # Stores the hangman’s body values to be shown to the player show_hangman_values = [‘ ’, ‘ ’, ‘ ’, ‘ ’, ‘ ’, ‘ ’, ‘ ’] # Loop for creating the display word for char in word: if char.isalpha(): word_display.append(‘_’) correct_letters.append(char.upper()) else: word_display.append(char) # Game Loop while True: # Printing necessary values print_hangman(show_hangman_values) print_word(word_display) print() print(“Incorrect characters : ”, incorrect) print() # Accepting player input inp = input(“Enter a character = ”) if len(inp) != 1: clear() print(“Wrong choice!! Try Again”) continue # Checking whether it is a alphabet if not inp[0].isalpha(): clear() print(“Wrong choice!! Try Again”) continue # Checking if it already tried before if inp.upper() in incorrect: clear() print(“Already tried!!”) continue # Incorrect character input if inp.upper() not in correct_letters: # Adding in the incorrect list incorrect.append(inp.upper()) # Updating the hangman display show_hangman_values[chances] = hangman_values[chances] chances = chances + 1 # Checking if the player lost if chances == len(hangman_v

But due to some error in the arduino board I ordered online I was unable to complete my whole project.