Add voice management tool bin/voice_tool.py and dynamic voice switching system

This commit is contained in:
Adolfo Reyna
2026-08-07 20:16:35 -04:00
parent 87b54ce8f4
commit 351b87beb8
3 changed files with 168 additions and 5 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""CLI helper to list and set voices for OpenCode and Claude tools."""
import sys
from pathlib import Path
# Add project root to sys.path
here = Path(__file__).parent.parent
if str(here) not in sys.path:
sys.path.insert(0, str(here))
from voice_manager import KOKORO_VOICES, MACOS_VOICES, VoiceManager
def main():
workspace = Path.home() / "Workspace"
vm = VoiceManager(workspace)
if len(sys.argv) < 2 or sys.argv[1] in ("list", "ls", "--list"):
print("Available Voices:\n")
print("Kokoro Voices (On-Device Neural Speech):")
for k, v in KOKORO_VOICES.items():
active = " (ACTIVE)" if k == vm._active_voice else ""
print(f" - {k}: {v}{active}")
print("\nmacOS System Voices:")
for k, v in MACOS_VOICES.items():
active = " (ACTIVE)" if k == vm._active_voice else ""
print(f" - {k}: {v}{active}")
return
action = sys.argv[1]
if action in ("set", "change") and len(sys.argv) >= 3:
target_voice = sys.argv[2]
ok, msg = vm.apply_voice(target_voice)
print(msg)
else:
# Treat single argument as target voice
target_voice = sys.argv[1]
ok, msg = vm.apply_voice(target_voice)
print(msg)
if __name__ == "__main__":
main()