Source code for mltk.datasets.audio.background_noise.esc50
"""ESC: Dataset for Environmental Sound Classification**************************************************************https://github.com/karoldvl/paper-2015-esc-datasetAbstract------------One of the obstacles in research activities concentrating on environmental sound classification is the scarcity of suitable and publicly available datasets.This paper tries to address that issue by presenting a new annotated collection of 2 000 short clips comprising 50 classes of various common sound events,and an abundant unified compilation of 250 000 unlabeled auditory excerpts extracted from recordings available through the Freesound project.The paper also provides an evaluation of human accuracy in classifying environmental sounds and compares it to the performance of selected baseline classifiersusing features derived from mel-frequency cepstral coefficients and zero-crossing rate.Citing---------K. J. Piczak. **ESC: Dataset for Environmental Sound Classification**. In *Proceedings of the 23rd ACM international conference on Multimedia*, pp. 1015-1018, ACM, 2015."""importosimportloggingfrommltk.utils.archive_downloaderimportdownload_verify_extractfrommltk.utils.process_poolimportProcessPoolfrommltk.core.preprocess.utilsimportaudioasaudio_utilsDOWNLOAD_URL='https://github.com/karolpiczak/ESC-50/archive/a5e0c7451e12a751302b32283f1f039cbd111356.zip'"""Public download URL"""VERIFY_SHA1='160bb1269418240f9d2bb86eee598ffbd882ca89'"""SHA1 hash of the downloaded archive"""
[docs]defdownload(dest_dir:str=None,dest_subdir:str='datasets/esc-50',sample_rate_hertz:int=16000,logger:logging.Logger=None,clean_dest_dir=False)->str:"""Download the dataset, extract, and convert each sample to the specified data rate in-place. Returns: The path to the extract and re-sample dataset directory """ifdest_dir:dest_subdir=Nonebase_dir,is_up_to_date=download_verify_extract(dest_dir=dest_dir,dest_subdir=dest_subdir,url=DOWNLOAD_URL,file_hash=VERIFY_SHA1,archive_fname='ESC-50.zip',remove_root_dir=True,clean_dest_dir=clean_dest_dir,logger=logger,return_uptodate=True)audio_dir=f'{base_dir}/audio'ifnotis_up_to_dateandsample_rate_hertz!=44100:withProcessPool(entry_point=_convert_sample_rate,n_jobs=8)aspool:filenames=list(fnforfninos.listdir(audio_dir)iffn.endswith('.wav'))batch=pool.create_batch(len(filenames))forfninfilenames:p=f'{audio_dir}/{fn}'pool.process(path=p,sample_rate_hz=sample_rate_hertz,pool_batch=batch)batch.wait()returnaudio_dir
Important: We use cookies only for functional and traffic analytics.
We DO NOT use cookies for any marketing purposes. By using our site you acknowledge you have read and understood our Cookie Policy.