def computeLowLevel(input_file, pool, startTime, endTime, namespace=''): llspace = 'lowlevel.' rhythmspace = 'rhythm.' if namespace: llspace = namespace + '.lowlevel.' rhythmspace = namespace + '.rhythm.' rgain, sampleRate, downmix = getAnalysisMetadata(pool) loader = streaming.EqloudLoader(filename=input_file, sampleRate=sampleRate, startTime=startTime, endTime=endTime, replayGain=rgain, downmix=downmix) lowlevel.compute(loader.audio, loader.audio, pool, startTime, endTime, namespace) essentia.run(loader) # check if we processed enough audio for it to be useful, in particular did # we manage to get an estimation for the loudness (2 seconds required) if not pool.containsKey(llspace + "loudness"): INFO('ERROR: File is too short (< 2sec)... Aborting...') sys.exit(2) numOnsets = len(pool[rhythmspace + 'onset_times']) sampleRate = pool['metadata.audio_properties.analysis_sample_rate'] onset_rate = numOnsets / float(loader.audio.totalProduced()) * sampleRate pool.set(rhythmspace + 'onset_rate', onset_rate)
def computeLowLevel(input_file, pool, startTime, endTime, namespace=''): llspace = 'lowlevel.' rhythmspace = 'rhythm.' if namespace : llspace = namespace + '.lowlevel.' rhythmspace = namespace + '.rhythm.' rgain, sampleRate, downmix = getAnalysisMetadata(pool) loader = streaming.EqloudLoader(filename = input_file, sampleRate = sampleRate, startTime = startTime, endTime = endTime, replayGain = rgain, downmix = downmix) lowlevel.compute(loader.audio, loader.audio, pool, startTime, endTime, namespace) essentia.run(loader) # check if we processed enough audio for it to be useful, in particular did # we manage to get an estimation for the loudness (2 seconds required) if not pool.containsKey(llspace + "loudness"): INFO('ERROR: File is too short (< 2sec)... Aborting...') sys.exit(2) numOnsets = len(pool[rhythmspace + 'onset_times']) sampleRate = pool['metadata.audio_properties.analysis_sample_rate'] onset_rate = numOnsets/float(loader.audio.totalProduced())*sampleRate pool.set(rhythmspace + 'onset_rate', onset_rate)
def reComputeDescriptors(inputAudioFile, outputJsonFile): """ :param inputAudioFile: :param outputJsonFile: :return: """ M = 2048 N = 2048 H = 1024 fs = 44100 W = 'blackmanharris62' # analysis parameters options = {} options['sampleRate'] = fs options['frameSize'] = M options['hopSize'] = H options['windowType'] = W options['skipSilence'] = True audio = ess.MonoLoader(filename=inputAudioFile, sampleRate=fs)() pool = es.Pool() sfx.compute(audio, pool, options) esx.compute(audio, pool, options) #output = ess.YamlOutput(filename='joeTestOut/essExtract_Pool.json', format='json') #output(pool) #calc_Mean_Var = ess.PoolAggregator(defaultStats=['mean', 'var']) calc_Mean_Var = ess.PoolAggregator(defaultStats=['mean']) aggrPool = calc_Mean_Var(pool) #output = ess.YamlOutput(filename='joeTestOut/essExtract_AggrPool.json', format='json') #output = ess.YamlOutput(filename=outputJsonFile, format='json') #output(aggrPool) features = makeFeatures(aggrPool) json.dump(features, open(outputJsonFile, 'w'))
def computeLowLevel(input_file, neqPool, eqPool, startTime, endTime, namespace=""): llspace = "lowlevel." rhythmspace = "rhythm." if namespace: llspace = namespace + ".lowlevel." rhythmspace = namespace + ".rhythm." rgain, sampleRate, downmix = getAnalysisMetadata(neqPool) loader = streaming.EasyLoader( filename=input_file, sampleRate=sampleRate, startTime=startTime, endTime=endTime, replayGain=rgain, downmix=downmix, ) eqloud = streaming.EqualLoudness() loader.audio >> eqloud.signal lowlevel.compute(eqloud.signal, loader.audio, neqPool, startTime, endTime, namespace) lowlevel.compute(eqloud.signal, eqloud.signal, eqPool, startTime, endTime, namespace) essentia.run(loader) # check if we processed enough audio for it to be useful, in particular did # we manage to get an estimation for the loudness (2 seconds required) if not neqPool.containsKey(llspace + "loudness") and not eqPool.containsKey(llspace + "loudness"): INFO("ERROR: File is too short (< 2sec)... Aborting...") sys.exit(2) sampleRate = neqPool["metadata.audio_properties.analysis_sample_rate"] numOnsets = len(neqPool[rhythmspace + "onset_times"]) onset_rate = numOnsets / float(loader.audio.totalProduced()) * sampleRate neqPool.set(rhythmspace + "onset_rate", onset_rate) numOnsets = len(eqPool[rhythmspace + "onset_times"]) onset_rate = numOnsets / float(loader.audio.totalProduced()) * sampleRate eqPool.set(rhythmspace + "onset_rate", onset_rate)
opts, args = parse_args() if len(args) != 2: sys.exit(1) cmd = './'+os.path.basename(sys.argv[0])+ ' -h' os.system(cmd) sys.exit(1) startTime = float(opts.startTime) endTime=float(opts.endTime) pool = essentia.Pool() readMetadata(args[0], pool) rgain, sampleRate, downmix = getAnalysisMetadata(pool) loader = streaming.EqloudLoader(filename = filename, sampleRate = sampleRate, startTime = startTime, endTime = endTime, replayGain = rgain, downmix = downmix) replaygain.compute(source, pool, startTime, endTime) lowlevel.compute(source, pool, startTime, endTime, sampleRate=analysisSampleRate) compute(source, pool, startTime, endTime, sampleRate=analysisSampleRate) stats = ['mean', 'var', 'min', 'max', 'dmean', 'dmean2', 'dvar', 'dvar2'] poolStats = essentia.standard.PoolAggregator(defaultStats=stats)(pool) essentia.standard.YamlOutput(filename=args[1])(poolStats)
if len(args) != 2: sys.exit(1) cmd = './' + os.path.basename(sys.argv[0]) + ' -h' os.system(cmd) sys.exit(1) startTime = float(opts.startTime) endTime = float(opts.endTime) pool = essentia.Pool() readMetadata(args[0], pool) rgain, sampleRate, downmix = getAnalysisMetadata(pool) loader = streaming.EqloudLoader(filename=filename, sampleRate=sampleRate, startTime=startTime, endTime=endTime, replayGain=rgain, downmix=downmix) replaygain.compute(source, pool, startTime, endTime) lowlevel.compute(source, pool, startTime, endTime, sampleRate=analysisSampleRate) compute(source, pool, startTime, endTime, sampleRate=analysisSampleRate) stats = ['mean', 'var', 'min', 'max', 'dmean', 'dmean2', 'dvar', 'dvar2'] poolStats = essentia.standard.PoolAggregator(defaultStats=stats)(pool) essentia.standard.YamlOutput(filename=args[1])(poolStats)