def exists(data_home=None): """Check if the Beatles dataset folder exists Args: data_home (str): Local path where the dataset is stored. If `None`, looks for the data in the default directory, `~/mir_datasets` Returns: (bool): True if the Beatles dataset folder exists """ save_path = utils.get_save_path(data_home) dataset_path = os.path.join(save_path, DATASET_DIR) return os.path.exists(dataset_path)
def load(data_home=None): """Load SALAMI dataset Args: data_home (str): Local path where the dataset is stored. If `None`, looks for the data in the default directory, `~/mir_datasets` Returns: (dict): {`track_id`: track data} """ save_path = utils.get_save_path(data_home) dataset_path = os.path.join(save_path, DATASET_DIR) validate(dataset_path, data_home) salami_data = {} for key in track_ids(): salami_data[key] = Track(key, data_home=data_home) return salami_data
def download(data_home=None): """MedleyDB is not available for downloading directly. This function prints a helper message to download MedleyDB through zenodo.org. Args: data_home (str): Local path where the dataset is stored. If `None`, looks for the data in the default directory, `~/mir_datasets` """ save_path = utils.get_save_path(data_home) print(""" To download this dataset, visit: https://zenodo.org/record/2628782#.XKZdABNKh24 and request access. Once downloaded, unzip the file MedleyDB-Melody.zip and place the result in: {save_path} """.format(save_path=save_path))
def download(data_home=None, force_overwrite=False): """Download ORCHSET Dataset. Args: data_home (str): Local path where the dataset is stored. If `None`, looks for the data in the default directory, `~/mir_datasets` force_overwrite (bool): whether to overwrite the existing downloaded data """ save_path = utils.get_save_path(data_home) dataset_path = os.path.join(save_path, DATASET_DIR) if exists(data_home) and not force_overwrite: return if force_overwrite: utils.force_delete_all(REMOTE, dataset_path, data_home) download_path = utils.download_from_remote(REMOTE, force_overwrite=force_overwrite) utils.unzip(download_path, save_path, dataset_path)
def download(data_home=None, force_overwrite=False): """Download the Beatles Dataset (annotations). The audio files are not provided due to the copyright. Args: data_home (str): Local path where the dataset is stored. If `None`, looks for the data in the default directory, `~/mir_datasets` force_overwrite (bool): Whether to overwrite the existing downloaded data """ save_path = utils.get_save_path(data_home) dataset_path = os.path.join(save_path, DATASET_DIR) if exists(data_home) and not force_overwrite: return if force_overwrite: utils.force_delete_all(ANNOTATIONS_REMOTE, dataset_path=None, data_home=data_home) download_path = utils.download_from_remote( ANNOTATIONS_REMOTE, data_home=data_home, force_overwrite=force_overwrite ) if not os.path.exists(dataset_path): os.makedirs(dataset_path) utils.untar(download_path, dataset_path, cleanup=True) missing_files, invalid_checksums = validate(dataset_path, data_home) if missing_files or invalid_checksums: print( """ Unfortunately the audio files of the Beatles dataset are not available for download. If you have the Beatles dataset, place the contents into a folder called Beatles with the following structure: > Beatles/ > annotations/ > audio/ and copy the Beatles folder to {} """.format( save_path ) )
def download(data_home=None): """Download iKala Dataset. However, iKala dataset is not available for download anymore. This function prints a helper message to organize pre-downloaded iKala dataset. Args: data_home (str): Local path where the dataset is stored. If `None`, looks for the data in the default directory, `~/mir_datasets` """ save_path = utils.get_save_path(data_home) print(""" Unfortunately the iKala dataset is not available for download. If you have the iKala dataset, place the contents into a folder called {ikala_dir} with the following structure: > {ikala_dir}/ > Lyrics/ > PitchLabel/ > Wavfile/ and copy the {ikala_dir} folder to {save_path} """.format(ikala_dir=DATASET_DIR, save_path=save_path))
def save_path(data_home): return utils.get_save_path(data_home)
def test_get_save_path_with_data_home(): assert 'data_home' == utils.get_save_path('data_home')
def test_get_save_path(mocker, tmpdir): mocker.patch('mirdata.utils.MIR_DATASETS_DIR', str(tmpdir)) assert tmpdir == utils.get_save_path(None)