Created
October 25, 2011 19:26
-
-
Save karolk/1313939 to your computer and use it in GitHub Desktop.
play a little tune based on any number (Windows)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
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
import beep_number beep_number('9876')
Soon you will be whistling your PIN number:)