diff --git a/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs b/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs index d30f540cb..d1d586b2a 100644 --- a/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs +++ b/src/AnalysisPrograms/Recognizers/GenericRecognizer.cs @@ -56,6 +56,11 @@ public override AnalyzerConfig ParseConfig(FileInfo file) // validation of configs can be done here ValidateProfileTagsMatchAlgorithms(result.Profiles, file); + if (result.PostProcessing is null) + { + Log.Warn($"The `{nameof(result.PostProcessing)}` section of the config appears to be empty"); + } + return result; } @@ -143,47 +148,49 @@ public override RecognizerResults Recognize( // ############################### POST-PROCESSING OF GENERIC EVENTS ############################### var postprocessingConfig = configuration.PostProcessing; - var postEvents = new List(); - var groups = results.NewEvents.GroupBy(x => x.DecibelDetectionThreshold); + if (postprocessingConfig is not null) { + var postEvents = new List(); + var groups = results.NewEvents.GroupBy(x => x.DecibelDetectionThreshold); - foreach (var group in groups) - { - var key = group.Key; - List events = group.ToList(); - var ppEvents = EventPostProcessing.PostProcessingOfSpectralEvents( - events, - postprocessingConfig, - key.Value, - results.Sonogram, - segmentStartOffset); - - postEvents.AddRange(ppEvents); - } + foreach (var group in groups) + { + var key = group.Key; + List events = group.ToList(); + var ppEvents = EventPostProcessing.PostProcessingOfSpectralEvents( + events, + postprocessingConfig, + key.Value, + results.Sonogram, + segmentStartOffset); + + postEvents.AddRange(ppEvents); + } - // Running profiles with multiple dB thresholds can produce enclosed/nested events. - // Remove all but the outermost events. - if (configuration.PostProcessing.RemoveEnclosedEvents) - { - Log.Debug($"\nREMOVE ENCLOSED EVENTS."); - Log.Debug($"Event count BEFORE removing enclosed events = {postEvents.Count}."); - results.NewEvents = CompositeEvent.RemoveEnclosedEvents(postEvents); - Log.Debug($"Event count AFTER removing enclosed events = {postEvents.Count}."); - } - else - { - Log.Debug($"\nENCLOSED EVENTS WERE NOT REMOVED - {postEvents.Count} events returned."); - results.NewEvents = postEvents; - } + // Running profiles with multiple dB thresholds can produce enclosed/nested events. + // Remove all but the outermost events. + if (configuration.PostProcessing.RemoveEnclosedEvents) + { + Log.Debug($"\nREMOVE ENCLOSED EVENTS."); + Log.Debug($"Event count BEFORE removing enclosed events = {postEvents.Count}."); + results.NewEvents = CompositeEvent.RemoveEnclosedEvents(postEvents); + Log.Debug($"Event count AFTER removing enclosed events = {postEvents.Count}."); + } + else + { + Log.Debug($"\nENCLOSED EVENTS WERE NOT REMOVED - {postEvents.Count} events returned."); + results.NewEvents = postEvents; + } - // Write out the events to log. - if (postEvents.Count > 0) - { - int counter = 0; - foreach (var ev in postEvents) + // Write out the events to log. + if (postEvents.Count > 0) { - counter++; - var spEvent = (SpectralEvent)ev; - Log.Debug($" Event[{counter}]: Start={spEvent.EventStartSeconds:f1}; End={spEvent.EventEndSeconds:f1}; Duration={spEvent.EventDurationSeconds:f2}; Bandwidth={spEvent.BandWidthHertz} Hz"); + int counter = 0; + foreach (var ev in postEvents) + { + counter++; + var spEvent = (SpectralEvent)ev; + Log.Debug($" Event[{counter}]: Start={spEvent.EventStartSeconds:f1}; End={spEvent.EventEndSeconds:f1}; Duration={spEvent.EventDurationSeconds:f2}; Bandwidth={spEvent.BandWidthHertz} Hz"); + } } } @@ -254,7 +261,8 @@ public static RecognizerResults RunProfiles( NoiseReductionParameter = ac.NoiseReductionParameter, }; - speciesName = "aed"; + // try to give the events are more useful name by dyanmically fetching aa value from the yaml config + speciesName = configuration.GetStringOrNull("SpeciesName") ?? "aed"; var spectrogram = new SpectrogramStandard(config, audioRecording.WavReader); // GET THIS TO RETURN BLOB EVENTS. diff --git a/src/AudioAnalysisTools/Events/Types/EventPostProcessing.cs b/src/AudioAnalysisTools/Events/Types/EventPostProcessing.cs index 2068d51cc..79f4e83f0 100644 --- a/src/AudioAnalysisTools/Events/Types/EventPostProcessing.cs +++ b/src/AudioAnalysisTools/Events/Types/EventPostProcessing.cs @@ -261,7 +261,11 @@ public class SidebandConfig /// public class SyllableSequenceConfig { - // ################ The first two properties concern the combining of syllables into a sequence or stroph. + + /// + /// Gets or sets a value indicating Whether or not to combine events that constitute a sequence of the same strophe. + /// + public bool CombinePossibleSyllableSequence { get; set; } /// /// Gets or sets a value indicating the maximum allowable start time gap (seconds) between events within the same strophe.