From 9fd0e707f0f8d5ea51253e28024d25de6a2f9154 Mon Sep 17 00:00:00 2001 From: space Date: Sun, 24 May 2026 12:43:03 +0200 Subject: [PATCH] Flatten package layout and add Gitea CI --- .gitea/workflows/ci.yml | 62 +++++++++++++++++++ README.md | 33 ++++++++-- backend/README.md | 7 +++ backend/pyproject.toml | 6 -- .../whisper_remote_backend/__init__.py | 0 .../whisper_remote_backend/server.py | 0 cli/README.md | 11 +++- cli/pyproject.toml | 6 -- cli/tests/conftest.py | 11 ---- cli/{src => }/whisper_remote_cli/__init__.py | 0 cli/{src => }/whisper_remote_cli/main.py | 0 11 files changed, 108 insertions(+), 28 deletions(-) create mode 100644 .gitea/workflows/ci.yml rename backend/{src => }/whisper_remote_backend/__init__.py (100%) rename backend/{src => }/whisper_remote_backend/server.py (100%) delete mode 100644 cli/tests/conftest.py rename cli/{src => }/whisper_remote_cli/__init__.py (100%) rename cli/{src => }/whisper_remote_cli/main.py (100%) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..f78adb9 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + backend: + name: Backend + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: https://github.com/actions/checkout@v4 + + - name: Set up Python + uses: https://github.com/actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install backend dependencies + working-directory: backend + run: | + python -m pip install --upgrade pip + python -m pip install -e .[dev] + python -m pip install build + + - name: Test backend + working-directory: backend + run: python -m pytest + + - name: Build backend package + working-directory: backend + run: python -m build + + cli: + name: CLI + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: https://github.com/actions/checkout@v4 + + - name: Set up Python + uses: https://github.com/actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install CLI dependencies + working-directory: cli + run: | + python -m pip install --upgrade pip + python -m pip install -e .[dev] + python -m pip install build + + - name: Test CLI + working-directory: cli + run: python -m pytest + + - name: Build CLI package + working-directory: cli + run: python -m build diff --git a/README.md b/README.md index 53e360a..fc5d902 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # whisper-remote -Two separate Python packages live in this repo: +A split repo for running the upstream `openai/whisper` CLI remotely. + +Two separate Python packages live here: - `backend/`: FastAPI wrapper around the upstream `whisper` CLI - `cli/`: local `whisper-remote` command that forwards work to the remote API -## Backend +The repo also includes a Gitea Actions workflow at `.gitea/workflows/ci.yml` that tests and builds both packages on pushes to `main` and pull requests. + +## Backend setup ```bash cd backend @@ -15,13 +19,34 @@ uvicorn whisper_remote_backend.server:app --host 0.0.0.0 --port 8000 The backend machine must already have the upstream `whisper` CLI available on `PATH`. -## CLI +## CLI setup ```bash cd cli pip install -e . +whisper-remote ./audio.mp3 --model base --language en --output-format txt +``` + +PowerShell: + +```powershell +$env:WHISPER_REMOTE = "http://your-server:8000" +whisper-remote .\audio.mp3 --model base --language en --output-format txt +``` + +Bash: + +```bash export WHISPER_REMOTE=http://your-server:8000 whisper-remote ./audio.mp3 --model base --language en --output-format txt ``` -By default the CLI prints the transcript to stdout. Use `--to-file` to save the returned transcript locally. +## Supported v1 options + +- model selection +- language forwarding +- transcript output formats: `txt`, `vtt`, `srt`, `tsv`, `json` +- file upload to the backend +- backend-side cleanup of uploaded and generated files after each request + +By default the CLI prints the returned transcript to stdout. Use `--to-file` to save it locally. diff --git a/backend/README.md b/backend/README.md index 574906e..4f1ef14 100644 --- a/backend/README.md +++ b/backend/README.md @@ -2,6 +2,8 @@ FastAPI wrapper around the upstream `whisper` CLI from `openai/whisper`. +Package layout is flat in this folder: `whisper_remote_backend/server.py`. + ## Run ```bash @@ -21,3 +23,8 @@ Multipart form fields: - `output_format`: `txt`, `vtt`, `srt`, `tsv`, or `json` The response body is the transcript artifact itself. The backend deletes the uploaded file and generated output after each request. + +## Notes + +- The backend host must already have the upstream `whisper` command on `PATH`. +- The included Gitea Actions workflow runs backend tests and package builds automatically. diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 263cffa..de51e81 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -22,9 +22,3 @@ dev = [ "httpx>=0.28.0,<1.0.0", "pytest>=8.3.0,<9.0.0", ] - -[tool.setuptools] -package-dir = {"" = "src"} - -[tool.setuptools.packages.find] -where = ["src"] diff --git a/backend/src/whisper_remote_backend/__init__.py b/backend/whisper_remote_backend/__init__.py similarity index 100% rename from backend/src/whisper_remote_backend/__init__.py rename to backend/whisper_remote_backend/__init__.py diff --git a/backend/src/whisper_remote_backend/server.py b/backend/whisper_remote_backend/server.py similarity index 100% rename from backend/src/whisper_remote_backend/server.py rename to backend/whisper_remote_backend/server.py diff --git a/cli/README.md b/cli/README.md index 6b3b894..ea8549a 100644 --- a/cli/README.md +++ b/cli/README.md @@ -2,6 +2,8 @@ Local CLI that forwards media files to a remote `whisper-remote-backend` server. +Package layout is flat in this folder: `whisper_remote_cli/main.py`. + ## Run ```bash @@ -10,4 +12,11 @@ export WHISPER_REMOTE=http://127.0.0.1:8000 whisper-remote ./audio.mp3 --model base --language en --output-format txt ``` -Use `--to-file` to save the returned transcript locally. +PowerShell: + +```powershell +$env:WHISPER_REMOTE = "http://127.0.0.1:8000" +whisper-remote .\audio.mp3 --model base --language en --output-format txt +``` + +Use `--to-file` to save the returned transcript locally. Without it, the CLI prints the transcript body to stdout. diff --git a/cli/pyproject.toml b/cli/pyproject.toml index 14ec2e6..fb3fe04 100644 --- a/cli/pyproject.toml +++ b/cli/pyproject.toml @@ -19,9 +19,3 @@ dev = [ [project.scripts] whisper-remote = "whisper_remote_cli.main:main" - -[tool.setuptools] -package-dir = {"" = "src"} - -[tool.setuptools.packages.find] -where = ["src"] diff --git a/cli/tests/conftest.py b/cli/tests/conftest.py deleted file mode 100644 index df150dc..0000000 --- a/cli/tests/conftest.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import annotations - -import sys -from pathlib import Path - - -ROOT = Path(__file__).resolve().parents[1] -SRC = ROOT / "src" - -if str(SRC) not in sys.path: - sys.path.insert(0, str(SRC)) diff --git a/cli/src/whisper_remote_cli/__init__.py b/cli/whisper_remote_cli/__init__.py similarity index 100% rename from cli/src/whisper_remote_cli/__init__.py rename to cli/whisper_remote_cli/__init__.py diff --git a/cli/src/whisper_remote_cli/main.py b/cli/whisper_remote_cli/main.py similarity index 100% rename from cli/src/whisper_remote_cli/main.py rename to cli/whisper_remote_cli/main.py