wip
This commit is contained in:
parent
788416adb6
commit
f8472f5c4c
1 changed files with 5 additions and 5 deletions
|
@ -15,7 +15,7 @@ EVENT_DIR = "events"
|
|||
SAMPLE_SECONDS = 1
|
||||
TOLERANCE = 2
|
||||
OVERTONE_TOLERANCE = TOLERANCE * 2
|
||||
THRESHOLD_BASE = 0.
|
||||
THRESHOLD_BASE = 0.1
|
||||
THRESHOLD_OCT = THRESHOLD_BASE / 10
|
||||
CLIP_PADDING_BEFORE = 1
|
||||
CLIP_PADDING_AFTER = 6
|
||||
|
@ -72,20 +72,20 @@ def process_chunk(filename):
|
|||
event_time = event_time_dt.strftime("%Y%m%d-%H%M%S")
|
||||
|
||||
base_name = os.path.splitext(filename)[0]
|
||||
flac_out = os.path.join(EVENT_DIR, f"{base_name}_{event_time}.flac")
|
||||
png_out = os.path.join(EVENT_DIR, f"{base_name}_{event_time}.png")
|
||||
flac_out = os.path.join(EVENT_DIR, f"{event_time}.flac")
|
||||
png_out = os.path.join(EVENT_DIR, f"{event_time}.png")
|
||||
sf.write(flac_out, clip, samplerate, format='FLAC')
|
||||
|
||||
plt.figure()
|
||||
plt.specgram(clip, Fs=samplerate, NFFT=NFFT, noverlap=NFFT//2, cmap='inferno', vmin=-90, vmax=-20)
|
||||
plt.title(f"Spectrogram: {base_name}_{event_time}")
|
||||
plt.title(f"Spectrogram: {event_time}")
|
||||
plt.xlabel("Time (s)")
|
||||
plt.ylabel("Frequency (Hz)")
|
||||
plt.colorbar(label="dB")
|
||||
plt.savefig(png_out)
|
||||
plt.close()
|
||||
|
||||
print(f"Event: {event_time} peak_freq: {int(peak_freq)} base_energy: {int(base_energy)} oct_energy: {int(oct_energy)} total_energy: {int(total_energy)}")
|
||||
print(f"Event: {event_time} peak_freq: {peak_freq:.9f} Hz, base_energy: {base_energy:.9f}, oct_energy: {oct_energy:.9f}, total_energy: {total_energy:.9f}")
|
||||
last_event = i
|
||||
i += skip_samples
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue