Skip to content

fix(piper_tts): resolve piper next to sys.executable before PATH - #940

Open
gauravchahal20 wants to merge 1 commit into
OpenMontageInc:mainfrom
gauravchahal20:fix/issue-888-piper-venv-resolution
Open

gauravchahal20 wants to merge 1 commit into
OpenMontageInc:mainfrom
gauravchahal20:fix/issue-888-piper-venv-resolution

Conversation

@gauravchahal20

Copy link
Copy Markdown

Summary

Resolves piper next to sys.executable (e.g. .venv/bin or .venv/Scripts) before falling back to PATH, so PiperTTS is detected as AVAILABLE and functions when executing via virtualenv Python without an activated virtualenv environment on PATH.

Related issue

Closes #888

Root Cause

piper installs its CLI script into the virtualenv's binary directory (.venv/bin on POSIX or .venv/Scripts on Windows). When an agent, IDE, or script runs .venv/bin/python without activating the virtualenv, shutil.which("piper") checks only the inherited PATH and fails to locate piper. Consequently, preflight reports tts 0/18 and pipelines requiring local offline TTS are blocked.

Changes

  • Added PiperTTS._find_piper: checks for piper or piper.exe in Path(sys.executable).parent before checking shutil.which("piper").
  • Updated PiperTTS.get_status() to use self._find_piper().
  • Implemented PiperTTS.check_dependencies() to verify binary presence via self._find_piper().
  • Updated PiperTTS._generate() to invoke the resolved executable path.
  • Added unit tests in tests/tools/test_piper_tts.py covering resolution next to sys.executable, fallback to PATH, unavailable handling, and invocation path passing.

Testing

Ran pytest tests/tools/test_piper_tts.py:

  • 10 passed in 0.25s

Ran pytest tests/tools/test_piper_routing_consolidation.py:

  • 6 passed in 0.15s

Checklist

  • The change is focused on a single logical concern.
  • I ran the relevant tests locally (make test-contracts / make test) where applicable.
  • I updated docs/README if behavior or usage changed.
  • No unrelated files (build artifacts, local config) are included in the diff.

When running python from a virtual environment without activating the venv,
piper binary resides in the venv's bin/Scripts directory and is not on PATH.
Resolving piper next to sys.executable before falling back to PATH ensures
PiperTTS reports AVAILABLE and executes successfully.

Fixes OpenMontageInc#888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Piper TTS shows as unavailable unless the virtualenv is activated

1 participant