wip
This commit is contained in:
parent
4ce4b5eede
commit
c78ad80aae
1 changed files with 7 additions and 7 deletions
|
@ -8,8 +8,8 @@ import scipy.signal
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
OUTDIR = "chunks_unprocessed"
|
INPUT_DIR = "chunks"
|
||||||
PROCESSED_DIR = "chunks_processed"
|
OUTPUT_DIR = "chunks/processed"
|
||||||
CHUNK_SECONDS = 1
|
CHUNK_SECONDS = 1
|
||||||
TOLERANCE = 1
|
TOLERANCE = 1
|
||||||
OVERTONE_TOLERANCE = TOLERANCE * 2
|
OVERTONE_TOLERANCE = TOLERANCE * 2
|
||||||
|
@ -34,7 +34,7 @@ def detect_event(chunk, samplerate):
|
||||||
return base_energy > THRESHOLD_BASE * total_energy and oct_energy > THRESHOLD_OCT * total_energy
|
return base_energy > THRESHOLD_BASE * total_energy and oct_energy > THRESHOLD_OCT * total_energy
|
||||||
|
|
||||||
def process_chunk(filename):
|
def process_chunk(filename):
|
||||||
input_path = os.path.join(OUTDIR, filename)
|
input_path = os.path.join(INPUT_DIR, filename)
|
||||||
print(f"🔍 Verarbeite {input_path}...")
|
print(f"🔍 Verarbeite {input_path}...")
|
||||||
|
|
||||||
# Frequenzanalyse und Event-Erkennung
|
# Frequenzanalyse und Event-Erkennung
|
||||||
|
@ -58,8 +58,8 @@ def process_chunk(filename):
|
||||||
|
|
||||||
event_time = datetime.now().strftime("%Y%m%d-%H%M%S")
|
event_time = datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||||
base_name = os.path.splitext(filename)[0]
|
base_name = os.path.splitext(filename)[0]
|
||||||
wav_out = os.path.join(PROCESSED_DIR, f"{base_name}_{event_time}.wav")
|
wav_out = os.path.join(OUTPUT_DIR, f"{base_name}_{event_time}.wav")
|
||||||
png_out = os.path.join(PROCESSED_DIR, f"{base_name}_{event_time}.png")
|
png_out = os.path.join(OUTPUT_DIR, f"{base_name}_{event_time}.png")
|
||||||
sf.write(wav_out, clip, samplerate)
|
sf.write(wav_out, clip, samplerate)
|
||||||
|
|
||||||
plt.figure()
|
plt.figure()
|
||||||
|
@ -78,13 +78,13 @@ def process_chunk(filename):
|
||||||
i += chunk_samples
|
i += chunk_samples
|
||||||
|
|
||||||
# Datei verschieben
|
# Datei verschieben
|
||||||
output_path = os.path.join(PROCESSED_DIR, filename)
|
output_path = os.path.join(OUTPUT_DIR, filename)
|
||||||
shutil.move(input_path, output_path)
|
shutil.move(input_path, output_path)
|
||||||
print(f"✅ Verschoben nach {output_path}")
|
print(f"✅ Verschoben nach {output_path}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for filename in os.listdir(OUTDIR):
|
for filename in os.listdir(INPUT_DIR):
|
||||||
if filename.endswith(".flac"):
|
if filename.endswith(".flac"):
|
||||||
process_chunk(filename)
|
process_chunk(filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue