Skip to content

Commit 43b6301

Browse files
committed
chore: removes and tidies
1 parent 0ab841f commit 43b6301

File tree

2 files changed

+24
-76
lines changed

2 files changed

+24
-76
lines changed

lib/src/audio_manager.py

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -56,56 +56,10 @@ def __init__(self, config_manager=None):
5656
if not self.assets_dir.exists():
5757
self.assets_dir = Path(__file__).parent.parent / "assets"
5858

59-
# Start sound path resolution
60-
if self.start_sound_path:
61-
# Try the path as-is first (for absolute paths)
62-
start_path = Path(self.start_sound_path)
63-
if start_path.exists():
64-
self.start_sound = start_path
65-
else:
66-
# Try relative to assets directory (for relative paths like "ping-up.ogg")
67-
start_path = self.assets_dir / self.start_sound_path
68-
if start_path.exists():
69-
self.start_sound = start_path
70-
else:
71-
# Fall back to default
72-
self.start_sound = self.assets_dir / "ping-up.ogg"
73-
else:
74-
self.start_sound = self.assets_dir / "ping-up.ogg"
75-
76-
# Stop sound path resolution
77-
if self.stop_sound_path:
78-
# Try the path as-is first (for absolute paths)
79-
stop_path = Path(self.stop_sound_path)
80-
if stop_path.exists():
81-
self.stop_sound = stop_path
82-
else:
83-
# Try relative to assets directory (for relative paths like "ping-down.ogg")
84-
stop_path = self.assets_dir / self.stop_sound_path
85-
if stop_path.exists():
86-
self.stop_sound = stop_path
87-
else:
88-
# Fall back to default
89-
self.stop_sound = self.assets_dir / "ping-down.ogg"
90-
else:
91-
self.stop_sound = self.assets_dir / "ping-down.ogg"
92-
93-
# Error sound path resolution
94-
if self.error_sound_path:
95-
# Try the path as-is first (for absolute paths)
96-
error_path = Path(self.error_sound_path)
97-
if error_path.exists():
98-
self.error_sound = error_path
99-
else:
100-
# Try relative to assets directory (for relative paths like "ping-error.ogg")
101-
error_path = self.assets_dir / self.error_sound_path
102-
if error_path.exists():
103-
self.error_sound = error_path
104-
else:
105-
# Fall back to default
106-
self.error_sound = self.assets_dir / "ping-error.ogg"
107-
else:
108-
self.error_sound = self.assets_dir / "ping-error.ogg"
59+
# Resolve sound paths (custom path -> relative to assets -> default)
60+
self.start_sound = self._resolve_sound_path(self.start_sound_path, "ping-up.ogg")
61+
self.stop_sound = self._resolve_sound_path(self.stop_sound_path, "ping-down.ogg")
62+
self.error_sound = self._resolve_sound_path(self.error_sound_path, "ping-error.ogg")
10963

11064
# Check if audio files exist
11165
self.start_sound_available = self.start_sound.exists()
@@ -127,11 +81,29 @@ def _validate_volume(self, volume: float) -> float:
12781
volume = float(volume)
12882
except (ValueError, TypeError):
12983
volume = 0.3
130-
84+
13185
# Clamp between 0.1 (10%) and 1.0 (100%)
13286
volume = max(0.1, min(volume, 1.0))
13387
return volume
134-
88+
89+
def _resolve_sound_path(self, custom_path: Optional[str], default_filename: str) -> Path:
90+
"""
91+
Resolve a sound file path with fallback logic.
92+
93+
Tries: custom_path as-is -> custom_path relative to assets -> default
94+
"""
95+
if custom_path:
96+
# Try as absolute path first
97+
path = Path(custom_path)
98+
if path.exists():
99+
return path
100+
# Try relative to assets directory
101+
path = self.assets_dir / custom_path
102+
if path.exists():
103+
return path
104+
# Fall back to default
105+
return self.assets_dir / default_filename
106+
135107
def _play_sound(self, sound_file: Path, volume: float = None) -> bool:
136108
"""
137109
Play an audio file with volume control

lib/src/cli_commands.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,30 +2694,6 @@ def setup_permissions():
26942694
log_warning("You may need to log out/in for new group memberships to apply")
26952695

26962696

2697-
# ==================== Validate Command ====================
2698-
2699-
def cleanup_venv_command():
2700-
"""Remove the venv directory completely"""
2701-
if not VENV_DIR.exists():
2702-
log_info("No venv found")
2703-
return True
2704-
2705-
log_warning("This will remove the entire Python virtual environment.")
2706-
log_warning("All installed packages (including pywhispercpp) will be deleted.")
2707-
if not Confirm.ask("Are you sure?", default=False):
2708-
log_info("Cleanup cancelled")
2709-
return False
2710-
2711-
try:
2712-
import shutil
2713-
shutil.rmtree(VENV_DIR)
2714-
log_success("Venv removed successfully")
2715-
return True
2716-
except Exception as e:
2717-
log_error(f"Failed to remove venv: {e}")
2718-
return False
2719-
2720-
27212697
# ==================== Backend Management Commands ====================
27222698

27232699
def backend_repair_command():

0 commit comments

Comments
 (0)