summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAbdellah El Morabit <nsrddyn@gmail.com>2024-11-07 17:00:19 +0100
committerAbdellah El Morabit <nsrddyn@gmail.com>2024-11-07 17:00:19 +0100
commit32ec9336088799c42d8aa7ace6648802e1b267cf (patch)
treebc6d718631a2f2a210b4cde462a5f7f97bd6b613 /bin
parentfa7007d00c04fc73f668e2b7f339c3f60a64d055 (diff)
did alot of designing and testing out on a linux machine
Diffstat (limited to 'bin')
-rw-r--r--bin/icon.pngbin0 -> 3754 bytes
-rw-r--r--bin/kasper_gui.py10
-rw-r--r--bin/kasper_source.py (renamed from bin/script.py)70
3 files changed, 72 insertions, 8 deletions
diff --git a/bin/icon.png b/bin/icon.png
new file mode 100644
index 0000000..c372c49
--- /dev/null
+++ b/bin/icon.png
Binary files differ
diff --git a/bin/kasper_gui.py b/bin/kasper_gui.py
new file mode 100644
index 0000000..2826638
--- /dev/null
+++ b/bin/kasper_gui.py
@@ -0,0 +1,10 @@
1import tkinter
2from tkinter import PhotoImage
3
4display = tkinter.Tk()
5display.title("Kasper")
6photo = PhotoImage(file = "icon.png")
7display.iconphoto(False, photo)
8
9
10display.mainloop() \ No newline at end of file
diff --git a/bin/script.py b/bin/kasper_source.py
index 5c33638..d8b0599 100644
--- a/bin/script.py
+++ b/bin/kasper_source.py
@@ -1,5 +1,7 @@
1from smbus2 import SMBus 1from smbus2 import SMBus
2from time import sleep 2from time import sleep
3from gpiozero import CPUTemperature
4from rpi_lcd import LCD
3 5
4import speech_recognition as sr 6import speech_recognition as sr
5import sounddevice 7import sounddevice
@@ -78,32 +80,84 @@ class LCD(object):
78 def clear(self): 80 def clear(self):
79 self.write(CLEAR_DISPLAY) 81 self.write(CLEAR_DISPLAY)
80 82
81 83LCD_DISPLAY = LCD()
82
83LCD = LCD()
84VOICE_REC = sr.Recognizer() 84VOICE_REC = sr.Recognizer()
85MIC = sr.Microphone() 85MIC = sr.Microphone()
86PROCES_LOAD = os.getloadavg() 86PROCES_LOAD = os.getloadavg()
87TIME = current_time.time() 87TIME = current_time.time()
88UPTIME = time.CLOCK_UPTIME() 88UPTIME = time.CLOCK_UPTIME()
89CPU_TEMP = CPUTemperature()
90
91# clearing the lcd from any text that was on it before the program started to ensure smooth operations
92lcd.clear()
89 93
94# Listening to the user's voice and putting it into a variable
95def listen_voice():
96 global audio
97 with mic as source:
98 r.adjust_for_ambient_noise(source)
99 audio = r.listen(source)
100 return audio
90 101
102# Transcribing the audio to text and printing it out
103# Using the Google Speech Recognizer
104def recognize_speech(audio):
105 try:
106 words = r.recognize_google(audio)
107 LCD_DISPLAY.text(words, 1)
108 print(f"Printing on screen: {words}")
109 except sr.UnknownValueError:
110 LCD_DISPLAY.text(ERROR_BAD_REQUEST, 1)
111 print(ERROR_BAD_REQUEST)
112 except sr.RequestError:
113 LCD_DISPLAY.text(ERROR_UNAUTHORIZED, 1)
114 print(ERROR_UNAUTHORIZED)
91 115
92def CPU_INFO(): 116def CPU_INFO():
117 print("you chose to display the cpou")
93 while (True): 118 while (True):
94 LCD.text(PROCES_LOAD(),1,left) 119 LCD.text(PROCES_LOAD(),1,left)
95 120
96def CURRENT_TIME(): 121def CURRENT_TIME():
97 while True: 122 while True:
98 backlight_mode = true 123 backlight_mode = True
99 LCD.text(UPTIME,1,left)
100 LCD.text(TIME,2,center) 124 LCD.text(TIME,2,center)
101
102 125
126def UPTIME():
127 while True:
128 LCD.text(UPTIME,1,left)
129
130def CPU_TEMP():
131 while True:
132 LCD.text(cpu.temperature)
133
134def CPU_LOAD():
135 backlight_mode = True
136 LCD.text(PROCES_LOAD,1,left)
103 137
138def NOTES():
139 count = 0
140 user_notes = input()
141 for i in user_notes:
142 while count < 20:
143 lcd.text(i,1,left)
144 count += 1
104 145
105OPTIONS = ["CPU_CLOCK", "TIME", "UPTIME", "CPU_TEMP", "CPU LOAD", "NOTES"] 146
147OPTIONS = ["CPU_CLOCK", "TIME", "UPTIME", "CPU_TEMP", "CPU_LOAD", "NOTES", "SPEECH_TRANSCRIBER"]
106 148
107def USER_GUI(): 149def PROGRAM(USER_INPUT):
108 print("WELCOME TO THE I2C COMMAND LINE CENTER \n WHAT DO YOU WISH TO DO? ") 150 print("WELCOME TO THE I2C COMMAND LINE CENTER \n WHAT DO YOU WISH TO DO? ")
109 print(OPTIONS) 151 print(OPTIONS)
152
153 FOUND = False
154 while FOUND == False:
155
156 USER_INPUT = input().upper()
157 for i in OPTIONS:
158 if i == USER_INPUT:
159 FOUND = True
160 else:
161 print(ERROR_NOT_FOUND)
162
163PROGRAM() \ No newline at end of file