diff options
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/icon.png | bin | 0 -> 3754 bytes | |||
| -rw-r--r-- | bin/kasper_gui.py | 10 | ||||
| -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 @@ | |||
| 1 | import tkinter | ||
| 2 | from tkinter import PhotoImage | ||
| 3 | |||
| 4 | display = tkinter.Tk() | ||
| 5 | display.title("Kasper") | ||
| 6 | photo = PhotoImage(file = "icon.png") | ||
| 7 | display.iconphoto(False, photo) | ||
| 8 | |||
| 9 | |||
| 10 | display.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 @@ | |||
| 1 | from smbus2 import SMBus | 1 | from smbus2 import SMBus |
| 2 | from time import sleep | 2 | from time import sleep |
| 3 | from gpiozero import CPUTemperature | ||
| 4 | from rpi_lcd import LCD | ||
| 3 | 5 | ||
| 4 | import speech_recognition as sr | 6 | import speech_recognition as sr |
| 5 | import sounddevice | 7 | import 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 | 83 | LCD_DISPLAY = LCD() | |
| 82 | |||
| 83 | LCD = LCD() | ||
| 84 | VOICE_REC = sr.Recognizer() | 84 | VOICE_REC = sr.Recognizer() |
| 85 | MIC = sr.Microphone() | 85 | MIC = sr.Microphone() |
| 86 | PROCES_LOAD = os.getloadavg() | 86 | PROCES_LOAD = os.getloadavg() |
| 87 | TIME = current_time.time() | 87 | TIME = current_time.time() |
| 88 | UPTIME = time.CLOCK_UPTIME() | 88 | UPTIME = time.CLOCK_UPTIME() |
| 89 | CPU_TEMP = CPUTemperature() | ||
| 90 | |||
| 91 | # clearing the lcd from any text that was on it before the program started to ensure smooth operations | ||
| 92 | lcd.clear() | ||
| 89 | 93 | ||
| 94 | # Listening to the user's voice and putting it into a variable | ||
| 95 | def 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 | ||
| 104 | def 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 | ||
| 92 | def CPU_INFO(): | 116 | def 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 | ||
| 96 | def CURRENT_TIME(): | 121 | def 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 | ||
| 126 | def UPTIME(): | ||
| 127 | while True: | ||
| 128 | LCD.text(UPTIME,1,left) | ||
| 129 | |||
| 130 | def CPU_TEMP(): | ||
| 131 | while True: | ||
| 132 | LCD.text(cpu.temperature) | ||
| 133 | |||
| 134 | def CPU_LOAD(): | ||
| 135 | backlight_mode = True | ||
| 136 | LCD.text(PROCES_LOAD,1,left) | ||
| 103 | 137 | ||
| 138 | def 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 | ||
| 105 | OPTIONS = ["CPU_CLOCK", "TIME", "UPTIME", "CPU_TEMP", "CPU LOAD", "NOTES"] | 146 | |
| 147 | OPTIONS = ["CPU_CLOCK", "TIME", "UPTIME", "CPU_TEMP", "CPU_LOAD", "NOTES", "SPEECH_TRANSCRIBER"] | ||
| 106 | 148 | ||
| 107 | def USER_GUI(): | 149 | def 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 | |||
| 163 | PROGRAM() \ No newline at end of file | ||
