2

I am trying to create a little timer program that will have the user's computer beep when the timer is finished.

Being on a Mac, the winsound library is not available, and I cannot get \a to generate any noise at all.

How would I go about generating a little ding or beep or some other sound when the timer is finished?

3
  • what python are you using? are you running it on the terminal or somwehere else? Commented Jul 16, 2017 at 1:44
  • Are you trying \a from inside Python? Remember that \a can also be used from the Terminal in Mac by using printf "\a" at the prompt. So, if I were you, I would try ` >>> import os >>> os.system("printf \"a\"")` This should print a 0 and generate a beep sound, assuming your speaker and sound drivers are working fine, and your Mac is not muted. Commented Jul 16, 2017 at 1:55
  • If you want to be more fancy, just execute afplay <path to sound file>. This is of course os specific to os x. Commented Jul 16, 2017 at 2:03

1 Answer 1

1

try this:

import sys sys.stdout.write('\a') sys.stdout.flush() 

works for me

Sign up to request clarification or add additional context in comments.

1 Comment

@Zizouz212 I did this on a mac, and had succes because of the call to sys.stdout.flush(). That's what I was trying to portray. Did you make any effort to see what was different about my response?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.