-
-
Save anonymous/adc2874aa09640237f6f to your computer and use it in GitHub Desktop.
a_loadSound
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 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