from playsound import playsound
from pynput import mouse
def on_click(x, y, button, pressed):
if pressed:
print("clicked")
playsound("clicking.wav")
if not pressed:
# Stop listener
print("unclicked")
return False
while True:
with mouse.Listener(on_click=on_click,) as listener:
listener.join()
Point of this program is to simulate the sound of clicking really fast. However when I run the sound file of fast clicking (clicking.wav) my mouse becomes very laggy and the program doesn't listen for when I'm not holding down right click, it keeps playing the sound file regardless. I am very unsure of how to fix this.