Test Structure Reorganization and CI Improvements (#5)

* Add GitHub Actions CI/CD workflows and status badges

* Fix CI workflow dependency installation

* Fix CI workflow: remove pip caching and add explicit requirements.txt

* Fix CI workflow: add system dependencies for PyGObject and pycairo

* Refactor code for improved readability and consistency

- Cleaned up whitespace and formatting in audio_feedback.py, config_manager.py, keyboard_shortcuts.py, tray_indicator.py, run_basic_tests.py, and test_basic.py.
- Enhanced the structure of the code by aligning comments and ensuring consistent indentation.
- Updated function definitions and calls to maintain a uniform style across the codebase.
- Improved logging messages for better clarity during debugging.
- Ensured all files end with a newline for better compatibility with various tools.

* Refactor imports for consistency and clarity across multiple modules

* Fix test imports by setting PYTHONPATH and adding conftest.py

* Update CI workflow to use Python 3.12 and ensure proper import path in tests

* Fix CI: Add GObject Introspection development dependencies

* Update CI: Use virtual environment like local setup

* Fix CI

* Update README and setup.py: Change Python version to 3.8 and correct author email

* Restructure tests for better organization and maintainability

* Fix formatting

* Update CI workflow to remove redundant test step

* Fix CI tests by properly mocking VOSK model loading

* Update CI and Tests

* Simplify
This commit is contained in:
Jatin K Malik
2025-04-16 20:23:40 -05:00
committed by GitHub
parent 7590332598
commit 3645c692fd
20 changed files with 996 additions and 682 deletions
+31 -23
View File
@@ -6,8 +6,8 @@ This module provides audio feedback for various recognition states.
import logging
import os
import subprocess
import shutil
import subprocess
from pathlib import Path
logger = logging.getLogger(__name__)
@@ -27,22 +27,22 @@ ERROR_SOUND = os.path.join(SOUNDS_DIR, "error.wav")
def _get_audio_player():
"""
Determine the best available audio player on the system.
Returns:
tuple: (player_command, format_supported)
"""
# Check for PulseAudio paplay (preferred)
if shutil.which("paplay"):
return "paplay", ["wav"]
# Check for ALSA aplay
if shutil.which("aplay"):
return "aplay", ["wav"]
# Check for play (from SoX)
if shutil.which("play"):
return "play", ["wav"]
# Check for mplayer
if shutil.which("mplayer"):
return "mplayer", ["wav"]
@@ -55,40 +55,48 @@ def _get_audio_player():
def _play_sound_file(sound_path):
"""
Play a sound file using the best available player.
Args:
sound_path: Path to the sound file
"""
if not os.path.exists(sound_path):
logger.warning(f"Sound file not found: {sound_path}")
return False
player, formats = _get_audio_player()
if not player:
return False
file_ext = os.path.splitext(sound_path)[1].lower().lstrip('.')
file_ext = os.path.splitext(sound_path)[1].lower().lstrip(".")
if file_ext not in formats:
logger.warning(f"Format {file_ext} not supported by {player}")
return False
try:
if player == "paplay":
subprocess.Popen([player, sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
subprocess.Popen(
[player, sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
elif player == "aplay":
subprocess.Popen([player, "-q", sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
subprocess.Popen(
[player, "-q", sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
elif player == "mplayer":
subprocess.Popen([player, "-really-quiet", sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
subprocess.Popen(
[player, "-really-quiet", sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
elif player == "play":
subprocess.Popen([player, "-q", sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
subprocess.Popen(
[player, "-q", sound_path],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
return True
except Exception as e:
logger.error(f"Failed to play sound {sound_path}: {e}")
@@ -107,4 +115,4 @@ def play_stop_sound():
def play_error_sound():
"""Play the sound for error notifications."""
_play_sound_file(ERROR_SOUND)
_play_sound_file(ERROR_SOUND)