Exemplo n.º 1
0
 def __init__(self, conf_path=None):
     # Load default settings
     if conf_path is not None:
         self.from_json(load_yaml(conf_path))  # pylint: disable=E1101
     else:
         conf_path = os.path.join(SETTING_DIR, self.default_setting_file)
         self.from_json(load_yaml(conf_path))  # pylint: disable=E1101
Exemplo n.º 2
0
    def _get_label_files(cls, dataset_path, wav_paths):
        # Get only vocal ground-truth files
        labels = []
        for wav_path in wav_paths:
            filename, _ = os.path.splitext(os.path.basename(wav_path))
            filename = filename.replace(cls.wav_postfix, "")
            meta_file = filename + cls.meta_file_postfix
            meta_file = os.path.join(os.path.dirname(wav_path), meta_file)
            meta = load_yaml(meta_file)

            if meta["instrumental"] == "yes":
                # Ignore instrumental songs that have no vocals.
                continue

            for tid, track in meta["stems"].items():
                if "singer" not in track["instrument"]:
                    # Ignore instruments
                    continue

                label_name = filename + cls.label_postfix.format(track_num=tid[1:]) + cls.label_ext
                label = os.path.join(dataset_path, cls.pitch_annotation_folder, label_name)
                if not os.path.exists(label):
                    # Not the main melody vocal
                    pass
                else:
                    labels.append(label)
                    break
        return labels
Exemplo n.º 3
0
def test_yaml_io(tmp_path):
    data = {
        "int": 1,
        "list": [1, 2, 3],
        "dict": {
            "a": "haha",
            "b": "iii"
        },
        "rrrr": "RRRRRRRRRRRRRRRRRR!",
        "nested": {
            "one": [3, 4, 5, 6.1, 9],
            "two": {
                "aa": {
                    "onon": 0.04,
                    "ofof": 0.16
                },
                "bb": "world"
            }
        }
    }
    f_name = tmp_path.joinpath("test.yaml")
    io.write_yaml(data, f_name)
    loaded = io.load_yaml(f_name)
    assert data == loaded