Skip to content

Instantly share code, notes, and snippets.

/a_loadSound.py Secret

Created May 8, 2013
Embed
What would you like to do?
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