def agregarPost():
    genero = int(request.form['genero'])
    if 'archivo' not in request.files:
        print 'No se ha enviado ningun archivo'
        return redirect(url_for('index'))
    file = request.files['archivo']
    if file.filename == '':
        print 'No se ha seleccionado ningun archivo'
        return redirect(url_for('index'))
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

        print '> Archivo subido: ' + filename
        audio = Audio(os.path.join(app.config['UPLOAD_FOLDER'], filename),
                      nro_texture_windows=NRO_TEXTURE_WINDOWS, hopsize=HOPSIZE)

        print '> Extrayendo caracteristicas:' + filename
        featureVector = feature.getFeatureVector(audio,
                                                 ANALYSIS_WINDOW,
                                                 HOPSIZE, TEXTURE_WINDOW)
        common.saveDict(featureVector,
                        os.path.join(app.config['UPLOAD_FOLDER'],
                                     filename + '.json'))
        print '> JSON generado: ' + filename + '.json'

        cur.execute(
            "INSERT INTO songs (filename, genre, data) VALUES (%s, %s, %s)",
            (filename, genero, filename + '.json'))
        conn.commit()

        return redirect(url_for('getLista'))
from neat import nn
import pickle
from app.audio.audioClass import Audio
from app.audio import feature
from app import common


a = Audio('/home/yuli/demo.wav',
          nro_texture_windows=2584, hopsize=256)
dict = feature.getFeatureVector(a, 512, 256, 86)

arr = common.featureDictToArray(dict)

winner = pickle.load(open('/home/yuli/IA2/clasificador/app/data/redNeuronal.p',
                          'r'))
winner_net = nn.create_feed_forward_phenotype(winner)
output = winner_net.serial_activate(arr)

print output