Datasets

The datasets module provides access to some common sources of audio on the internet. In general, a dataset instance is an iterable of zounds.soundfile.AudioMetaData instances that can be passed to the root node of an audio processing graph.

class zounds.datasets.FreeSoundSearch(api_key, query, n_results=10, delay=0.2)[source]

Produces an iterable of zounds.soundfile.AudioMetaData instances for every result from a https://freesound.org search

Parameters:
Raises
ValueError: when api_key and/or query are not supplied

Examples

>>> from zounds import FreeSoundSearch
>>> fss = FreeSoundSearch('YOUR_API_KEY', 'guitar')
>>> iter(fss).next()
{'description': u'Etude of Electric Guitar in Dm. Used chorus and reverberation effects. Size 6/4. Tempo 100. Gloomy and sentimental.', 'tags': [u'Etude', u'Experemental', u'Guitar', u'guitar', u'Electric', u'Chorus'], 'uri': <Request [GET]>, 'channels': 2, 'licensing': u'http://creativecommons.org/licenses/by/3.0/', 'samplerate': 44100.0}
class zounds.datasets.InternetArchive(archive_id, format_filter=None, **attrs)[source]

Produces an iterable of zounds.soundfile.AudioMetaData instances for every file of a particular format from an internet archive id.

Parameters:
  • archive_id (str) – the Internet Archive identifier
  • format_filter (str) – The file format to return
  • attrs (dict) – Extra attributes to add to the AudioMetaData
Raises:

ValueError – when archive_id is not provided

Examples

>>> from zounds import InternetArchive
>>> ia = InternetArchive('Greatest_Speeches_of_the_20th_Century')
>>> iter(ia).next()
{'creator': u'John F. Kennedy', 'height': u'0', 'channels': None, 'genre': u'Folk', 'licensing': None, 'mtime': u'1236666800', 'samplerate': None, 'size': u'7264435', 'album': u'Great Speeches of the 20th Century [Box Set] Disc 2', 'title': u'The Cuban Missile Crisis', 'format': u'128Kbps MP3', 'source': u'original', 'description': None, 'tags': None, 'track': u'15', 'crc32': u'ace17eb5', 'md5': u'e00f4e7bd9df7bdba4db7098d1ccdfe0', 'sha1': u'e42d1f348078a11ed9a6ea9c8934a1236235c7b3', 'artist': u'John F. Kennedy', 'external-identifier': [u'urn:acoustid:ff850a0c-2efa-450f-8034-efdb31a9b696', u'urn:mb_recording_id:912cedd0-5530-4f26-972c-13d131fef06e'], 'uri': <Request [GET]>, 'length': u'454.03', 'width': u'0'}
class zounds.datasets.PhatDrumLoops(**attrs)[source]

Produces an iterable of zounds.soundfile.AudioMetaData instances for every drum break from http://phatdrumloops.com/beats.php

Parameters:attrs (dict) – Extra properties to add to the AudioMetaData
Examples
>>> from zounds import PhatDrumLoops
>>> pdl = PhatDrumLoops()
>>> iter(pdl).next()
{'description': None, 'tags': None, 'uri': <Request [GET]>, 'channels': None, 'licensing': None, 'samplerate': None}
class zounds.datasets.CompositeDataset(*datasets)[source]

A dataset composed of two or more others

Parameters:datasets (list of datasets) – One or more other datasets

Examples

>>> from zounds import InternetArchive, CompositeDataset, ingest
>>> dataset1 = InternetArchive('beethoven_ingigong_850')
>>> dataset2 = InternetArchive('The_Four_Seasons_Vivaldi-10361')
>>> composite = CompositeDataset(dataset1, dataset2)
>>> ingest(composite, Sound) # ingest data from both datasets