Threading implementation for better speed
- Today I decided to learn about the python module
threading, and realized it wasn’t that difficult to implement in my project. - The issue was: when I ran
oled("thinking_animation.gif")it ran sequentially, so the whole script had to wait for the animation to finish, which obviously can’t happen. - So I created different threads for each animation/png, and made a “switch”, better known as a
threading.Event()which enabled me to manage the “workers” way better (sorry, i’m getting used to the vocabulary) - Also I added comments everywhere in
main.pyfor better explainability. - Finally I adjusted the code in OLED.py with the switch implemented and added some small user-friendly checks throughout my project.
- Hopefully everything works!
Note: sadly it will be difficult to use threads in the rest of the code, since the process is, at its core, sequential.
Faster-whisperneeds audio to proceed, the ollama AI chatbot needs a prompt to continue, etc…
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.