示例#1
0
def main_extractor(args):
    """main_extractor

    Compute the comprehensive extractor feature set over the input
    waveform and dump the pickled result into a file
    """
    audio = loadaudio(args)

    frame = audio

    extr = estd.Extractor(
        lowLevelFrameSize = args.frame_size_low_level,
        lowLevelHopSize   = int(args.frame_size_low_level/2),
        )

    # # compute the centroid for all frames in our audio and add it to the pool
    # for frame in estd.FrameGenerator(audio, frameSize = 10 * args.samplerate, hopSize = 5 * args.samplerate):
    #     dreal, ddfa = danceability(w(frame))
    #     print "d", dreal # , "frame", frame
    #     pool.add('rhythm.danceability', dreal)

    # compute feature of frame and put them into dict p
    p = extr(frame)

    pdict = {}
    # print "type(p)", type(p)
    for desc in p.descriptorNames():
        print((desc, type(p[desc])))
        #     print "{0: >20}: {1}".format(desc, p[desc])
        pdict[desc] = p[desc]

    pickle.dump(pdict, open("data/music_features_%s.pkl" % (util_filename_clean(args.file), ), "wb"))
示例#2
0
def featureExtraction(soundfiles):

    #extractor = esst.LowLevelSpectralExtractor()
    extractor = esst.Extractor(dynamics=True,
                               dynamicsFrameSize=88200,
                               dynamicsHopSize=44100,
                               highLevel=True,
                               lowLevel=True,
                               lowLevelFrameSize=2048,
                               lowLevelHopSize=1024,
                               midLevel=True,
                               namespace="",
                               relativeIoi=False,
                               rhythm=True,
                               sampleRate=44100,
                               tonalFrameSize=4096,
                               tonalHopSize=2048,
                               tuning=True)

    #soundfiles = listdir(inputPath)

    for file, outPath in soundfiles:

        audioLoader = esst.MonoLoader(filename=file)
        audio = audioLoader()
        pool = essentia.Pool()
        pool = extractor(audio)
        aggPool = esst.PoolAggregator()(pool)
        esst.YamlOutput(filename=outPath + 'features.json',
                        format='json')(aggPool)
        print(file + ' exported')
def extractDefaultFeatures(audio, outputDir):

    # compute all features for all sounds
    extractor = ess.Extractor(dynamics=True,
                              dynamicsFrameSize=88200,
                              dynamicsHopSize=44100,
                              highLevel=True,
                              lowLevel=True,
                              lowLevelFrameSize=2048,
                              lowLevelHopSize=1024,
                              midLevel=True,
                              namespace="",
                              relativeIoi=False,
                              rhythm=True,
                              sampleRate=44100,
                              tonalFrameSize=4096,
                              tonalHopSize=2048,
                              tuning=True)

    pool = essentia.Pool()
    pool = extractor(audio)
    aggPool = ess.PoolAggregator()(pool)

    if not path.exists(outputDir):
        makedirs(outputDir)

    ess.YamlOutput(filename=outputDir + "features.json",
                   format="json",
                   doubleCheck=True)(aggPool)
示例#4
0
def featureExtraction(soundfiles):
    # extractor = esst.LowLevelSpectralExtractor()
    extractor = esst.Extractor(dynamics = False,
                                                dynamicsFrameSize = 88200,
                                                dynamicsHopSize = 44100,
                                                highLevel = False,
        			         lowLevel = True,
        			         lowLevelFrameSize = 2048,
        			         lowLevelHopSize = 1024,
        			         midLevel = True,
        			         namespace = "",
        			         relativeIoi = False,
        			         rhythm = False,
        			         sampleRate  = 44100,
        			         tonalFrameSize  = 4096,
        			         tonalHopSize = 2048,
			         tuning = True)

	#soundfiles = listdir(inputPath)
    for file in soundfiles:

        path1= '/Users/helena/Desktop/SMC/ASP/sms-tools/workspace/A10/code/downloaded/'
        name=file[70:-4] + '_features.json'
        outPath = path1 + 'features/' + name
        print file
        audioLoader = esst.MonoLoader(filename=file)
        audio = audioLoader()
        pool = essentia.Pool()
        pool = extractor(audio)
        aggPool = esst.PoolAggregator()(pool)
        output = esst.YamlOutput(filename = outPath, format='json')
        output(aggPool)
        print (outPath + ' exported')