From 23bf096b0d91d4d6a7bc730317fe16dc654b1548 Mon Sep 17 00:00:00 2001 From: "Tomi P. Hakala" Date: Mon, 6 Jan 2025 10:51:01 +0200 Subject: [PATCH 1/2] feat: add debug flag for BirdNET processing - Introduced a new debug mode option in BirdNETConfig to enable detailed logging during analysis. - Set default value for debug mode to false in the configuration settings. --- internal/conf/config.go | 1 + internal/conf/defaults.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/conf/config.go b/internal/conf/config.go index 7357e95..d48e239 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -194,6 +194,7 @@ type InputConfig struct { } type BirdNETConfig struct { + Debug bool // true to enable debug mode Sensitivity float64 // birdnet analysis sigmoid sensitivity Threshold float64 // threshold for prediction confidence to report Overlap float64 // birdnet analysis overlap between chunks diff --git a/internal/conf/defaults.go b/internal/conf/defaults.go index b1c8489..8d43704 100644 --- a/internal/conf/defaults.go +++ b/internal/conf/defaults.go @@ -21,6 +21,7 @@ func setDefaultConfig() { viper.SetDefault("main.log.rotationday", "Sunday") // BirdNET configuration + viper.SetDefault("birdnet.debug", false) viper.SetDefault("birdnet.sensitivity", 1.0) viper.SetDefault("birdnet.threshold", 0.8) viper.SetDefault("birdnet.overlap", 0.0) From 422186b08244202d211225de23218fbc96b75815 Mon Sep 17 00:00:00 2001 From: "Tomi P. Hakala" Date: Mon, 6 Jan 2025 10:55:12 +0200 Subject: [PATCH 2/2] feat: add BirdNET debug logging for result analysis - Updated the debug logging mechanism in the BirdNET processing function to print all results when debug mode is enabled. --- internal/myaudio/process.go | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/internal/myaudio/process.go b/internal/myaudio/process.go index c3b7070..9441ff4 100644 --- a/internal/myaudio/process.go +++ b/internal/myaudio/process.go @@ -33,18 +33,26 @@ func ProcessData(bn *birdnet.BirdNET, data []byte, startTime time.Time, source s // get elapsed time elapsedTime := time.Since(predictStart) - // Sort results by confidence (descending order) - /*sort.Slice(results, func(i, j int) bool { - return results[i].Confidence > results[j].Confidence - }) - - // DEBUG print species of results with confidence > 0.20 in green - green := color.New(color.FgGreen).SprintfFunc() - for _, result := range results { - if result.Confidence > 0.20 { - fmt.Println(green("%.2f %s", result.Confidence, result.Species)) + // DEBUG print all BirdNET results + if conf.Setting().BirdNET.Debug { + debugThreshold := float32(0) // set to 0 for now, maybe add a config option later + hasHighConfidenceResults := false + for _, result := range results { + if result.Confidence > debugThreshold { + hasHighConfidenceResults = true + break + } } - }*/ + + if hasHighConfidenceResults { + log.Println("[birdnet] results:") + for _, result := range results { + if result.Confidence > debugThreshold { + log.Printf("[birdnet] %.2f %s\n", result.Confidence, result.Species) + } + } + } + } // Get the current settings settings := conf.Setting()