def extract(feature_name,wav_fd=None,fe_fd=None,yaml_file='',print_arr=[]): """ This function extracts features from audio. Parameters ---------- feature_name : str Name of feature to be extracted wav_fd : str Path to audio files fe_fd : str Path to feature files yaml_file : str Path to yaml file print_arr : str array, optional Description of feature that should be printed """ # Introduce features here if feature_name in M.get_list(): yaml_load=M.read_yaml(yaml_file) try: featx=yaml_load[feature_name] except Exception as e: print("Make sure you add the {} to the YAML file".format(e)) raise SystemExit x=call_ftr(feature_name,featx,wav_fd,fe_fd,print_arr) print("Something wrong happened" if x==1000 else "Feature found") else: print("Invalid Feature Name")
def extract_one(feature_name, wav_file, yaml_file='', library='wavread', dataset=None): """ This function extracts features from audio. Parameters ---------- feature_name : str Name of feature to be extracted wav_file : str Path to a single audio file yaml_file : str Path to yaml file """ if feature_name in M.get_list(): yaml_load = M.read_yaml(yaml_file) try: featx = yaml_load[feature_name] except Exception as e: print("Make sure you add the {} to the YAML file".format(e)) raise SystemExit x = M.call_ftr_one(feature_name, featx, wav_file, library, dataset) print("Something wrong happened" if type(x) == 'int' else "Feature found") return x else: print("Invalid Feature Name")
def check_dimension(feature, dimy, yaml_file): """ Args: feature: Name of the feature dimy: Dimension of the extracted feature yaml_file: YAML file from which feature was extracted Returns: None Raises: exception if dimensions mismatch """ if feature in ['mel', 'logmel']: find = 'n_mels' elif feature in ['cqt', 'spectralcentroid']: find = 'n_mels' if feature in M.get_list(): yaml_load = M.read_yaml(yaml_file) n1 = yaml_load[feature][find][0] if n1 != dimy: print "Dimension Mismatch. Expected {} Found {}".format(n1, dimy) raise SystemExit else: print "Correct dimension"
def dcu_handler(): ''' Main DCU handler. ''' if 'uid' in request.values: uid = request.values['uid'] c = Client.query.filter_by(uid=uid).first() if c is None: return make_response('UID not registered', 403) if 'logout' in request.values: db.session.delete(c) db.session.commit() return make_response(dumps({'logout':True}), 200) if 'recv' in request.values: receiver = request.values['recv'] r = Client.query.filter_by(name=receiver).first() if r is None: return make_response('Receiver not registered', 403) if not r.name in loads(c.access): return make_response('Access denied to \'%s\'' % r.name, 403) module = r.module client = r else: module = c.module client = c if module in modules.get_list(): proxy = modules.load(module).proxy return proxy.run(client) else: return make_response('Unknown module \'%s\'' % c.module, 400) else: try: name = request.values['name'] module = request.values['module'] if len(name) < 4 or len(name) > 15: return make_response('Name error, must be from 4 to 15', 400) if module in modules.get_list(): c = Client(name, module) db.session.add(c) db.session.commit() return make_response(dumps({'uid':c.uid}), 200) else: return make_response('Unknown module \'%s\'' % module, 400) except KeyError: return make_response('Not sended name or module', 400) except OperationalError as e: if DEBUG: return make_response('Database error: %s' % e, 400) else: return make_response('Database error', 400) except: return make_response('Client create unknown exception', 500)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from os.path import abspath, dirname sys.path.append('%s/..' % abspath(dirname(__file__))) import modules ################################################################################ ## ## Datastorage creator. ## ################################################################################ for i in modules.get_list(): modules.load(i) from dcu import db db.create_all()
#!/usr/bin/env python # -*- coding: utf-8 -*- from os.path import abspath, dirname import sys ################################################################################ ## ## Simple module tester ## ################################################################################ if __name__ == '__main__': sys.path.append('%s/..' % abspath(dirname(__file__))) from modules import get_list, load print '=> DCU-F Module tester <=' for module in get_list(): print '==> %s: Test started...' % module load(module).test.start()
## ################################################################################ try: target = sys.argv[1] print 'Moving static files to %s ...' % target core_static = abspath('%s/../static' % dirname(__file__)) print core_static print 'Copying core static files...' try: copytree(core_static, target) print 'done' except OSError as e: print 'pass: %s' % e.strerror for module in modules.get_list(): print 'Copying %s static files...' % module module_static = join(join(modules.MODULES_DIR, module), 'static') try: copytree(module_static, join(target, module)) print 'done' except OSError as e: print 'pass: %s' % e.strerror print 'complete! Have fun! =)' except IndexError: print 'Usage:\n\tcollect_static.py [target]'