Esempio n. 1
0
def map_song_tr(data):
    label, sid = data
    try:
        song_path = get_song_path(sid)
        new_mat = process_mp3(song_path)
        wd_ids = range(len(new_mat))
        random.shuffle(wd_ids)
        wd_ids = wd_ids[:SIZE]
        new_mat = [new_mat[i] for i in wd_ids]
        _new_mat = np.array(new_mat)
        _new_mat = np.log(_new_mat + 1)
        _new_mat = normalize(_new_mat)
        new_mat = map(lambda x: list(x), _new_mat)
        str_mat = map_list_to_str(new_mat)
        assert len(str_mat.split()) == DIM * SIZE  # QA
        return str_mat
    except:
        import traceback
        traceback.print_exc()
Esempio n. 2
0
def map_song_with_label_te(data):
    """For testing cases, provide beansdb for python test script"""
    label, sid = data
    try:
        song_path = get_song_path(sid)
        new_mat = process_mp3(song_path)
        wd_ids = range(len(new_mat))
        random.shuffle(wd_ids)
        wd_ids = wd_ids[:SIZE]
        new_mat = [new_mat[i] for i in wd_ids]
        _new_mat = np.array(new_mat)
        _new_mat = np.log(_new_mat + 1)
        _new_mat = normalize(_new_mat)
        new_mat = map(lambda x: list(x), _new_mat)
        new_mat_ln = reduce(lambda x, y : list(x) + list(y), list(new_mat))
        assert len(new_mat_ln) == DIM * SIZE # QA
        return label, new_mat_ln
    except:
        import traceback
        traceback.print_exc()
def map_song_with_label_te(data):
    """For testing cases, provide beansdb for python test script"""
    label, sid = data
    try:
        song_path = get_song_path(sid)
        new_mat = process_mp3(song_path)
        wd_ids = range(len(new_mat))
        random.shuffle(wd_ids)
        wd_ids = wd_ids[:SIZE]
        new_mat = [new_mat[i] for i in wd_ids]
        assert all(len(mat_elem) == DIM for mat_elem in new_mat)
        assert len(new_mat) == SIZE
        _new_mat = np.array(new_mat)
        _new_mat = np.log(_new_mat + 1)
        _new_mat = normalize(_new_mat)
        new_mat = _new_mat.tolist() # IMPORTANT. beansdb can't save numpy.float64
        return label, new_mat
    except:
        import traceback
        traceback.print_exc()
Esempio n. 4
0
def map_song_with_label_te(data):
    """For testing cases, provide beansdb for python test script"""
    label, sid = data
    try:
        song_path = get_song_path(sid)
        new_mat = process_mp3(song_path)
        wd_ids = range(len(new_mat))
        random.shuffle(wd_ids)
        wd_ids = wd_ids[:SIZE]
        new_mat = [new_mat[i] for i in wd_ids]
        assert all(len(mat_elem) == DIM for mat_elem in new_mat)
        assert len(new_mat) == SIZE
        _new_mat = np.array(new_mat)
        _new_mat = np.log(_new_mat + 1)
        _new_mat = normalize(_new_mat)
        new_mat = _new_mat.tolist(
        )  # IMPORTANT. beansdb can't save numpy.float64
        return label, new_mat
    except:
        import traceback
        traceback.print_exc()
Esempio n. 5
0
def map_song_with_label_tr(data):
    """For paracel IO, provide textfiles"""
    label, sid = data
    try:
        song_path = get_song_path(sid)
        new_mat = process_mp3(song_path)
        wd_ids = range(len(new_mat))
        random.shuffle(wd_ids)
        wd_ids = wd_ids[:SIZE]
        new_mat = [new_mat[i] for i in wd_ids]
        assert all(len(mat_elem) == DIM for mat_elem in new_mat)
        assert len(new_mat) == SIZE
        _new_mat = np.array(new_mat)
        _new_mat = np.log(_new_mat + 1)
        _new_mat = normalize(_new_mat)
        new_mat = map(lambda x: list(x), _new_mat)
        map(lambda x: x.append(label), new_mat)
        str_mat = map_list_to_str(new_mat)
        return str_mat
    except:
        import traceback
        traceback.print_exc()
def map_song_with_label_tr(data):
    """For paracel IO, provide textfiles"""
    label, sid = data
    try:
        song_path = get_song_path(sid)
        new_mat = process_mp3(song_path)
        wd_ids = range(len(new_mat))
        random.shuffle(wd_ids)
        wd_ids = wd_ids[:SIZE]
        new_mat = [new_mat[i] for i in wd_ids]
        assert all(len(mat_elem) == DIM for mat_elem in new_mat)
        assert len(new_mat) == SIZE
        _new_mat = np.array(new_mat)
        _new_mat = np.log(_new_mat + 1)
        _new_mat = normalize(_new_mat)
        new_mat = map(lambda x: list(x), _new_mat)
        map(lambda x: x.append(label), new_mat)
        str_mat = map_list_to_str(new_mat)
        return str_mat
    except:
        import traceback
        traceback.print_exc()