0

I have an issue where the winsound.Beep function has an extremely high latency on my Windows 10 laptop speakers. It is so bad that the terminal would have completed execution of my code and then the beep sound would continue in the background(an audio buffer type effect). If I plug in USB headphones the sound functions properly i.e. one beep every second as specified in my code. I am using VS code as an editor.

I've:

  • Checked that latest audio drivers installed
  • Searched Python bug tracker list
  • Tested on VS 2019 and VS Code(same result)

Code:

for j in range(duration,0,-1):
        winsound.Beep(1000,250)
        print(str(j) + ' secs')
        time.sleep(0.75)

I read winsound in python - low latency on monitor, high latency on laptop why?, but that wasn't answered.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
LesleyH84
  • 1
  • 1
  • Welcome to SO! Does your problem also happen when you write a script without the `for` loop, no `print`, no `sleep`? If so, you can remove that from the code also, as it's not relevant to the problem :-) On my HP Elitebook, I can execute `winsound.Beep(1000,250)` without any delay, both on speakers and headphones. Python version `3.8.12`, Windows 10. – André Jul 28 '22 at 13:45
  • Thank you for the response, appreciate. Yes I stripped down the code to just winsound.Beep(1000,250)... the sound is still very delayed(terminal finished executing the .py code and ready for next command line and then only beeps)... as mentioned in question runs without any delay through external sound(i.e. earphones).Python 3.10.5... maybe I will try your older version of Python? – LesleyH84 Jul 29 '22 at 06:04

0 Answers0