Skip to content

feat(cli): unified speaches cli for server and client, uvx now optional#449

Open
ahundt wants to merge 8 commits intospeaches-ai:masterfrom
ahundt:cli-simplified
Open

feat(cli): unified speaches cli for server and client, uvx now optional#449
ahundt wants to merge 8 commits intospeaches-ai:masterfrom
ahundt:cli-simplified

Conversation

@ahundt
Copy link
Copy Markdown
Contributor

@ahundt ahundt commented Jun 27, 2025

Unified speaches Command Line Interface Motivation

This PR unifies the server and client tools into a single, cohesive speaches command-line interface. uvx and uvicorn are now optional and they continue to work. This makes speaches easier to use and easier to integrate into other workflows.

Key Changes

  • Executable Entry Point: The pyproject.toml now creates a single speaches executable via [project.scripts].
    • The use of uvx and directly running uvicorn are now optional steps that remain supported.
  • New serve Command: The primary way to run the application is now speaches serve. This command handles all server startup logic internally.
  • Integrated Client Commands: The separate speaches-cli package has been removed, and its commands (e.g., model ls, registry download) are now available as sub-commands of the main speaches executable.
  • Robust Configuration: config.py has been refactored to ensure predictable host/port resolution while maintaining 100% backwards compatibility with UVICORN_HOST/PORT environment variables.
  • Modernized Lifespan Management: The FastAPI app in main.py now uses the standard lifespan context manager for startup and shutdown events.

New Workflow

git clone https://github.com/speaches-ai/speaches.git
cd speaches
uv venv
source .venv/bin/activate
uv sync --all-extras --upgrade
uv tool install .

# Downloading a Text To Speech (TTS) model:
uvx speaches model download speaches-ai/Kokoro-82M-v1.0-ONNX

# Downloading a Speech To Text (STT) model:
uvx speaches model download Systran/faster-distil-whisper-small.en

# run the speaches server then open http://localhost:8000 in your web browser to try speaches
speaches serve --host 0.0.0.0 --port 8000

note uvx is now optional.

ahundt added 8 commits June 26, 2025 00:57
- Add info-level logging of available ONNX Runtime providers in Kokoro and Piper model managers to aid debugging.
- Introduce a custom `APIProxyError` and global FastAPI handler for chat proxy failures, returning structured JSON errors with error IDs, hints, and optional debug info.
- Validate audio file presence early in Gradio UI and STT tab handlers, raising clear exceptions if missing.
- Log the Gradio UI access URL at startup for user convenience.
- Added a detailed docstring and clarified parameter order for `APIProxyError`.
- Updated type annotations for clarity and maintainability.
- Default error suggestions are now more concrete and actionable for users and developers.
- Switched to a timezone-aware ISO 8601 timestamp for error traceability.
- No changes outside error handling and error message formatting.
This commit unifies the server and client into a single `speaches` executable to create a more intuitive user experience, similar to tools like `ollama`.

Key Changes:

- **Renamed `speaches` cli command:** The `speaches-cli` CLI command is now simply `speaches`.
- **New `speaches serve` command:** The `speaches` CLI now includes a `serve` command as the primary entry point for running the FastAPI server.
- **Client Integration:** All commands from the former `speaches-cli` (e.g., `model ls`, `registry ls`) are now sub-commands of the main `speaches` executable.
- **Unified Packaging:**
  - The `packages/speaches-cli` directory has been removed.
  - Dependencies are consolidated into the root `pyproject.toml`.
  - A `[project.scripts]` entry now creates the `speaches` executable.
- **Robust Config Resolution:** `config.py` is updated to resolve host/port with a clear precedence (`SPEACHES_*` > `UVICORN_*` > default), ensuring backwards compatibility.
- **Modernized App Lifecycle:** `main.py` now uses the `lifespan` context manager for startup logic, replacing the deprecated `@on_event` decorator.

The direct `uvicorn speaches.main:create_app` command remains fully functional.
@ahundt ahundt changed the title feat(cli): unified speaches cli for server speaches serve and client speaches model ls; uvx now optional feat(cli): unified speaches cli for server and client; uvx now optional Jun 27, 2025
@ahundt ahundt changed the title feat(cli): unified speaches cli for server and client; uvx now optional feat(cli): unified speaches cli for server and client, uvx now optional Jun 27, 2025
@fedirz
Copy link
Copy Markdown
Collaborator

fedirz commented Jul 6, 2025

Hey, I think it's a good idea to have uv speaches serve command as an alternative way of running speaches. I like that the CLI mimics that of ollama. However, I do see some problems with the implementation:

  • Adding speeches_ is a breaking change. Overall, I think it's a better idea to have a prefix than not, but I don't want to introduce this change ATM.
  • A lot more dependencies were added to the main group. The project is already a bit bloated, and IMO, it's better to continue having multiple optional dependency groups so that people could rebuild speaches without some dependency groups being installed and get a smaller image

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.

2 participants