Skip to content

Commit

Permalink
calculate hop_length dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuus committed Jan 10, 2025
1 parent c139a46 commit 55e0e86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions core/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def __init__(self, device='cuda'):
self.linear_transform = ta.transforms.Spectrogram(
n_fft=2*cfg.audio.win_length,
win_length=cfg.audio.win_length,
hop_length=cfg.audio.hop_length,
hop_length=int(cfg.audio.segment_len * cfg.audio.sampling_rate / cfg.audio.spec_width),
power=1
).to(self.device)

self.mel_transform = ta.transforms.MelSpectrogram(
sample_rate=cfg.audio.sampling_rate,
n_fft=2*cfg.audio.win_length,
win_length=cfg.audio.win_length,
hop_length=cfg.audio.hop_length,
hop_length=int(cfg.audio.segment_len * cfg.audio.sampling_rate / cfg.audio.spec_width),
f_min=cfg.audio.min_audio_freq,
f_max=cfg.audio.max_audio_freq,
n_mels=cfg.audio.spec_height,
Expand Down
7 changes: 0 additions & 7 deletions core/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Audio:
spec_height = 192 # spectrogram height
spec_width = 384 # spectrogram width (3 * 128)
sampling_rate = 37120
hop_length = int(segment_len * sampling_rate /spec_width)
win_length = 2048
min_audio_freq = 200 # need this low for American Bittern
max_audio_freq = 13000 # need this high for Chestnut-backed Chickadee "seet series"
Expand Down Expand Up @@ -102,12 +101,6 @@ class Inference:
confirmed_if_seconds = 8 # need at least this many confirmed seconds >= raised threshold
lower_min_factor = .6 # if so, include all labels with score >= this * min_score

# map our species names to the names used by eBird for location/date processing
ebird_names = {
"American Goshawk": "Northern Goshawk",
"Black-crowned Night Heron": "Black-crowned Night-Heron",
}

# Low/high/band-pass filters can be used during inference and have to be enabled and configured here.
# Inference will then use the max prediction per species, with and without the filter(s).
# Using a single filter adds ~50% to elapsed time for large datasets, but less for small ones where
Expand Down

0 comments on commit 55e0e86

Please sign in to comment.