Exemple #1
0
def create_event():
    service = calendar_service()
    respond("summary of the event")
    summary = listen()
    year = datetime.now().year
    month = datetime.now().month
    date = get_event_date()
    hour, minute = get_event_time()
    event_duration = get_event_duration()
    start_day = datetime(year, month, date, hour, minute)
    start = start_day.isoformat()
    end = (start_day + timedelta(hours = event_duration)).isoformat()

    event = {
        'summary': summary,
        'start': {
            'dateTime': start,
            'timeZone': 'Asia/Kolkata',
        },
        'end': {
            'dateTime': end,
            'timeZone': 'Asia/Kolkata',
        },
        'attendees' : [
            {'email' : '*****@*****.**'}
        ]
    }
    event = service.events().insert(calendarId='primary', body=event).execute()
    respond("event created successfully")
    return
Exemple #2
0
def draw_status():
    global draw

    if winner is None:
        #message = XO.upper() + "'s Turn"
        if XO == "x":
            message = " It's your turn sir"
        else:
            time.sleep(1)
            message = " It's my turn sir"
    else:
        #message = winner.upper() + " won!"
        if winner == "x":
            message = "Your Won Sir!"
        else:
            message = "I won Sir!"
    if draw:
        message = 'Game Draw!'
    
    font = pg.font.Font(None, 30)
    text = font.render(message, 1, (255, 255, 255))

    screen.fill ((0, 0, 0), (0, 400, 500, 100))
    text_rect = text.get_rect(center=(width/2, 500-50))
    screen.blit(text, text_rect)
    pg.display.update()
    time.sleep(1)
    respond(message)
Exemple #3
0
def System_specs(data):
    if "battery" in data:
        battery = Battery()
        if "status" in data:
            battery.Status()

    elif "cpu" in data:
        cpu = CPU()
        if "status" in data:
            cpu.Status()

    elif "memory" in data:
        memory = Memory()
        if "usage" in data or "consumption" in data:
            memory.Usage()

    elif "brightness" in data:
        brightness = Brightness()
        if "status" in data or "current" in data:
            current_brightness_level = brightness.Status()
            respond("System brightness currently at {} percent".format(
                current_brightness_level))

        elif "set" in data:
            data = data.split(" ")
            brightness_toset = data[-2]
            brightness.SetBrightness(brightness_toset)

        elif "increase" in data:
            brightness.Increase()

        elif "decrease" in data:
            brightness.Decrease()
    return
Exemple #4
0
def get_event_duration():
    try:
        respond("event duration")
        event_duration = listen().split()
        event_duration = int(event_duration[0])
        return event_duration
    except:
        respond("Pardon me, please say that again")
        get_event_duration()
Exemple #5
0
def get_event_date():
    try:
        respond("event Date")
        date_ = (listen()).split()
        date = int(date_[1][0:2])
        return date
    except:
        respond("Pardon me,please say that again")
        get_event_date()
def internet_availability():
    try:
        url = "http://google.com/"
        timeout = 2
        _ = requests.get(url, timeout = timeout)
        return True
    except:
        respond("No internet connection!")
        return False
Exemple #7
0
def get_event_time():
    try:
        respond("event time")
        event_time = listen().split()
        hour = int(event_time[0][0:2])
        minute = int(event_time[0][-2:])
        if event_time[1][0] == "p":
            hour = hour + 12 
        return hour, minute
    except:
        respond("Pardon me,please say that again")
        get_event_time()
Exemple #8
0
 def Decrease(self):
     try:
         current_brightness = Brightness().Status()
         if current_brightness - 20 >= 0:
             sbc.set_brightness('-20')
         else:
             sbc.set_brightness(0)
         respond("Brightness Decreased")
     except:
         respond(
             "Sorry sir, I can't further decrease brightness as it is already in minimum state"
         )
Exemple #9
0
def calendar_events():
    service = calendar_service()
    now = datetime.now(IST)
    timeMin, timeMax = Get_Min_Max_times(now)
    print('Getting the upcoming events')
    event_results = service.events().list(calendarId='primary', timeMin=timeMin, 
                                          timeMax=timeMax, maxResults=10, 
                                          singleEvents=True, orderBy='startTime').execute()
    events = event_results.get('items', [])
    if not events:
        respond("No upcoming events found.")
    for event in events:
        start_time = event['start'].get('dateTime')
        date_time = start_time.split("T")
        event_date = date_time[0]
        event_time = date_time[1].split("+")
        respond("{} class is at {} {}".format(event['summary'], event_time[0], event_date))
    return 
