Skip to content

Instantly share code, notes, and snippets.

/a_loadSound.py Secret

Created May 8, 2013 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/adc2874aa09640237f6f to your computer and use it in GitHub Desktop.
Save anonymous/adc2874aa09640237f6f to your computer and use it in GitHub Desktop.
a_loadSound
import os
from urllib import urlopen
from sound import play_effect
from time import sleep
folderPath = 'Sounds'
soundPath = 'we_fight_with_honor_test'
urlPath = "http://www.flashkit.com/imagesvr_ce/flashkit/loops/Ambient/Soundscapes/We_Fight-drpengui-10065/We_Fight-drpengui-10065_hifi.mp3"
def loadSound(soundPath,folderPath='Sounds',urlPath='Null'):
if folderPath: folderPath+="/"
if not os.path.exists(folderPath[:-1]): os.mkdir(folderPath[:-1])
if not os.path.exists(folderPath+soundPath+".caf"):
url = urlopen(urlPath)
with open(folderPath+soundPath+".caf", "wb") as output:
output.write(url.read())
print folderPath+soundPath+".caf has been downloaded."
return os.getcwd()+'/'+folderPath+soundPath
playNoise = loadSound(soundPath,folderPath,urlPath)
while True:
print "replaying"
play_effect(playNoise)
sleep(18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment