Пример #1
0
    def get_symbtr_data(txt_file, mu2_file):
        extractor = DataExtractor()
        txt_data = extractor.extract(txt_file)[0]

        mu2_header = Mu2Reader.read_header(mu2_file)[0]

        return extractor.merge(txt_data, mu2_header, verbose=False)
Пример #2
0
    def get_symbtr_data(txt_file, mu2_file):
        extractor = DataExtractor()
        txt_data = extractor.extract(txt_file)[0]

        mu2_header = Mu2Reader.read_header(mu2_file)[0]

        return extractor.merge(txt_data, mu2_header, verbose=False)
def test_with_full_input():
    """
    Tests the result with complete information available, i.e. mbid, phrase
    annotation and user provided segmentation
    """
    # inputs
    scorename = 'kurdilihicazkar--sarki--agiraksak--ehl-i_askin--tatyos_efendi'

    txt_filename = os.path.join(_curr_folder, 'data', scorename + '.txt')

    mbid = 'b43fd61e-522c-4af4-821d-db85722bf48c'

    auto_seg_file = os.path.join(_curr_folder, 'data', scorename + '.autoSeg')
    auto_seg_bounds = json.load(open(auto_seg_file, 'r'))['boundary_noteIdx']

    mu2_filename = os.path.join(_curr_folder, 'data', scorename + '.mu2')

    # initialize the extractor
    extractor = DataExtractor(extract_all_labels=False,
                              melody_sim_thres=0.75,
                              lyrics_sim_thres=0.75,
                              save_structure_sim=True,
                              get_recording_rels=False,
                              print_warnings=True)

    # extract txt_data
    txt_data, is_data_valid = extractor.extract(
        txt_filename,
        symbtr_name=scorename,
        mbid=mbid,
        segment_note_bound_idx=auto_seg_bounds)

    # extract mu2 header metadata
    mu2_header, header_row, is_header_valid = Mu2Reader.read_header(
        mu2_filename, symbtr_name=scorename)

    # merge
    data = DataExtractor.merge(txt_data, mu2_header)
    is_valid = is_data_valid and is_header_valid

    # compare with a previously saved result
    score_data_file = os.path.join(_curr_folder, 'data', scorename + '.json')
    saved_data = json.load(open(score_data_file))

    assert saved_data == data, u"{0:s}: the result is different".format(
        scorename)
    assert is_valid, "The data is not valid (or the validations failed.)"
def test_with_full_input():
    """
    Tests the result with complete information available, i.e. mbid, phrase
    annotation and user provided segmentation
    """
    # inputs
    scorename = 'kurdilihicazkar--sarki--agiraksak--ehl-i_askin--tatyos_efendi'

    txt_filename = os.path.join(_curr_folder, 'data', scorename + '.txt')

    mbid = 'b43fd61e-522c-4af4-821d-db85722bf48c'

    auto_seg_file = os.path.join(_curr_folder, 'data', scorename + '.autoSeg')
    auto_seg_bounds = json.load(open(auto_seg_file, 'r'))['boundary_noteIdx']

    mu2_filename = os.path.join(_curr_folder, 'data', scorename + '.mu2')

    # initialize the extractor
    extractor = DataExtractor(
        extract_all_labels=False, melody_sim_thres=0.75, lyrics_sim_thres=0.75,
        save_structure_sim=True, get_recording_rels=False, print_warnings=True)

    # extract txt_data
    txt_data, is_data_valid = extractor.extract(
        txt_filename, symbtr_name=scorename, mbid=mbid,
        segment_note_bound_idx=auto_seg_bounds)

    # extract mu2 header metadata
    mu2_header, header_row, is_header_valid = Mu2Reader.read_header(
        mu2_filename, symbtr_name=scorename)

    # merge
    data = DataExtractor.merge(txt_data, mu2_header)
    is_valid = is_data_valid and is_header_valid

    # compare with a previously saved result
    score_data_file = os.path.join(_curr_folder, 'data', scorename + '.json')
    saved_data = json.load(open(score_data_file))

    assert saved_data == data, u"{0:s}: the result is different".format(
        scorename)
    assert is_valid, "The data is not valid (or the validations failed.)"