dcase_models.data.TAUUrbanAcousticScenes2019

class dcase_models.data.TAUUrbanAcousticScenes2019(dataset_path)[source]

Bases: dcase_models.data.datasets._TAUUrbanAcousticScenes

TAU Urban Acoustic Scenes 2019 dataset.

This class inherits all functionality from Dataset and defines specific attributes and methods for TAU Urban Acoustic Scenes 2019.

Url: https://zenodo.org/record/2589280

A. Mesaros, T. Heittola, and T. Virtanen. “A multi-devicedataset for urban acoustic scene classification”. Proceedings of the Detection and Classification of Acoustic Scenes and Events 2018 Workshop (DCASE 2018). November 2018.

Parameters:
dataset_path : str

Path to the dataset folder. This is the path to the folder where the complete dataset will be downloaded, decompressed and handled. It is expected to use a folder name that represents the dataset unambiguously (e.g. ../datasets/TAUUrbanAcousticScenes2019).

Examples

To work with TAUUrbanAcousticScenes2019 dataset, just initialize this class with the path to the dataset.

>>> from dcase_models.data.datasets import TAUUrbanAcousticScenes2019
>>> dataset = TAUUrbanAcousticScenes2019(
    '../datasets/TAUUrbanAcousticScenes2019')

Then, you can download the dataset and change the sampling rate.

>>> dataset.download()
>>> dataset.change_sampling_rate(22050)
__init__(dataset_path)[source]

Init Dataset

Methods

__init__(dataset_path) Init Dataset
build() Builds the dataset.
change_sampling_rate(new_sr) Changes the sampling rate of each wav file in audio_path.
check_if_downloaded() Checks if the dataset was downloaded.
check_sampling_rate(sr) Checks if dataset was resampled before.
convert_to_wav([remove_original]) Converts each file in the dataset to wav format.
download([force_download]) Downloads and decompresses the dataset from zenodo.
generate_file_lists() Creates file_lists, a dict that includes a list of files per fold.
get_annotations(file_name, features, …) Returns the annotations of the file in file_path.
get_audio_paths([sr]) Returns paths to the audio folder.
set_as_downloaded() Saves a download.txt file in dataset_path as a downloaded flag.
build()

Builds the dataset.

Define specific attributes of the dataset. It’s mandatory to define audio_path, fold_list and label_list. Other attributes may be defined here (url, authors, etc.).

change_sampling_rate(new_sr)

Changes the sampling rate of each wav file in audio_path.

Creates a new folder named audio_path{new_sr} (i.e audio22050) and converts each wav file in audio_path and save the result in the new folder.

Parameters:
sr : int

Sampling rate.

check_if_downloaded()

Checks if the dataset was downloaded.

Just checks if exists download.txt file.

Further checks in the future.

check_sampling_rate(sr)

Checks if dataset was resampled before.

For now, only checks if the folder {audio_path}{sr} exists and each wav file present in audio_path is also present in {audio_path}{sr}.

Parameters:
sr : int

Sampling rate.

Returns:
bool

True if the dataset was resampled before.

convert_to_wav(remove_original=False)

Converts each file in the dataset to wav format.

If remove_original is False, the original files will be deleted

Parameters:
remove_original : bool

Remove original files.

download(force_download=False)[source]

Downloads and decompresses the dataset from zenodo.

Parameters:
zenodo_url : str

URL with the zenodo files. e.g. ‘https://zenodo.org/record/12345/files

zenodo_files : list of str

List of files. e.g. [‘file1.tar.gz’, ‘file2.tar.gz’, ‘file3.tar.gz’]

force_download : bool

If True, download the dataset even if was downloaded before.

Returns:
bool

True if the downloading process was successful.

generate_file_lists()

Creates file_lists, a dict that includes a list of files per fold.

Each dataset has a different way of organizing the files. This function defines the dataset structure.

get_annotations(file_name, features, time_resolution)

Returns the annotations of the file in file_path.

Parameters:
file_path : str

Path to the file

features : ndarray

nD array with the features of file_path

time_resolution : float

Time resolution of the features

Returns:
ndarray

Annotations of the file file_path Expected output shape: (features.shape[0], len(self.label_list))

get_audio_paths(sr=None)

Returns paths to the audio folder.

If sr is None, return audio_path. Else, return {audio_path}{sr}.

Parameters:
sr : int or None, optional

Sampling rate.

Returns:
audio_path : str

Path to the root audio folder. e.g. DATASET_PATH/audio

subfolders : list of str

List of subfolders include in audio folder. Important when use AugmentedDataset. e.g. [‘{DATASET_PATH}/audio/original’]

set_as_downloaded()

Saves a download.txt file in dataset_path as a downloaded flag.