| #!/usr/bin/env python3 | |
| """ | |
| Create a silent placeholder audio file if the actual audio doesn't exist | |
| """ | |
| import os | |
| import numpy as np | |
| import soundfile as sf | |
| def create_placeholder_audio(): | |
| """Create a silent audio file as placeholder""" | |
| audio_file = "audio/Footsteps on Gravel Path Outdoor.mp3" | |
| wav_file = audio_file.replace('.mp3', '.wav') | |
| if not os.path.exists(audio_file) and not os.path.exists(wav_file): | |
| print(f"Creating placeholder audio file at {wav_file}") | |
| # Create 2 seconds of silence at 44.1kHz, stereo | |
| duration = 2 | |
| sample_rate = 44100 | |
| silence = np.zeros((sample_rate * duration, 2), dtype=np.float32) | |
| os.makedirs("audio", exist_ok=True) | |
| sf.write(wav_file, silence, sample_rate) | |
| print(f"β Created placeholder audio: {wav_file}") | |
| else: | |
| print(f"β Audio file already exists") | |
| if __name__ == "__main__": | |
| create_placeholder_audio() | |