new alarm mechanism
This commit is contained in:
@@ -12,8 +12,19 @@ CHUNK_SIZE = 4096
|
||||
AUDIO_DIR = Path(__file__).parent / "assets" / "alarm"
|
||||
|
||||
|
||||
def find_wav() -> Path:
|
||||
"""Find the first .wav file in the alarm assets directory."""
|
||||
def find_wav(path: Path | None = None) -> Path:
|
||||
"""Return a WAV file path.
|
||||
|
||||
If *path* is given and points to an existing file, use it directly.
|
||||
Otherwise fall back to the first .wav found in the alarm assets directory.
|
||||
"""
|
||||
if path is not None:
|
||||
p = Path(path)
|
||||
if p.is_file():
|
||||
log.info("Using audio file: %s", p)
|
||||
return p
|
||||
log.warning("Specified audio path not found: %s — falling back to glob", p)
|
||||
|
||||
wavs = list(AUDIO_DIR.glob("*.wav"))
|
||||
if not wavs:
|
||||
raise FileNotFoundError(f"No .wav files found in {AUDIO_DIR}")
|
||||
|
||||
Reference in New Issue
Block a user