stanford_mir.py
def download_samples(collection='drum_samples_train', download=True):
    """Download ten kick drum samples and ten snare drum samples.

        `collection`: output directory containing the twenty drum samples

    Returns:

        `kick_filepaths`: list of kick drum filepaths

        `snare_filepaths`: list of snare drum filepaths
    """
    try:
        os.makedirs(collection)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise

    if collection == 'drum_samples_train':
        if download:
            for drum_type in ['kick', 'snare']:
                for i in range(1, 11):
                    filename = '%s_%02d.wav' % (drum_type, i)
                    urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/drum_samples/%s' % filename,
                                       filename=os.path.join(collection, filename))
        kick_filepaths = [os.path.join(collection, 'kick_%02d.wav' % i) for i in range(1, 11)]
        snare_filepaths = [os.path.join(collection, 'snare_%02d.wav' % i) for i in range(1, 11)]
        return kick_filepaths, snare_filepaths

    elif collection == 'drum_samples_test':
        if download:
            for drum_type in ['kick', 'snare']:
                for i in range(30):
                    filename = '%s_%02d.wav' % (drum_type, i)
                    urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/drum_samples/test/%s' % filename,
                                       filename=os.path.join(collection, filename))
        kick_filepaths = [os.path.join(collection, 'kick_%02d.wav' % i) for i in range(30)]
        snare_filepaths = [os.path.join(collection, 'snare_%02d.wav' % i) for i in range(30)]
        return kick_filepaths, snare_filepaths

    elif collection == 'violin_samples_train':
        urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/violin_samples_train/list.txt',
                           filename=os.path.join(collection, 'list.txt'))
        for line in open(os.path.join(collection, 'list.txt'), 'r'):
            filename = line.strip()
            print(filename)
            if filename.endswith('.wav'):
                urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/' + filename,
                                   filename=filename)
        return [os.path.join(collection, f) for f in os.listdir(collection)]
Download ten kick drum samples and ten snare drum samples.

        `collection`: output directory containing the twenty drum samples

    Returns:

        `kick_filepaths`: list of kick drum filepaths

        `snare_filepaths`: list of snare drum filepaths
    
Download ten kick drum samples and ten snare drum samples.
`collection`: output directory containing the twenty drum samples
Download ten kick drum samples and ten snare drum samples . ` collection ` : output directory containing the twenty drum samples
def download_samples(collection='drum_samples_train', download=True):
    try:
        os.makedirs(collection)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise
    if collection == 'drum_samples_train':
        if download:
            for drum_type in ['kick', 'snare']:
                for i in range(1, 11):
                    filename = '%s_%02d.wav' % (drum_type, i)
                    urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/drum_samples/%s' % filename,
                                       filename=os.path.join(collection, filename))
        kick_filepaths = [os.path.join(collection, 'kick_%02d.wav' % i) for i in range(1, 11)]
        snare_filepaths = [os.path.join(collection, 'snare_%02d.wav' % i) for i in range(1, 11)]
        return kick_filepaths, snare_filepaths
    elif collection == 'drum_samples_test':
        if download:
            for drum_type in ['kick', 'snare']:
                for i in range(30):
                    filename = '%s_%02d.wav' % (drum_type, i)
                    urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/drum_samples/test/%s' % filename,
                                       filename=os.path.join(collection, filename))
        kick_filepaths = [os.path.join(collection, 'kick_%02d.wav' % i) for i in range(30)]
        snare_filepaths = [os.path.join(collection, 'snare_%02d.wav' % i) for i in range(30)]
        return kick_filepaths, snare_filepaths
    elif collection == 'violin_samples_train':
        urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/violin_samples_train/list.txt',
                           filename=os.path.join(collection, 'list.txt'))
        for line in open(os.path.join(collection, 'list.txt'), 'r'):
            filename = line.strip()
            print(filename)
            if filename.endswith('.wav'):
                urllib.request.urlretrieve('http://audio.musicinformationretrieval.com/' + filename,
                                   filename=filename)
        return [os.path.join(collection, f) for f in os.listdir(collection)]
def download_samples ( collection = 'drum_samples_train' , download = True ) : try : os . makedirs ( collection ) except OSError as exception : if exception . errno != errno . EEXIST : raise if collection == 'drum_samples_train' : if download : for drum_type in [ 'kick' , 'snare' ] : for i in range ( 1 , 11 ) : filename = '%s_%02d.wav' % ( drum_type , i ) urllib . request . urlretrieve ( 'http://audio.musicinformationretrieval.com/drum_samples/%s' % filename , filename = os . path . join ( collection , filename ) ) kick_filepaths = [ os . path . join ( collection , 'kick_%02d.wav' % i ) for i in range ( 1 , 11 ) ] snare_filepaths = [ os . path . join ( collection , 'snare_%02d.wav' % i ) for i in range ( 1 , 11 ) ] return kick_filepaths , snare_filepaths elif collection == 'drum_samples_test' : if download : for drum_type in [ 'kick' , 'snare' ] : for i in range ( 30 ) : filename = '%s_%02d.wav' % ( drum_type , i ) urllib . request . urlretrieve ( 'http://audio.musicinformationretrieval.com/drum_samples/test/%s' % filename , filename = os . path . join ( collection , filename ) ) kick_filepaths = [ os . path . join ( collection , 'kick_%02d.wav' % i ) for i in range ( 30 ) ] snare_filepaths = [ os . path . join ( collection , 'snare_%02d.wav' % i ) for i in range ( 30 ) ] return kick_filepaths , snare_filepaths elif collection == 'violin_samples_train' : urllib . request . urlretrieve ( 'http://audio.musicinformationretrieval.com/violin_samples_train/list.txt' , filename = os . path . join ( collection , 'list.txt' ) ) for line in open ( os . path . join ( collection , 'list.txt' ) , 'r' ) : filename = line . strip ( ) print ( filename ) if filename . endswith ( '.wav' ) : urllib . request . urlretrieve ( 'http://audio.musicinformationretrieval.com/' + filename , filename = filename ) return [ os . path . join ( collection , f ) for f in os . listdir ( collection ) ]
Download ten kick drum samples and ten snare drum samples.
Download ten kick drum samples and ten snare drum samples .
"""Download ten kick drum samples and ten snare drum samples.

        `collection`: output directory containing the twenty drum samples

    Returns:

        `kick_filepaths`: list of kick drum filepaths

        `snare_filepaths`: list of snare drum filepaths
    """
list of kick drum filepaths
`snare_filepaths`: list of snare drum filepaths
list of kick drum filepaths ` snare_filepaths ` : list of snare drum filepaths
`kick_filepaths`
collection
download