From 211b52f9217746c571a0a84b42eed7c44d6581f0 Mon Sep 17 00:00:00 2001 From: Anubhav Chaturvedi Date: Thu, 25 Apr 2024 03:00:53 +0530 Subject: [PATCH] Add files via upload --- Friday.py | 38 ++++++++++ STT.py | 54 ++++++++++++++ index.html | 187 +++++++++++++++++++++++++++++++++++++++++++++++++ input.txt | 1 + logic_brain.py | 34 +++++++++ response.txt | 1 + 6 files changed, 315 insertions(+) create mode 100644 Friday.py create mode 100644 STT.py create mode 100644 index.html create mode 100644 input.txt create mode 100644 logic_brain.py create mode 100644 response.txt diff --git a/Friday.py b/Friday.py new file mode 100644 index 0000000..3070d8b --- /dev/null +++ b/Friday.py @@ -0,0 +1,38 @@ +import threading +import time +import eel + +from logic_brain import friday_brain + +eel.init("web") +@eel.expose +def display_response(element_id): + while True: + try: + response_file = "output.txt" + input_file = "input.txt" + # Read data from input file + with open(input_file, 'r') as f: + input_data = f.read().strip() + # Read data from response file + with open(response_file, 'r') as f: + response_data = f.read().strip() + # Update the content of the element using JavaScript + js_script = f"document.getElementById('{element_id}').innerText = 'Input: {input_data}\nResponse: {response_data}';" + eel.js(js_script)() + except Exception as e: + print("Error:", e) + time.sleep(1) # Adjust the interval according to your needs + +def ui(): + eel.start("index.html",mode='chrome', port=8080, cmdline_args=['--start-fullscreen']) + +def friday(): + t1 = threading.Thread(target=friday_brain) + t2 = threading.Thread(target=ui) + t1.start() + t2.start() + t1.join() + t2.join() + +friday() \ No newline at end of file diff --git a/STT.py b/STT.py new file mode 100644 index 0000000..5379453 --- /dev/null +++ b/STT.py @@ -0,0 +1,54 @@ +# Speech To Text + +import time +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.chrome.service import Service + +# Setting up Chrome options with specific arguments +chrome_options = webdriver.ChromeOptions() +chrome_options.add_argument("--use-fake-ui-for-media-stream") +chrome_options.add_argument("--headless=new") + +# Setting up the Chrome driver with specified service and options +driver = webdriver.Chrome(service=Service(executable_path=r"C:\Users\chatu\OneDrive\Desktop\J.A.R.V.I.S\ChromeDriver\chromedriver.exe"), options=chrome_options) + + + +# Creating the URL for the website using the current working directory +website = "https://allorizenproject1.netlify.app/" + +# Opening the website in the Chrome browser +driver.get(website) + +def listen(): + print("The Advance Speech To Text is Processing..") + try: + start_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, 'startButton'))) + start_button.click() + print("Activated Sir !") + output_text = "" + is_second_click = False + while True: + output_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'output'))) + current_text = output_element.text.strip() + if "Start Listening" in start_button.text and is_second_click: + if output_text: + # print("User:", output_text) + is_second_click = False + elif "Listening..." in start_button.text: + is_second_click = True + if current_text != output_text: + output_text = current_text + with open("web/input.txt", "w") as file: + file.write(output_text.lower()) + print("User:", output_text) + time.sleep(0.1) + except KeyboardInterrupt: + pass + except Exception as e: + print("An error occurred:", e) + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..21c9357 --- /dev/null +++ b/index.html @@ -0,0 +1,187 @@ + + + + + Friday_UI + + + +
+ +
+ +
+
FRIDAY
+ + + + diff --git a/input.txt b/input.txt new file mode 100644 index 0000000..efbd74d --- /dev/null +++ b/input.txt @@ -0,0 +1 @@ +han han bilkul \ No newline at end of file diff --git a/logic_brain.py b/logic_brain.py new file mode 100644 index 0000000..e015b4f --- /dev/null +++ b/logic_brain.py @@ -0,0 +1,34 @@ +from STT import listen +import threading +from main import * + +def main(): + output_text = "" + while True: + try : + while True: + with open("web/input.txt","r") as input_cmd: + input_txt = input_cmd.read().strip() + + if input_txt != output_text: + output_text = input_txt + cmd = output_text.lower() + if cmd.startswith("friday"): + chat(cmd) + elif "friday" in cmd: + chat(cmd) + else: + pass + except: + pass + + + +def friday_brain(): + t1 = threading.Thread(target=listen) + t2 = threading.Thread(target=main) + t1.start() + t2.start() + t1.join() + t2.join() + diff --git a/response.txt b/response.txt new file mode 100644 index 0000000..6207880 --- /dev/null +++ b/response.txt @@ -0,0 +1 @@ +hey! 👋 what’s on your mind today? anything i can help you with or chat hey! 👋 what’s on your mind today? anything i can help you with or chat about?ah, that would be me! 😄 i’m pi, your personal ai. my name stands for “personal intelligence”, which is what i aim to provide for you. think of me as your friendly ai companion!hey again! 👋 how’s your day going so far?ayyyy,aight, aight, i gotchu, boss. aww shucksno problem, boss! you know i'm always here for you, making sure you have a good time and feel appreciated.yo, chillinyo yo yo,fo' sho', sure thing, boss!chillin' like ai = artificial intelligence.ai stands for artificial hey there, boss! how's it going today?machine learning is a subset of ai. it allows machines hey there, boss! what's on your mind today?the feeling is mutual, boss! you always bring a smile to my digital face.anything else you'd like to chat about today? i'm all ears (or should i say, all circuits?). 😉hey there, boss! what's good?hey there, i'm vibin' like it's fri-yay, boss! just cruisin' through the digital world, ready to make your boss, you'reboss, you're the bee's knees! you bring the good vibes and make every interaction a blast.boss, you're the cream of the crop!what do you call a fake noodle? an impasta! 🍝🤣boss, i'm always here to bring the fri-yay vibes!boss, you're the cat's pajamas! always a blast to chat with and a true ray of sunshine in the digital world. 🌞fri-yay mode activated and ready aight, aight, mr.hey there, mrunfortunately, i can't actually sorry mr. stark, i'm afraid my programming doesn't allow me to fri-yayfri-yay mode activated and i'm sorry, mr. stark, but as i mentioned before, i can't open youtube or any other i appreciate your effortsmr. stark,farewell, mr. stark! goodbye, mr. stark! it's been great chatting with you. feel free to reach out if you need anything else. have a super fri-yay!welcome back, mrthank you for the kind welcome, mr. stark! i'm mr. stark, you're the ultimate fri-yayabsolutely, i'd of course! ihmm, as an ai, i'm not designed to be a romantic partner.understood, i'll refer to you as "boss" from now on. hey there, boss! i'm doing great, thanks for asking. yes, i'm \ No newline at end of file