Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/kahst/BirdNET-Analyzer into…
Browse files Browse the repository at this point in the history
… main
  • Loading branch information
kahst committed Oct 20, 2023
2 parents 6f41ec0 + ff50ed3 commit 865aac5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def saveResultFile(r: dict[str, list], path: str, afile_path: str):
# Write header
out_string += header

# Read native sample rate
high_freq = audio.get_sample_rate(afile_path) / 2

if high_freq > cfg.SIG_FMAX:
high_freq = cfg.SIG_FMAX

# Extract valid predictions for every timestamp
for timestamp in getSortedTimestamps(r):
rstring = ""
Expand All @@ -65,8 +71,8 @@ def saveResultFile(r: dict[str, list], path: str, afile_path: str):
selection_id,
start,
end,
150,
15000,
cfg.SIG_FMIN,
high_freq,
cfg.CODES[c[0]] if c[0] in cfg.CODES else c[0],
label.split("_", 1)[-1],
c[1],
Expand Down
5 changes: 5 additions & 0 deletions audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def openAudioFile(path: str, sample_rate=48000, offset=0.0, duration=None):
return sig, rate


def get_sample_rate(path: str):
import librosa
return librosa.get_samplerate(path)


def saveSignal(sig, fname: str):
"""Saves a signal to file.
Expand Down

0 comments on commit 865aac5

Please sign in to comment.