Skip to content

Commit

Permalink
BirdNET debug (#370)
Browse files Browse the repository at this point in the history
* 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.

* 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.
  • Loading branch information
tphakala authored Jan 6, 2025
1 parent cb97201 commit ffd5d25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions internal/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/conf/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 19 additions & 11 deletions internal/myaudio/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ffd5d25

Please sign in to comment.