Skip to content

Commit

Permalink
filter tracks below 1000
Browse files Browse the repository at this point in the history
  • Loading branch information
gferraro committed Nov 7, 2023
1 parent e84b45d commit b48a1c6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Melt/identify_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ def load_samples(
power=1,
db_scale=False,
filter_freqs=True,
filter_below=None,
):
logging.debug(
"Loading samples with length %s stride %s hop length %s and mean_sub %s mfcc %s break %s htk %s n mels %s fmin %s fmax %s filtering freqs %s",
"Loading samples with length %s stride %s hop length %s and mean_sub %s mfcc %s break %s htk %s n mels %s fmin %s fmax %s filtering freqs %s filter below %s",
segment_length,
stride,
hop_length,
Expand All @@ -73,6 +74,7 @@ def load_samples(
fmin,
fmax,
filter_freqs,
filter_below,
)
mels = []
i = 0
Expand All @@ -97,6 +99,13 @@ def load_samples(
track_frames = butter_bandpass_filter(
track_frames, t.freq_start, t.freq_end, sr
)
elif filter_below and t.freq_end < filter_below:
logging.info(
"Filter freq below %s %s %s", filter_below, t.freq_start, t.freq_end
)
track_frames = butter_bandpass_filter(
track_frames, t.freq_start, t.freq_end, sr
)
while True:
data = track_frames[sr_start:sr_end]
if len(data) != sample_size:
Expand Down Expand Up @@ -323,6 +332,7 @@ def classify(file, models):
for model_file in models:
model, meta = load_model(model_file)
filter_freqs = meta.get("filter_freq", True)
filter_below = meta.get("filter_below", 1000)

labels = meta.get("labels")
multi_label = meta.get("multi_label")
Expand Down Expand Up @@ -366,6 +376,7 @@ def classify(file, models):
power=power,
db_scale=db_scale,
filter_freqs=filter_freqs,
filter_below=filter_below,
)
data = mel_data
if len(data) == 0:
Expand Down

0 comments on commit b48a1c6

Please sign in to comment.