This commit is contained in:
CroneKorkN 2025-06-01 19:40:39 +02:00
parent 3b483805df
commit d804d781c6
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw

View file

@ -99,6 +99,7 @@ def process_recording(filename):
# not detecting an event # not detecting an event
if current_event: if current_event:
duration = (current_event['end_at'] - current_event['start_at']).total_seconds() duration = (current_event['end_at'] - current_event['start_at']).total_seconds()
current_event['duration'] = duration
print(f'🔊 {current_event['start_at'].strftime('%Y-%m-%d %H:%M:%S')} ({duration:.1f}s): {current_event['start_freq']:.1f}Hz->{current_event['end_freq']:.1f}Hz @{current_event['max_amplitude']:.0f}rDB') print(f'🔊 {current_event['start_at'].strftime('%Y-%m-%d %H:%M:%S')} ({duration:.1f}s): {current_event['start_freq']:.1f}Hz->{current_event['end_freq']:.1f}Hz @{current_event['max_amplitude']:.0f}rDB')
write_event(current_event=current_event, sound=sound, samplerate=samplerate) write_event(current_event=current_event, sound=sound, samplerate=samplerate)
@ -124,10 +125,10 @@ def write_event(current_event, sound, samplerate):
# write spectrogram # write spectrogram
plt.figure(figsize=(8, 6)) plt.figure(figsize=(8, 6))
plt.specgram(event_clip, Fs=samplerate, NFFT=samplerate, noverlap=samplerate//2, cmap='inferno', vmin=-100, vmax=-10) plt.specgram(event_clip, Fs=samplerate, NFFT=samplerate, noverlap=samplerate//2, cmap='inferno', vmin=-100, vmax=-10)
plt.title(f"Bootshorn @{event.strftime('%Y-%m-%d %H:%M:%S')}") plt.title(f"Bootshorn @{event.strftime('%Y-%m-%d %H:%M:%S%z')}")
plt.xlabel("Time (s)") plt.xlabel(f"Time {current_event['duration']:.1f}s")
plt.ylabel("Frequency (Hz)") plt.ylabel(f"Frequency {current_event['start_freq']:.1f}Hz -> {current_event['end_freq']:.1f}Hz")
plt.colorbar(label="Intensity (dB)") plt.colorbar(label="Intensity (rDB)")
plt.ylim(50, 1000) plt.ylim(50, 1000)
spectrogram_path = os.path.join(DETECTIONS_DIR, f"{filename_prefix}.png") spectrogram_path = os.path.join(DETECTIONS_DIR, f"{filename_prefix}.png")
plt.savefig(spectrogram_path) plt.savefig(spectrogram_path)