Skip to main content

This package aims at simplifying the download of the strong version of AudioSet dataset. This is a revised version of audioset-download (https://github.com/MorenoLaQuatra/audioset-download).

Project description

Ensure you read YouTube’s Terms of Service and confirm that you have the necessary permissions to access the data.

AudioSet Strong Download

This repository contains code for downloading the AudioSet dataset. The code is provided as-is, and is not officially supported by Google. Please note that as YouTube continually updates its API, the code in this repository may become outdated and stop working in the future.

Updates in This Repository

This repository is a revised version of audioset-download, with the following major updates:

  1. Updated commands to support the latest version of yt-dlp, with a particular focus on specifying the time segment to be downloaded.
  2. Added functionality to download either the dataset with original 10-second-resolution labels or the 2021 temporally-strong labels.
  3. Enabled support for incorporating cookies in the yt-dlp command.

Requirements

  • Python 3.9 (it may work with other versions, but it has not been tested)

Installation

# Install ffmpeg
brew install ffmpeg
# Install audioset-strong-download
pip install audioset-strong-download

Usage

The following code snippet downloads the unbalanced train set, and stores it in the test directory. It only downloads the files associated with the Speech and Cart labels, and uses two parallel processes for downloading. If a file is associated to multiple labels, it will be stored only once, and associated to the first label in the list.

from audioset_strong_download import Downloader
d = Downloader(root_path='test', labels=["Speech", "Cart"], n_jobs=2, download_type='eval', dataset_ver='strong', copy_and_replicate=False)
d.download(format = 'wav')

Implementation

The main class is audioset_strong_download.Downloader. It is initialized using the following parameters:

  • root_path: the path to the directory where the dataset will be downloaded.
  • labels: a list of labels to download. If None, all labels will be downloaded. See weak labels and strong labels
  • n_jobs: the number of parallel downloads. Default is 1.
  • dataset_ver:
  • download_type: the type of download. It can be one of the following:
    • balanced_train: balanced train set (weak)
    • unbalanced_train: unbalanced train set (weak)
    • train: train set (strong)
    • eval: evaluation set (weak & strong)
  • cookies: /path/to/cookies/file.txt (default: None)
  • copy_and_replicate: if True if a file is associated to multiple labels, it will be copied and replicated for each label. If False, it will be associated to the first label in the list. Default is True.

The methods of the class are:

  • download(format='vorbis', quality=5): downloads the dataset.
  • The format can be one of the following (supported by yt-dlp --audio-format parameter):
    • vorbis: downloads the dataset in Ogg Vorbis format. This is the default.
    • wav: downloads the dataset in WAV format.
    • mp3: downloads the dataset in MP3 format.
    • m4a: downloads the dataset in M4A format.
    • flac: downloads the dataset in FLAC format.
    • opus: downloads the dataset in Opus format.
    • webm: downloads the dataset in WebM format.
    • ... and many more.
    • The quality can be an integer between 0 and 10. Default is 5.
  • read_class_mapping(): reads the class mapping file. It is not used externally.
  • download_file(...): downloads a single file. It is not used externally.

Cookies

Due to the large number of files in AudioSet, YouTube may block the program from accessing videos. To address this issue, you can pass cookies to yt-dlp with the following steps:

  1. Run the command:

    yt-dlp --cookies-from-browser chrome --cookies cookies.txt
    

    This will generate a cookies.txt file in your current directory.

  2. Specify the cookies file path in the Downloader() function:

    cookies = "/path/to/cookies/file.txt"
    

For more details, refer to the yt-dlp FAQ.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audioset_strong_download-2.0.5.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audioset_strong_download-2.0.5-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file audioset_strong_download-2.0.5.tar.gz.

File metadata

  • Download URL: audioset_strong_download-2.0.5.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for audioset_strong_download-2.0.5.tar.gz
Algorithm Hash digest
SHA256 ce3810dd4ede112bd8dc6a6f2cf2b21beb3236e8763736156c88ae70e4f04f29
MD5 b37c49ac336e2412b497611ea1b3cf96
BLAKE2b-256 ec9dd14a22ba9061994b4a573b466a1ba1c2ff49a6a7bf5ed1222ecf2bb84d76

See more details on using hashes here.

File details

Details for the file audioset_strong_download-2.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for audioset_strong_download-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 302a8627a0507ba66b208ce1407ceb4bba7bfad6753a4c435dd75d54cb7e0264
MD5 3dbd6a448010887122372ad41eaaaf04
BLAKE2b-256 f59fa6264ae4c67411827e1ac8c84a2ee7f0ea25d5936f5c346ac414eccd31be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page