def getMels(audioPath, id, category): print("Generating mels for " + audioPath) featuresArray = [] for i in range(0, SOUND_SAMPLE_LENGTH, HAMMING_STRIDE): if i + HAMMING_SIZE <= SOUND_SAMPLE_LENGTH - 1: y, sr = librosa.load(audioPath, offset=i / 1000.0, duration=HAMMING_SIZE / 1000.0) # Let's make and display a mel-scaled power (energy-squared) spectrogram S = librosa.feature.melspectrogram(y, sr=sr, n_mels=128) # Convert to log scale (dB). We'll use the peak power as reference. log_S = librosa.logamplitude(S, ref_power=np.max) mfcc = librosa.feature.mfcc(S=log_S, sr=sr, n_mfcc=13) # featuresArray.append(mfcc) featuresArray.append(S) if len(featuresArray) == 599: break localPath = "mels/{0}/{1}.pp".format(category, id) ppFilePath = utils.resolvePath(utils.getPath(), localPath) f = open(ppFilePath, 'wb') f.write(pickle.dumps(featuresArray)) f.close()
def fixPath(path, project_path, cwd_path, change): '''Will make sure the path is properly formatted''' newpath = path.replace('\\', '/') # Make sure the blend file path is absolute for further processing if newpath.startswith('//') and project_path: # Convert the project (starts with '//') paths - they could # contain parent dir usage, so need to ensure it's ok newpath = utils.resolvePath(os.path.join(project_path, newpath[2:])) elif not utils.isPathAbsolute(newpath) and cwd_path: # Looks like relative path to the cwd - so making it newpath = utils.resolvePath(os.path.join(cwd_path, newpath)) # Now the path is absolute and we can modify it to the actual path if newpath.startswith(project_path): newpath = '//' + newpath.replace(project_path, '', 1).lstrip('/') elif change: newpath = '//../ext_deps/' + newpath.replace(':', '_').lstrip('/') return newpath
def convert(id, category, ext): localPath = "data/{0}/{1}".format(category, id) fullPath = utils.resolvePath(utils.getPath(), localPath) subprocess.call([ "ffmpeg", "-i", fullPath + ".ogg", fullPath + ".wav", "-loglevel", "panic" ]) #subprocess.call(["rm","-rf",fullPath+".ogg"]) #print("Converted {0}".format(id)) return fullPath + ".wav"
def __init__(self, parent): img = utils.resolvePath('images/RPG-icon.png') logo = Pixbuf.new_from_file_at_size(img, width=128, height=128) super(About, self).__init__( parent=parent, artists=['Teekatas Suwannakrua'], authors=['Loïc Penaud', 'Erwan Bourhis'], comments="A RPG Lottery", copyright="Loïc Penaud", documenters=['Loïc Penaud'], license_type=Gtk.License.GPL_3_0_ONLY, logo=logo, program_name="Lottery", version='1.2', website='https://github.com/lpenaud/rpg-dark-fantasy', website_label='Github')
def downloadFile(id, category, url): localPath = "data/{0}/{1}.ogg".format(category, id) fullPath = utils.resolvePath(utils.getPath(), localPath) subprocess.call(["wget", url, "-O", fullPath, "--quiet"])
def __init__(self, lottery, **args): MyWindow.__init__(self, utils.resolvePath('glade/Lottery.glade')) img = Pixbuf.new_from_file_at_size(utils.resolvePath('images/RPG-icon.png'), width=128, height=128) self.getWindow().set_icon(img) self.getWindow().set_title("Loterie") self.lottery = lottery self.interval = 0.1 self.times = 50 self.handlerItemIdItem = 0 self.handlerItemIdRand = self.addEvent('button-launch', 'clicked', self.randomise) self.catImg = { "parchment":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Document.png"), "book":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Ebook.png"), "stick":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Stick.png"), "sword":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/sword.png"), "axe":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Axe.png"), "att":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/SwordAxe.png"), "shoe":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Pegasus-Boot.png"), "helmet":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Music-4.png"), "shield":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Shield-Security.png"), "armor":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Armor.png"), "unknown":utils.resolvePath("images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Storage.png") } self.changeImage("image-give-me-your-money", utils.resolvePath('images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Gold.png'), width=96, height=96) self.changeTextLabel("label-name-lottery", "Le loto de Ginette") self.changeImage('image-arrow', utils.resolvePath('images/Legendora-Icon-Set-by-Raindropmemory/Legendora-Icon-Set/Icon/Download.png'), width=96, height=96) self.threadJobRandom = ThreadJob(self.displayRandom, 0.01, 1) self.threadJobRandom.start() load(self.getWindow())
#!/usr/bin/env python3 # coding: utf-8 import os import sys sys.path.insert(0, os.path.abspath(os.curdir) + '/utils') from Lottery import Lottery from Window import LotteryWindow from utils import load, resolvePath builder = LotteryWindow(Lottery(resolvePath('data/stuff.json')))
def addCookbookPath(self, *args): for origPath in args: path = utils.resolvePath(origPath) #print "%s vs %s" % (origPath, path) self._cookbookPaths.append((origPath, path))