Change default sample rate to 48kHz and add validation

Changes:
- Update default sample rate from 44.1kHz to 48kHz (more professional standard)
- Add sample rate validation in play_sound_file()
- Display clear warning when uploaded file doesn't match configured rate
- Update default sound generation (dial tone & beep) to use configured RATE
- Prevent playback of incompatible sample rates (avoids ALSA errors)

Error Handling:
- Check file sample rate before attempting playback
- Print warning with actual vs expected sample rate
- Return False and skip playback if mismatch detected
- User-friendly error message with resampling instructions

This fixes the "Invalid sample rate" error when playing files with
non-matching sample rates. Users must now resample their audio files
to match the configured rate (default 48kHz).

To resample audio files:
ffmpeg -i input.wav -ar 48000 output.wav

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-27 12:55:13 +07:00
parent fbe9bb2f9a
commit 52b8348a03
2 changed files with 21 additions and 15 deletions

View File

@@ -11,7 +11,7 @@
"chunk_size": 1024,
"format": "paInt16",
"channels": 1,
"sample_rate": 44100,
"sample_rate": 48000,
"max_record_seconds": 300
},
"paths": {