def subprocessFeatureExtractionFrame(path_root, path_folder, fn):
    """
    subprocess for essentia freesound feature extractor
    :param path_root: input audio root path
    :param path_folder: input audio subfolder path
    :param fn: audio file name
    :return:
    """

    extractor = es.FreesoundExtractor(lowlevelFrameSize=2048,
                                      lowlevelHopSize=1024,
                                      tonalFrameSize=2048,
                                      tonalHopSize=1024,
                                      gfccStats=["mean"],
                                      mfccStats=["mean"],
                                      lowlevelStats=["mean", "stdev"],
                                      tonalStats=["mean", "stdev"],
                                      rhythmStats=["mean"])
    feature_aggregated, _ = extractor(os.path.join(path_root, path_folder, fn))
    feature_array, list_desc = convert_essentia_pool_2_feature_array(
        feature_aggregated)
    ensure_dir(os.path.join(path_root, path_folder + "_feature"))
    pickle.dump([feature_array, list_desc],
                open(
                    os.path.join(path_root, path_folder + "_feature",
                                 fn + ".pkl"), 'w'))
Ejemplo n.º 2
0
def subprocessFeatureExtractionFrame(path_audio,
                                     path_feature_freesound_statistics, fn):
    """
    Run this in process to avoid memory leak
    :param path_audio:
    :param path_feature_freesound_statistics:
    :param fn:
    :return:
    """
    extractor = es.FreesoundExtractor(lowlevelFrameSize=4096,
                                      lowlevelHopSize=2048)
    _, feature_frame_pool = extractor(os.path.join(path_audio, fn))
    feature_pd_DataFrame = frame_pool_aggregation(feature_frame_pool, fn)
    feature_pd_DataFrame.to_csv(
        os.path.join(path_feature_freesound_statistics,
                     fn.split('.')[0] + '.csv'))
Ejemplo n.º 3
0
def batchFeatureExtractionFrame(path_audio, path_feature_freesound_statistics,
                                channel_string):
    filenames_audio = [
        f for f in os.listdir(path_audio)
        if os.path.isfile(os.path.join(path_audio, f))
    ]
    for ii, fn in enumerate(filenames_audio):
        if ii < 21840:
            continue
        print('calculating', ii, fn, 'audio feature for', channel_string,
              'in total', len(filenames_audio))
        # try:
        extractor = es.FreesoundExtractor(lowlevelFrameSize=4096,
                                          lowlevelHopSize=2048)
        _, feature_frame_pool = extractor(os.path.join(path_audio, fn))
        feature_pd_DataFrame = frame_pool_aggregation(feature_frame_pool, fn)
        feature_pd_DataFrame.to_csv(
            os.path.join(path_feature_freesound_statistics,
                         fn.split('.')[0] + '.csv'))
                'lowlevelHopSize': 1024,
                'lowlevelWindowType': 'blackmanharris62',
                'lowlevelSilentFrames': 'noise',
                'lowlevelStats': stats,
                'rhythmMethod': 'degara',
                'rhythmMinTempo': 40,
                'rhythmMaxTempo': 208,
                'rhythmStats': stats,
                'tonalFrameSize': 4096,
                'tonalHopSize': 2048,
                'tonalWindowType': 'blackmanharris62',
                'tonalSilentFrames': 'noise',
                'tonalStats': stats
            }

            features, features_frames = es.FreesoundExtractor(
                **profile)(audio_in)
            file_json = output + ".json"
            es.YamlOutput(filename=file_json, format='json')(features)

            tab_header = []
            tab_value = []

            features_name = sorted(features.descriptorNames())
            for feat in range(0, len(features_name)):
                name_feature = features_name[feat]
                # print(name)
                kind_of_feature = name_feature.split(".")
                # print(type)

                # ALL FEATURES
                # if(kind_of_feature[0] != 'metadata' and