1

I want windows (possibly cross-platform) solution to play simple tone of certain frequency and length on speakers. Here

Python: Making a beep noise

it is suggested to use winsound, but this solution only creates PC speaker sound. Is there any way to create sound on real speakers?

Community
  • 1
  • 1
Pygmalion
  • 785
  • 2
  • 8
  • 24

1 Answers1

2

You can use winsound to play

A single-frequency beep:

winsound.Beep(2000,500) # Hz, milliseconds

An external sound:

winsound.PlaySound('./sounds_folder/my_sound.wav', winsound.SND_FILENAME)                
Pythonic
  • 2,091
  • 3
  • 21
  • 34
  • I want pure frequency beep but not on system speakers but on normal speakers (attached to green exit on computer). – Pygmalion Apr 21 '15 at 09:54
  • I have used winsound for a similar task, to send a pure sine wave to the external speakers. Once I connect the jack, the external speakers override the system speakers. Could this be a sound card-related option? – Pythonic Apr 21 '15 at 09:58
  • In `winsound` instructions it explicitly says that Beep uses PC speaker. – Pygmalion Apr 21 '15 at 10:36
  • On certain systems the output that goes to PC speaker might divert to whatever overrides it: an external speaker, a bluetooth speaker. Where do you hear your normal Windows sounds if you connect the external speakers to the green jack? – Pythonic Apr 21 '15 at 11:06
  • I hear windows sounds on external speakers what makes things even more curious. – Pygmalion Apr 21 '15 at 12:15
  • I just tried to `winsound.beep` a sinewave out of my bluetooth speakers, and it works as expected. This might maybe have to do with your sound card, if you use one. – Pythonic Apr 21 '15 at 18:18
  • On my notebook that does not have PC speaker Beep is transferred to normal speakers. However on desktop with PC speaker Beep is always performed PC speaker and I just did not find a way to transfer signal to normal speakers. – Pygmalion Apr 22 '15 at 18:18