wip
This commit is contained in:
parent
cf5b1396b1
commit
c165442acc
1 changed files with 6 additions and 5 deletions
11
process
11
process
|
@ -23,7 +23,8 @@ DETECTION_DISTANCE_SECONDS = 30 # seconds (minimum time between detections)
|
|||
DETECTION_DISTANCE_BLOCKS = DETECTION_DISTANCE_SECONDS // BLOCK_SECONDS # number of blocks to skip after a detection
|
||||
BLOCK_OVERLAP_FACTOR = 0.9 # overlap between blocks (0.2 means 20% overlap)
|
||||
MIN_SIGNAL_QUALITY = 1000.0 # maximum noise level (relative DB) to consider a detection valid
|
||||
PLOT_PADDING_SECONDS = 2 # seconds (padding before and after the event in the plot)
|
||||
PLOT_PADDING_START_SECONDS = 2 # seconds (padding before and after the event in the plot)
|
||||
PLOT_PADDING_END_SECONDS = 3 # seconds (padding before and after the event in the plot)
|
||||
|
||||
def process_recording(filename):
|
||||
print('processing', filename)
|
||||
|
@ -110,13 +111,13 @@ def process_recording(filename):
|
|||
|
||||
def write_event(current_event, sound, samplerate):
|
||||
# write a spectrogram using the sound from start to end of the event
|
||||
event_start_sample = current_event['start_sample'] - samplerate * PLOT_PADDING_SECONDS
|
||||
event_end_sample = current_event['end_sample'] + samplerate * PLOT_PADDING_SECONDS
|
||||
event_start_sample = current_event['start_sample'] - samplerate * PLOT_PADDING_START_SECONDS
|
||||
event_end_sample = current_event['end_sample'] + samplerate * PLOT_PADDING_END_SECONDS
|
||||
event_clip = sound[event_start_sample:event_end_sample]
|
||||
plot_start_date = current_event['start_at'] - datetime.timedelta(seconds=PLOT_PADDING_SECONDS)
|
||||
event = current_event['start_at'] - datetime.timedelta(seconds=PLOT_PADDING_START_SECONDS)
|
||||
plt.figure(figsize=(8, 6))
|
||||
plt.specgram(event_clip, Fs=samplerate, NFFT=samplerate, noverlap=samplerate//2, cmap='inferno', vmin=-100, vmax=-10)
|
||||
plt.title(f"Bootshorn @{plot_start_date.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
plt.title(f"Bootshorn @{event.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
plt.xlabel("Time (s)")
|
||||
plt.ylabel("Frequency (Hz)")
|
||||
plt.colorbar(label="Intensity (dB)")
|
||||
|
|
Loading…
Reference in a new issue