Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
Asked
Viewed
3 times
This piece of code is pretty simple as I am a new guy and I have built it as is satisfies much of my requirements. Where I am actually facing a problem is that I want Jarvis to keep on asking me his help till I say my final ‘no’ i.e. I wanted to loop def allbegins() and created another function through which i could do it. But still I am unable to as there is some mistake in my code as I don’t even get an error. So my code is wrong, can you help me please?
def allbegins():
import os
import pywhatkit
import pyttsx3
import pyaudio
import speech_recognition as sr
listener = sr.Recognizer()
engine = pyttsx3.init()
engine.say('Hi, I am your personal assistant . what can i do for you? ')
engine.runAndWait()
try:
with sr.Microphone() as source:
print('listening.....')
voice = listener.listen(source)
command = listener.recognize_google(voice)
print(command)
except:
pass
import pywhatkit
import pyttsx3
import pyaudio
import speech_recognition as sr
import os
if 'my browser' in command:
os.startfile('C:Program FilesBraveSoftwareBrave-BrowserApplicationBrave.exe')
if 'show disk usage' in command:
os.startfile("C:ProgramDataMicrosoftWindowsStart MenuProgramsSystem ToolsTask Manager.lnk")
if 'clean cache' in command:
os.startfile("C:ProgramDataMicrosoftWindowsStart MenuProgramsAdministrative ToolsDisk Cleanup.lnk")
if 'i want to compress some files' in command:
os.startfile(r"C:UsersDELLAppDataRoamingMicrosoftWindowsStart MenuProgramsFreeArc.lnk")
if 'telegram' in command:
os.startfile("C:Program FilesTelegramMessengerLLP.TelegramDesktop_2.7.0.0_x64__t4vj0pshhgkwmTelegram.exe")
if 'Notepad' in command:
os.system("notepad.exe")
if 'Whatsapp' in command:
os.startfile('https://web.whatsapp.com/')
if 'favourite whatsapp' in command:
os.startfile("C:Program FilesWindowsApps5319275A.WhatsAppDesktop_2.2108.9.0_x64__cv1g1gvanyjgmappWhatsApp.exe")
if 'MS Word' in command:
os.startfile("C:ProgramDataMicrosoftWindowsStart MenuProgramsWord.lnk")
if 'MS PowerPoint' in command:
os.startfile("C:ProgramDataMicrosoftWindowsStart MenuProgramsPowerPoint.lnk")
if 'file explorer' in command:
os.startfile('explorer.exe')
if 'PDF reader' in command:
os.startfile("C:ProgramDataMicrosoftWindowsStart MenuProgramsAcrobat Reader DC.lnk")
if 'camera' in command:
os.system('start microsoft.windows.camera:')
if 'CMD' in command:
os.system('cmd.exe')
if 'song' in command:
os.startfile(r"C:UsersDELLPycharmProjectsMYJARVISvenv132.mp3")
if 'play' in command:
pywhatkit.playonyt(command)
if 'who is' in command:
pywhatkit.search(command)
if 'tell me about' in command:
pywhatkit.search(command)
if 'open browser and type' in command:
pywhatkit.search(command)
def allending():
import pyttsx3
import os
import speech_recognition as sr
import pyaudio
import pywhatkit
from threading import Thread
listeners = sr.Recognizer()
engines= pyttsx3.init()
engines.say('Hi, DHUNGA ')
engines.runAndWait()
with sr.Microphone() as sources:
print('listening.....')
voices = listener.listen(sources)
COM = listener.recognize_google(voices)
print(COM)
if COM == 'no':
print('THANKS')
if COM == 'yes':
Thread(target= allbegins).start()```
ROHIT coder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
lang-py
