def beat_extractor(queue_beat):
    kwargs = dict(
        fps=100,
        correct=True,
        infile=None,
        outfile=None,
        max_bpm=170,
        min_bpm=60,
        #nn_files = [BEATS_LSTM[0]],
        transition_lambda=100,
        num_frames=1,
        online=True,
        verbose=1)

    def beat_callback(beats, output=None):
        if len(beats) > 0:
            # Do something with the beat (for now, just print the array to stdout)
            queue_beat.put(beats[0])
            #print(beats)

    #print('Process to write betas: %s' % os.getpid())
    in_processor = RNNBeatProcessor(**kwargs)
    beat_processor = DBNBeatTrackingProcessor(**kwargs)
    out_processor = [beat_processor, beat_callback]
    processor = IOProcessor(in_processor, out_processor)
    process_online(processor, **kwargs)
Пример #2
0
          "Otherwise the model's performance will be very poor.\n")

    # initialize network
    print("Initializing tagging network ...")
    model = select_model(args.model)
    net = model.build_model(batch_size=1)

    # initialize neural network
    TAGGER = Network(net, print_architecture=False)

    # load model parameters network
    if args.params is not None:
        dump_file = args.params
    else:
        out_path = os.path.join(os.path.join(EXP_ROOT), model.EXP_NAME)
        dump_file, log_file = get_dump_file_paths(out_path, 1)
        dump_file = dump_file.replace(".pkl", "_it0.pkl")
    print("Loading model from: %s" % dump_file)
    TAGGER.load(dump_file)

    # set prediction rate
    PREDICT_EVERY_K = args.predict_every_k

    # dummy prediction to compile model
    print("Compiling prediction function ...")
    TAGGER.predict(SLIDING_WINDOW[np.newaxis, np.newaxis])

    print("Starting prediction loop ...")
    processor = IOProcessor(in_processor=processor_pipeline2, out_processor=output_processor)
    process_online(processor, infile=None, outfile=None, sample_rate=32000)