You are browsing as a guest. Sign up (or log in) to start making projects!

1h 2m 3s logged

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.py for 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-whisper needs audio to proceed, the ollama AI chatbot needs a prompt to continue, etc…

1
16

Comments 0

No comments yet. Be the first!