def execute_commands():
    try:
        respond("okay sir!")
        respond("please give me the list of instruction to execute")
        a=[]
        while True:
            data = listen()
            if "that's it" in data:
                break
            else:
                a.append(data)
                respond("okay")
        for instruct in a:
            speech="your instruction {} is going to execute sir!".format(instruct)
            respond(speech)
            digital_assistant(instruct)       
    except:
        respond("sorry sir, there is an error occurred. Could you plese repeat commands to do!")
    return
Exemple #11
0
def New_access(name):
    cap = cv2.VideoCapture(0)
    while True:
        success, img = cap.read()
        imgS = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        facesCurFrame = face_recognition.face_locations(imgS)
        if len(facesCurFrame) == 1:
            y1, x2, y2, x1 = facesCurFrame[0][0], facesCurFrame[0][
                1], facesCurFrame[0][2], facesCurFrame[0][3]
            new_face = img[y1 - 40:y2 + 20, x1:x2]
            path = "{}/{}/{}{}".format("Images", "Access_members", name,
                                       ".jpg")
            cv2.imwrite(path, new_face)
            cv2.rectangle(img, (x1, y1 - 40), (x2, y2 + 20), (0, 255, 0), 2)
            cv2.imshow("webcam", img)
            cv2.waitKey(1)
            cv2.destroyAllWindows()
            return
            break
        elif len(facesCurFrame) >= 2:
            respond("I am getting more than one face")
            respond("I can't give access more than one at a time")
        else:
            respond("sorry sir! I couldn't recognize you")
        cv2.imshow("webcam", img)
        cv2.waitKey(1)
Exemple #12
0
def face_rec():
    path = "Images/Access_members"
    images = []
    names = []
    mylist = os.listdir(path)
    #print(mylist)
    for cl in mylist:
        curImg = cv2.imread(f'{path}/{cl}')
        images.append(curImg)
        names.append(os.path.splitext(cl)[0])
    #print(names)
    encodeListKnown = findEncoding(images)
    name = ""
    i = 0
    cap = cv2.VideoCapture(0)
    while True:
        success, img = cap.read()
        i += 1
        #print(i)
        imgS = cv2.resize(img, (0, 0), None, 0.25, 0.25)
        imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
        facesCurFrame = face_recognition.face_locations(imgS)
        #print(facesCurFrame)
        if facesCurFrame != []:
            encodesCurFrame = face_recognition.face_encodings(
                imgS, facesCurFrame)
            for encodeFace, faceLoc in zip(encodesCurFrame, facesCurFrame):
                matches = face_recognition.compare_faces(
                    encodeListKnown, encodeFace)
                faceDis = face_recognition.face_distance(
                    encodeListKnown, encodeFace)
                matchIndex = np.argmin(faceDis)
                if matches[matchIndex]:
                    name = names[matchIndex]
                if name in names:
                    #print("okay")
                    y1, x2, y2, x1 = faceLoc
                    y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
                    cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
                    cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0),
                                  cv2.FILLED)
                    name = name.upper()
                    cv2.putText(img, name, (x1 + 6, y2 - 6),
                                cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255),
                                2)
                    cv2.imshow("webcam", img)
                    cv2.waitKey(1)
                    respond("You are recognized!")
                    cv2.destroyAllWindows()
                    return True
                    break

                else:
                    respond("sorry sir!,I couldn't recognize you!")

        else:
            respond("Could You please allow me to scan your Face!")

        cv2.imshow("webcam", img)
        cv2.waitKey(1)
def wishme():
    hour=datetime.datetime.now().hour
    if hour>=0 and hour<12:
        respond("Good Morning")
    elif hour>=12 and hour<18:
        respond("Good Afternoon")
    else:
        respond("Good Evening")
Exemple #14
0
 def Increase(self):
     try:
         current_brightness = Brightness().Status()
         if current_brightness >= 100:
             respond(
                 "Sorry sir, I can't further increase brightness as it is already in maximum state"
             )
         else:
             sbc.set_brightness('+20')
             respond("Brightness Increased")
     except:
         respond(
             "Sorry sir, I can't further increase brightness as it is already in maximum state"
         )
            return
       elif 'email to' in data:
            try:
                respond("Sir, give me your message")
                print('Give message.......')
                content = takeCommand()
                to = "receiver email address"
                sendEmail(to, content)
                print('Sending mail........')
                respond("Email has been sent!")
            except Exception as e:
                print(e)
                respond("Sorry master . I am not able to send this email")

        else:
            respond("I can search the web for you,Do you want to continue?")
            opinion=listen()
            if opinion=="yes":
                url="https://www.google.com/search?q =" + '+'.join(data.split())
                webbrowser.get('chrome').open_new(url)
                time.sleep(5)
                return
            else:
                return
    except:
        respond("I don't understand, I can search the web for you,Do you want to continue?")
        opinion=listen()
        if opinion=="yes":
            url="https://www.google.com/search?q =" + '+'.join(data.split())
            webbrowser.get('chrome').open_new(url)
            time.sleep(5)
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.

#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.


import os
import time
from RespondListen import respond, listen
from digital_assistant import  init_check, intiate_jarvis, digital_assistant 
if __name__=="__main__":
    if init_check():
        intiate_jarvis()
        while True:
            respond("Please tell me how can i help you?")
            data = listen().lower()
            if data == 0:
                continue
            if "stop listening" in data or "ok bye" in data or "stop" in data or "exit" in data:
                os.system("taskkill /f /im Rainmeter.exe")
                respond("I am going to sleep sir")
                break
            digital_assistant(data)          
            time.sleep(2)
Exemple #17
0
 def SetBrightness(self, data):
     try:
         sbc.set_brightness(data)
         respond("Brightness set successfully!")
     except:
         respond("Sorry sir, I am unable to do that")
Exemple #18
0
 def Usage(self):
     process_id = os.getpid()
     py = psutil.Process(process_id)
     memory_use = round(py.memory_info()[0] / 2.**30, 2)
     respond(" I am currently using {} Gb of memory".format(memory_use))
Exemple #19
0
 def Status(self):
     respond("CPU is at " + str(psutil.cpu_percent()))
Exemple #20
0
 def Status(self):
     battery = psutil.sensors_battery()
     respond("Your system is at " + str(battery.percent) + " percent")
def access():
    respond("Are you confirm in access control transfer!")
    data = listen()
    if "confirm" in data or "yes" in data or "yeah" in data:
        respond("could you please say the name of  the person of whom you are going to give access")
        name = listen()
        respond("okay")
        respond("new visual confirmation required!")
        New_access(name)
        respond("access control transferred successfully!")
        return
    else:
        respond("are you sure in cancelling access control transfer!")
        data = listen()
        if data == "yes":
            return
        else:
            access()
Exemple #22
0
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.

#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.

import os
import time
from RespondListen import respond, listen
from digital_assistant import init_check, intiate_jarvis, digital_assistant, contain
if __name__ == "__main__":
    if init_check():
        intiate_jarvis()
        while True:
            respond("Please tell me how can i help you?")
            data = listen().lower()
            if data == 0:
                continue
            if contain(data, ["turn off", "stop", "exit", "bye"]):
                os.system("taskkill /f /im Rainmeter.exe")
                respond("I am going to sleep sir, Have a nice day!")
                break
            digital_assistant(data)
            time.sleep(2)
def digital_assistant(data):
    try:   
        if data == "jarvis":
            respond("yes sir! I am at your service")
            return
            
        elif "how are you" in data: 
            respond("I am well")
            return

        elif contain(data,["define yourself","what can you do","who are you"]):
            respond("I am viswanadh's personal assistant, I am programmed to do minor tasks like system monitoring, profiling,"
            "predict time, take a photo, predict weather,"
            " opening applications like youtube, google chrome ,gmail etcetre, show the top headline news and you can ask me computational or geographical questions too!")
            return
        
        elif contain(data,["who made you","who created you"]):
            respond("I was built by viswa")
            return

        elif "shutdown" in data:
            respond("Are you sure! you want to shutdown your computer")
            data = listen()
            if data == "yes":
                respond("system is going to shutdown...")
                os.system("taskkill /f /im Rainmeter.exe")
                os.system("shutdown /s /t 1")
                return
        
        elif "restart" in data:
            respond("want to restart your computer")
            data=listen()
            if data=="yes":
                os.system("shutdown /r /t 1")
                return

        elif "music" in data:
            respond("Here you go with music")
            music_dir = "C:\\Users\\VISWANADH\\Music"
            song = random.choice(os.listdir(music_dir))
            os.startfile(os.path.join(music_dir,song))
            time.sleep(5)
            return

        elif "movie" in data:
            os.system("D:\\movies\\Ala_Vaikunthapurramloo.mkv")
            time.sleep(5)
            return
        
        elif "notepad" in data:
            os.system("notepad")
            return

        elif contain(data,['select all','cut','copy','paste','history','download','undo','redo','save','enter','search','find']):
            Ctrl_Keys(data)
            return

        elif "open" in data:
            if "tab" in data:
                Tab_Opt(data)
                time.sleep(10)
                respond("what do you wanna search sir!")
                data = listen()
                if "search" in data:
                    keys.Paste()
                else:
                    pyautogui.typewrite(data)
                keys.Enter()
            elif "window" in data:
                Win_Opt(data)
            elif "chrome" in data:
                time.sleep(3)
                webbrowser.open("http://www.google.com/")
                time.sleep(10)
                respond("what do you wanna search sir!")
                data = listen()
                if "search" in data:
                    keys.Paste()
                else:
                    pyautogui.typewrite(data)
                keys.Enter()
            else:
                data = data.split(" ")
                query = data[1]
                for j in search(query, tld='com', lang='en', num=1, start=0, stop=1, pause=2.0):
                    url=j
                webbrowser.get('chrome').open_new(url)
                respond(data[1] + " is open now")
                time.sleep(7)
            return

        elif "news" in data:
            query = "news"
            url="https://timesofindia.indiatimes.com/home/headlines"
            webbrowser.get('chrome').open_new(url)
            respond("Here are some headlines from the Times of India,Happy reading")
            time.sleep(5)
            return
                
        elif "weather" in data:
            data=data.split(" ")
            api_key = "###############################"
            base_url = "https://api.openweathermap.org/data/2.5/weather?"
            if "in" not in data:
                city_name = "kurupam"
            else:
                city_name = data[-1]
            complete_url = base_url + "appid=" + api_key + "&q=" + city_name
            response = requests.get(complete_url)
            x = response.json()
            if x["cod"] != "404":
                y = x["main"]
                current_temperature = y["temp"]
                current_humidiy = y["humidity"]
                z = x["weather"]
                weather_description = z[0]["description"]
                respond(" Temperature in kelvin unit at " + city_name + " is " +
                      str(current_temperature) +
                      "\n humidity in percentage is " +
                      str(current_humidiy) +
                      "\n description  " +
                      str(weather_description))
                return
            else:
                respond(city_name + " weather details not found")
                return
        
        elif "something" in data:
            respond("Searching...")
            data=data.split(" ")
            data = data[3:]
            Req_data = ""
            for word in data:
                Req_data = Req_data + " " + word
            data =  "According to wikipedia " + wikipedia.summary(Req_data, sentences=4) 
            respond(data)
            return

        elif contain(data,["take a photo","capture the photo"]):
            ec.capture(0,False,"img.jpg")
            respond("photo captured successfully")
            return

        elif contain(data,["video","record the video"]):
            ec.auto_vidcapture(0,False,"video.mkv",10)
            respond("video recorded successfully")
            return

        elif "access" in data:
            access()
            return
        
        elif "where is" in data:
            data = data.split(" ")
            name = data[-1]
            url = "https://www.google.com/maps/place/"+name
            webbrowser.get('chrome').open_new(url)
            time.sleep(5)
            return

        elif "write a note" in data:
            respond("What should i write, sir!")
            data = listen()
            file = open('note.txt', 'a')
            file.write("\n"+ctime()+"\n")
            file.write(data)
            respond("noted successfully")
            return
        
        elif "execute" in data:
            execute_commands()
            return

        elif contain(data,["upcoming events","scheduled events","events"]):
            calendar_events()
            return

        elif contain(data,["game","play"]):
            try:
                tic_tac_toe()
                return
            except:
                return

        elif "create event" in data:
            create_event()
            return
            
        elif contain(data,["speed test","internet speed"]):
            try:
                respond("sure! wait a second to measure")
                st = speedtest.Speedtest()
                server_names = []
                st.get_servers(server_names)
                ping = st.results.ping
                downlink_Mbps = round(st.download() / 1000000, 2)
                uplink_Mbps = round(st.upload() / 1000000, 2)
                respond('ping {} ms'.format(ping))
                respond("The uplink is {} Mbps".format(uplink_Mbps))
                respond("The downlink is {}Mbps".format(downlink_Mbps))
                return
            except:
                respond ("I couldn't run a speedtest")     
                return              
        
        elif contain(data,["internet connection","connection"]):
            if internet_availability():
                respond("Internet Connection is okay!")
            return

        elif "wait" in data:
            respond("okay sir")
            time.sleep(10)
            return
        
        elif "screenshot" in data:
            Screenshot = pyautogui.screenshot()
            dir = "C:\\Users\VISWANADH\Pictures\Screenshots"
            length = len(os.listdir(dir))
            Screenshot_name = "Screenshot({}).png".format(length)
            path = os.path.join(dir,Screenshot_name)
            Screenshot.save(path)
            respond("Screenshot saved Successfully!")
            return

        elif "tab" in data:
            Tab_Opt(data)
            return
        
        elif "window" in data:
            Win_Opt(data)
            return
        
        elif contain(data,['battery', 'cpu', 'memory', 'brightness']):
            System_specs(data)
            return

        elif "time" in data:      
            respond(ctime())
            return

        else:
            respond("I can search the web for you,Do you want to continue?")
            opinion=listen()
            if opinion=="yes":
                url="https://www.google.com/search?q =" + '+'.join(data.split())
                webbrowser.get('chrome').open_new(url)
                time.sleep(5)
                return
            else:
                return
    except:
        respond("I don't understand, I can search the web for you,Do you want to continue?")
        opinion=listen()
        if opinion=="yes":
            url="https://www.google.com/search?q =" + '+'.join(data.split())
            webbrowser.get('chrome').open_new(url)
            time.sleep(5)
            return
        else:
            return
