Skip to content

Instantly share code, notes, and snippets.

@karolk
Created October 25, 2011 19:26
Show Gist options
  • Save karolk/1313939 to your computer and use it in GitHub Desktop.
Save karolk/1313939 to your computer and use it in GitHub Desktop.
play a little tune based on any number (Windows)
import time
import winsound #only works on windows, any similar APIs on Mac/Linux?
def beep_number(number, length=200):
#sounds frequencies in hertz, starting from middle C and going up to high E
sounds = [261, 294, 330, 350, 392, 440, 494, 523, 587, 659]
i=0
while i<len(number):
winsound.Beep(sounds[int(number[i])],length)
time.sleep(length/500)
i = i+1
beep_number('00798659683540065')
@karolk
Copy link
Author

karolk commented Oct 25, 2011

import beep_number beep_number('007986596835400', 400)
Second parameter controls speed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment