Package: audioset-manager
AudioSet Data ManagerA simple python package for managing the audio data from Google Research's ontology of 632 audio event classes and a collection of 2,084,320 human-labeled 10-second sound clips drawn from YouTube videos.DescriptionGoogle Research's AudioSet is a repository of audio events that span a wide range of labels. This python package is here to help you navigate, downlead, and edit the entire repository of audio events in order to easily extract the desired files. Each line in the AudioSetcsvfile format has columns defined by the third header line:# YTID, start_seconds, end_seconds, positive_labels. The package is based on this loose temporal.csvfile format; which looks like this:# Segments csv created Sun Mar 5 10:54:31 2017positive_labels# num_ytids=22160num_segs=22160num_unique_labels=527num_positive_labels=52882# YTIDstart_secondsend_secondspositive_labels--PJHxphWEs30.00040.000"/m/09x0r,/t/dd00088"............DO NOT ALTER CSV FILE. The python package will automatically format into the following:YTIDstart_secondsend_secondspositive_labels-0RWZT-miFs420.000430.000"/m/03v3yw,/m/0k4j"............Getting StartedDependenciesPython v3.xFFmpegpydubyoutubedlpandasInstallingTo install the python packages simply run the following commandspip install requirements.txtDownload the correct FFmpeg packages & executable files depedning on your OSLink hereAdd FFmpeg to PATHExecuting programCreating ManagerInstantiate AudioSet Manager by passing in argumentscsvargument is the file path to the csv downloaded fromthis pagedirargument is the file path to the desired directory you want files to be saved toydl_optsargument is the youtubedl configuration format of the downloaded files.See youtubedl docsfor more information andthisfor possible field optionsfromAudioSetimportAudioSetaud=AudioSet(csv=CSV,dir=DIR,ydl_opts=YDL_OPTS)print(aud.df.head())# See the top 5 rowsFiltering bymidIn order to narrow down the dataset by a desired audio event, you can filter the entire dataframe according to the audio event'smid. Refer toonotolgy.jsonfor themiddictionaryaud.filter("/m/0dgw9r")# Keep only audio clips that contain "Human Sounds"print(aud.df.head())# Will only contain rows with "Human Sounds"Downloading Videos and Audio CuttingOne can download all theaudioin the manager's dataframeNote, thissaves to project home directory. Specify desired save directory withydl_optsargument in constructor.aud.download()There are several options for cutting the audio. Thewavargument is the path to the desired wav file to cut. These all save the clips under theDIRfolder.Cutting based onstart_timeandend_timefrom AudioSet csv filesExport files of audio fromstart_timetoend_timeaud.split(wav=WAV_PATH)Cutting based on method 1 and then further cutting based on silence_chunkExport files into segments of non-silent audio fromstart_timetoend_timeaud.split_by_silence(wav=WAV_PATH, theta=-35)thetais the silence threshold (default is -35dB)Cutting based on chunks of timeExport files intoxseconds clipsaud.chunkify(wav=WAV_PATH, seconds=x)Future DevelopmentsSupport for strong temporal stamp filesIn progressMore robust file readingMore audio editing featuresContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.