Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BirdNET debug #370

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading