diff --git a/resample_audio.py b/resample_audio.py index 4e3c414..9caac14 100644 --- a/resample_audio.py +++ b/resample_audio.py @@ -8,6 +8,7 @@ import wave import numpy as np import os import json +import shutil from scipy import signal def load_config(): @@ -126,16 +127,20 @@ def main(): # Create backup backup_path = input_path + '.backup' + source_path = input_path + if not os.path.exists(backup_path): - os.rename(input_path, backup_path) + # Copy to backup instead of rename, so original still exists + shutil.copy2(input_path, backup_path) print(f" Backup created: {filename}.backup") + source_path = backup_path else: - input_path = backup_path print(f" Using existing backup") + source_path = backup_path # Resample output_path = os.path.join(sounds_dir, filename) - if resample_wav(input_path, output_path, target_rate): + if resample_wav(source_path, output_path, target_rate): print(f" ✓ Successfully resampled to {target_rate}Hz") else: print(f" ✗ Failed to resample, restoring backup")