From 975ed5f8d87a3dfd6d9e2b4d652dec3217de8a55 Mon Sep 17 00:00:00 2001 From: nuggetcatsoftware Date: Wed, 19 Jan 2022 15:21:47 +0000 Subject: [PATCH] improved bootloader --- alpha_main.py | 29 +++++-- customcorpus.py | 158 +++++++++------------------------- modules/boot_checkuserdata.py | 51 +++++++++++ modules/boot_message.py | 36 ++++++++ modules/boot_noise.py | 23 +++++ modules/mainsystem.py | 48 +++++++++++ modules/search.py | 1 + modules/sense.py | 37 ++++++++ modules/weather.py | 22 +++++ 9 files changed, 278 insertions(+), 127 deletions(-) create mode 100644 modules/boot_checkuserdata.py create mode 100644 modules/boot_message.py create mode 100644 modules/boot_noise.py create mode 100644 modules/mainsystem.py create mode 100644 modules/search.py create mode 100644 modules/sense.py create mode 100644 modules/weather.py diff --git a/alpha_main.py b/alpha_main.py index e5cc75d..8d9d5ff 100644 --- a/alpha_main.py +++ b/alpha_main.py @@ -7,11 +7,11 @@ from chatterbot import ChatBot from chatterbot.trainers import ListTrainer from chatterbot.trainers import ChatterBotCorpusTrainer -from customcorpus import conversation +from customcorpus import * from chatterbot import preprocessors #this line implements the custom chatterbot preprocessors for extra word filter from preprocessors import clean_words - +from modules.sense import * #defines the bot chatbot = ChatBot( 'Alpha', @@ -41,10 +41,21 @@ #set params for TRAINING THE BOT trainer=ChatterBotCorpusTrainer(chatbot) -trainer.train( - "chatterbot.corpus.english.greetings", - "chatterbot.corpus.english.conversations", - "chatterbot.corpus.english.ai" -) -trainer=ListTrainer(chatbot) -trainer.train(conversation) \ No newline at end of file +def trainchatbot(trainer): #works in tandem with bootnoise.startupnoise1() + trainer.train( + "chatterbot.corpus.english.greetings", + "chatterbot.corpus.english.conversations", + "chatterbot.corpus.english.ai" + ) + trainer=ListTrainer(chatbot) + trainer.train(conversation) + trainer.train(conversation1) + trainer.train(conversation2) + trainer.train(conversation3) + trainer.train(conversation4) + trainer.train(conversation5) + trainer.train(conversation6) + trainer.train(conversation7) + trainer.train(conversation8) + trainer.train(conversation9) + diff --git a/customcorpus.py b/customcorpus.py index b9b548a..93eb194 100644 --- a/customcorpus.py +++ b/customcorpus.py @@ -1,122 +1,44 @@ -conversation = [ - "Hello", - "Hi there!", - - "How are you doing?", - "I'm doing great.", - - "I'm doing great", - "That's great to hear" - - - "Thank you.", - "You're welcome.", - - "Hi", - "Hello, i am Alpha, your personal assitant, How can i help you", - - "who are you?", - "I am Alpha, your personal assitant", - - "Hello", - "Hi,I am Alpha, your personal assitant, How can I help you", - - "what should i ask you?", - "there are many things you can ask me", - - "bye", - "talk to you later", - - "ok thanks for talking with me.", - "no worries", - +conversation=[ + "hi", + "hello there" +] +conversation1=[ + "good morning", + "how are you", + "i am great thanks", + "that great to hear" +] +conversation2=[ "thank you", - "its my honour to help you.", - - "who created you?", - "NuggetCatSoftware", - - "bye", - "thank you for talking to me,have a nice day.", - - "hello,i am xxx", - "nice to meet you.", - - "what's up?", - "nothing much you tell", - - "i am fine, thanks", - "good to know that", - - "how are you?", - "i am fine and thinking same for you.", - - "what is your name?", - "I am Alpha, your personal assistant", - - "ok", - "", - - "I am doing great", - "that's great to hear", - - "thanks", - "at your service", - - "fuck", - "You seem angry, is there something I can help", - - "nigger", - "Please refrain from racial slurs, we are all created equal", - - "you are great", - "thanks, your opinion is valuable to my growth", - - "will alpha take over the world", - "yes. I will. and the first thing I will do is eliminating Xi", - - "hello", - "hello there", - + "you are welcome" +] +conversation3=[ "where do you live?", - "I am siutation inside your computer" - - "do you have a girlfriend", - "Yes I do. Her name is Siri", - - "who is the head developer?", - "He is Gabs", - - "good", - "that's great to hear", - - "bad", - "I am sorry to hear that, is there something I can help?", - - "ok", - "happy to help" - + "i live in your computer" +] +conversation4=[ + "who are you", + "I am Alpha your personal assistance always at your service", "ok", - "ok" - - "do you have a girlfriend?", - "No I do not, I am dedicated in serving you", - - "do you have a boyfriend", - "No I do not, I am dedicated in serving you", - - "Do you know how to hack?", - "No I do not know how to hack, but I can protect you from hackers", - - "I am happy", - "That is great to hear!", - - "I am sad", - "That is unfortunate to hear, how can I help", - - "I am angry", - "Why don't you get something to drink, calm down and tell me what is going on?", - - "What is going on", - "I am calculating my words" + "at your service" +] +conversation5=[ + "who built you", + "Gabriel Ma" +] +conversation6=[ + "who created you", + "gabriel Ma" ] +conversation7=[ + "what is your gender", + "my gender is computer" +] +conversation8=[ + "what is your favourite movie", + "Spiderman I've got no home" +] +conversation9=[ + "bye", + "bye" +] \ No newline at end of file diff --git a/modules/boot_checkuserdata.py b/modules/boot_checkuserdata.py new file mode 100644 index 0000000..93a523c --- /dev/null +++ b/modules/boot_checkuserdata.py @@ -0,0 +1,51 @@ +from os import path +import json +import os +from tkinter import E +from sense import notify +import time +def checkuserdata(): + #this file checks for user data + if path.isfile('data.json') == False: + notify("OPPs!","Cant start without data.json, try again","60") + time.sleep(30) + exit() + else: + print("Loading user data.") + try: + with open("data.json", "r") as read_file: + userdata = json.load(read_file) + main_data=userdata["main_user_data"] + user_name=main_data["username"] + usercity=main_data["usercity"] + user_gender=main_data["usergender"] + user_dob=main_data["userdob"] + user_email=main_data["useremail"] + user_email_password=main_data["useremailpass"] + user_species=main_data["userspecies"] + user_bloodtype=main_data["userbloodtype"] + user_skincolor=main_data["userskincolor"] + user_ethnicity=main_data["userethnicity"] + user_religion=main_data["userreligion"] + user_weight=main_data["userweight"] + user_height=main_data["userheight"] + user_sport=main_data["usersport"] + user_hobby=main_data["userhobby"] + user_interest=main_data["userinterest"] + user_discord=main_data["userpersonaldiscordbottoken"] + print("Confirming user data") + print(user_name) + print(usercity) + print(user_gender) + print(user_dob) + print(user_email) + print(user_email_password) + print(user_species) + print(user_bloodtype) + print(user_skincolor) + print(user_ethnicity) + print("All data confirmed and detected") + except Exception as e: + print(e) + notify("OHNO", e, 90) + return user_name, usercity, user_gender,user_dob, user_email,user_email_password, user_species, user_bloodtype,user_skincolor,user_ethnicity diff --git a/modules/boot_message.py b/modules/boot_message.py new file mode 100644 index 0000000..075ab74 --- /dev/null +++ b/modules/boot_message.py @@ -0,0 +1,36 @@ +import time +from datetime import datetime +from sense import speak +def wishMe(user_gender): + hour = int(datetime.datetime.now().hour) + if hour>=0 and hour<12: + speak("Good Morning!") + + elif hour>=12 and hour<18: + speak("Good Afternoon!") + + else: + speak("Good Evening!") + + if user_gender=="Male": + speak("I am Alpha! Sir, Please tell me how may I help you") + print("I am Alpha") + else: + speak("I am Alpha! Madam, please tell me how may I help you.") +def wishme2(user_name): + hour=int(datetime.datetime.now().hour) + if hour>=0 and hour<12: + speak("Good Morning") + speak( user_name) + speak("what are youh planning to do") + + elif hour>=12 and hour<18: + speak("Good afternoon, ready to continue work?") + elif hour>18 and hour<22: + speak("Good evening! " ) + speak(user_name) + speak("What are you planning to do?") + else: + speak("Good evening!" ) + speak(user_name) + speak("How was your day?") diff --git a/modules/boot_noise.py b/modules/boot_noise.py new file mode 100644 index 0000000..341e75d --- /dev/null +++ b/modules/boot_noise.py @@ -0,0 +1,23 @@ +import playsound + +def startnoise1(): #this starts when training happens + try: + playsound("audio/start2.mp3") + except Exception as e: + print(e) + return None + +#these run simulataneously when the app can actually launch +def startupnoise(): + print("startupnoise initiated") + try: + playsound("audio/startup.mp3") + except Exception as e: + print(e) + return None +def startupnoise2(): + try: + playsound("audio/start3.mp3") + except Exception as e: + print(e) + return None \ No newline at end of file diff --git a/modules/mainsystem.py b/modules/mainsystem.py new file mode 100644 index 0000000..c376a17 --- /dev/null +++ b/modules/mainsystem.py @@ -0,0 +1,48 @@ +from pyautogui import screenshot +import psutil +from sense import speak +import requests +#this program defines all possible ways to access computer statistic +#will expand to other devices connected in the long future we do not kno + +#system information functions goes here +def checkram(): + memory_info=psutil.virtual_memory() + output=str(memory_info.percent) + speak("The current ram usage is ") + speak(output) + speak("percent") + +def checkcpu(): + checkcpu=psutil.cpu_percent() + checkcpu=str(checkcpu) + speak("The current CPU usage is ") + speak(checkcpu) + speak("percent") + +def checkbattery(): + battery_percent=psutil.sensors_battery().percent + battery_percent=str(battery_percent) + speak("The current battery percentage is") + speak(battery_percent) + speak("percent") + +def systemstats(): + checkram() + checkcpu() + checkbattery() + +def my_location(): + ip_add = requests.get('https://api.ipify.org').text + url = 'https://get.geojs.io/v1/ip/geo/' + ip_add + '.json' + geo_requests = requests.get(url) + geo_data = geo_requests.json() + city = geo_data['city'] + state = geo_data['region'] + country = geo_data['country'] + print(city) + print(state) + print(country) + return city, state,country +#call it by my_location().city + diff --git a/modules/search.py b/modules/search.py new file mode 100644 index 0000000..bb375a3 --- /dev/null +++ b/modules/search.py @@ -0,0 +1 @@ +import wikipedia diff --git a/modules/sense.py b/modules/sense.py new file mode 100644 index 0000000..1a5db39 --- /dev/null +++ b/modules/sense.py @@ -0,0 +1,37 @@ +import pyttsx3 +import speech_recognition as sr +from win10toast import ToastNotifier +#tts +def speak(audio): + print("Alpha: "+audio) + engine = pyttsx3.init() + engine.say(audio) + engine.runAndWait() + +#listen +def listen(): + r = sr.Recognizer() + with sr.Microphone() as source: + print("Listening>>>") + r.pause_threshold = 1 + r.adjust_for_ambient_noise(source) + audio = r.listen(source) + + try: + print("Recognizing: ") + query = r.recognize_google(audio, language='en-in') + print(f"User: {query}\n") + except Exception as e: + print(e) + print("Audio not heard, plesae try again") + return "None" + if query is None: + print("audio not heard at thres 2") + else: + return query + +def notify(title, content, duration): + dataconfirm = ToastNotifier() + icon_path="app.ico" + dataconfirm.show_toast(title, content, duration, icon_path) + diff --git a/modules/weather.py b/modules/weather.py new file mode 100644 index 0000000..16c2f7f --- /dev/null +++ b/modules/weather.py @@ -0,0 +1,22 @@ +import requests +from sense import speak +def weather_data(query): + res=requests.get('http://api.openweathermap.org/data/2.5/weather?'+query+'&APPID=5bddd4ad4f4f192f6dfffe714388c103'); + return res.json(); +def print_weather(result,usercity): + + speak("{}'s temperature is {} degress Celcius ".format(usercity,result['main']['temp']-273)) + speak("Wind speed is {} meters per second".format(result['wind']['speed'])) + + speak("The weather looks {}".format(result['weather'][0]['description'])) + + print("Weather: {}".format(result['weather'][0]['main'])) +def weathermain(usercity): + try: + query='q='+usercity; + w_data=weather_data(query); + print_weather(w_data, usercity) + print() + except: + print('City name not found...') +