def pre_init():
    respond("hi sir! You are activated Jarvis, But In orded to activate all the functions of Jarvis I have to recognize you sir ")
    respond("So, A facial recognition is under process, please wait!")
def digital_assistant(data):
    try:
        if "how are you" in data: 
            respond("I am well")
            return
            
        elif "time" in data:      
            respond(ctime())
            return

        elif "who are you" in data or "what can you do" in data or "define yourself" in data:
            respond("I am viswanadh's personal assistant, I am programmed to do minor tasks like system monitoring, profiling,"
            "predict time, take a photo, predict weather,"
            " opening applications like youtube, google chrome ,gmail etcetre, show the top headline news and you can ask me computational or geographical questions too!")
            return

        elif "who made you" in data or "who created you" in data:
            respond("I was built by viswa")
            return

        elif "shutdown" in data:
            respond("Are you sure! you want to shutdown your computer")
            data = listen()
            if data == "yes":
                respond("system is going to shutdown...")
                os.system("taskkill /f /im Rainmeter.exe")
                os.system("shutdown /s /t 1")
                return
        
        elif "restart" in data:
            respond("want to restart your computer")
            data=listen()
            if data=="yes":
                os.system("shutdown /r /t 1")
                return
        
        elif "battery" in data:
            battery=psutil.sensors_battery()
            respond("Your system is at " + str(battery.percent) + " percent")
            return

        elif "cpu" in data:
            respond("CPU is at "+ str(psutil.cpu_percent()))
            return

        elif "music" in data:
            respond("Here you go with music")
            music_dir = "C:\\Users\\VISWANADH\\Music"
            song = random.choice(os.listdir(music_dir))
            os.startfile(os.path.join(music_dir,song))
            time.sleep(5)
            return

        elif "movie" in data:
            os.system("D:\\movies\\Ala_Vaikunthapurramloo.mkv")
            time.sleep(5)
            return
        
        elif "notepad" in data:
            os.system("notepad")
            return

        elif "open" in data:
            data = data.split(" ")
            query = data[1]
            for j in search(query, tld='com', lang='en', num=1, start=0, stop=1, pause=2.0):
                url=j
            webbrowser.get('chrome').open_new(url)
            respond(data[1] + " is open now")
            time.sleep(7)
            return

        elif "news" in data:
            query = "news"
            url="https://timesofindia.indiatimes.com/home/headlines"
            webbrowser.get('chrome').open_new(url)
            respond("Here are some headlines from the Times of India,Happy reading")
            time.sleep(5)
            return
                
        elif "weather" in data:
            data=data.split(" ")
	    #create key: https://home.openweathermap.org/users/sign_in
            api_key = ####################
            base_url = "https://api.openweathermap.org/data/2.5/weather?"
            if "in" not in data:
                city_name = "kurupam"
            else:
                city_name = data[-1]
            complete_url = base_url + "appid=" + api_key + "&q=" + city_name
            response = requests.get(complete_url)
            x = response.json()
            if x["cod"] != "404":
                y = x["main"]
                current_temperature = y["temp"]
                current_humidiy = y["humidity"]
                z = x["weather"]
                weather_description = z[0]["description"]
                respond(" Temperature in kelvin unit at " + city_name + " is " +
                      str(current_temperature) +
                      "\n humidity in percentage is " +
                      str(current_humidiy) +
                      "\n description  " +
                      str(weather_description))
                return
            else:
                respond(city_name + " weather details not found")
                return
        
        elif "something" in data:
            respond("Searching...")
            data=data[22:]
            data =  "According to wikipedia " + wikipedia.summary(data, sentences=4) 
            respond(data)
            return

        elif "capture the photo" in data or "take a photo" in data:
            ec.capture(0,False,"img.jpg")
            respond("photo captured successfully")
            return

        elif "video" in data or "capture the video" in data:
            ec.auto_vidcapture(0,False,"video.mkv",10)
            respond("video recorded successfully")
            return

        elif "access" in data:
            access()
            return
        
        elif "where is" in data:
            data = data.split(" ")
            name = data[-1]
            url = "https://www.google.com/maps/place/"+name
            webbrowser.get('chrome').open_new(url)
            time.sleep(5)
            return

        elif "write a note" in data:
            respond("What should i write, sir!")
            data = listen()
            file = open('note.txt', 'w')
            file.write(data)
            respond("noted successfully")
            return
        
        elif "execute" in data:
            execute_commands()
            return

        elif "upcoming events" in data or "scheduled events" in data or "events" in data:
            events = calendar_events()
            return

        elif "game" in data or "play" in data:
            try:
                tic_tac_toe()
                return
            except:
                return

        elif "create event" in data:
            create_event()
            return
            
        elif "speed test" in data:
            try:
                respond("sure! wait a second to measure")
                st = speedtest.Speedtest()
                server_names = []
                st.get_servers(server_names)
                ping = st.results.ping
                downlink_Mbps = round(st.download() / 1000000, 2)
                uplink_Mbps = round(st.upload() / 1000000, 2)
                respond('ping {} ms'.format(ping))
                respond("The uplink is {} Mbps".format(uplink_Mbps))
                respond("The downlink is {}Mbps".format(downlink_Mbps))
                return
            except:
                respond ("I couldn't run a speedtest")     
                return              
        
        elif "memory" in data:
            process_id = os.getpid()
            py = psutil.Process(process_id)
            memory_use = round(py.memory_info()[0]/2. **30, 2)
            respond("I use {} Gb of memory".format(memory_use))
            return
        
        elif "internet connection" in data or "internet" in data:
            if internet_availability():
                respond("Internet Connection is okay!")
            return
       elif 'email to' in data:
            try:
                respond("Sir, give me your message")
                print('Give message.......')
                content = takeCommand()
                to = "receiver email address"
                sendEmail(to, content)
                print('Sending mail........')
                respond("Email has been sent!")
            except Exception as e:
                print(e)
                respond("Sorry master . I am not able to send this email")
def intiate_jarvis():
    respond("checking remote servers!")
    respond("importing preferences and loading all the system drivers!")
    respond("establish secure connection!")
    os.startfile("c:\\Program files\\Rainmeter\\Rainmeter.exe")
    respond("secure connection established!")
    respond("we are online!")
    respond("welcome back sir!")
    wishme()
    respond("Jarvis is at your service")