Skip to content

Commit 6e7aa08

Browse files
Pin transformers dependency, deduplicate TranscriptionError logic, and update installation instructions.
1 parent 25fa6a8 commit 6e7aa08

5 files changed

Lines changed: 117 additions & 132 deletions

File tree

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ install: ## Install production dependencies (excludes whisperx — see install-w
1515
install-dev: ## Install development dependencies (excludes whisperx — see install-whisperx)
1616
uv sync --extra dev
1717

18-
install-whisperx: ## Install whisperx separately (must run after install or install-dev)
19-
uv pip install --no-deps "whisperx @ git+https://github.com/m-bain/whisperX.git@v3.1.1"
18+
install-whisperx: ## Install whisperx and its runtime deps separately (must run after install or install-dev)
19+
uv pip install --no-deps "whisperx @ git+https://github.com/m-bain/whisperX.git@741ab9a2a8a1076c171e785363b23c55a91ceff1"
20+
uv pip install "av==16.1.0" "ctranslate2==4.7.1" "faster-whisper==1.2.1" "flatbuffers==25.12.19" "nltk==3.9.2" "onnxruntime==1.24.1"
2021

2122
test: ## Run unit tests (no GPU required)
2223
uv run python -m pytest tests/ -m "not integration"
@@ -66,7 +67,10 @@ ci: install-dev all-checks ## Run CI pipeline (install deps + all checks)
6667
@echo ""
6768
@echo "CI pipeline completed successfully!"
6869

69-
dev-setup: install-dev install-whisperx pre-commit-install ## Complete development setup (installs all deps including whisperx + hooks)
70+
install-torch-cuda: ## Reinstall PyTorch with CUDA 12.1 wheels (run after uv sync, which pulls CPU-only builds)
71+
uv pip install torch==2.1.2+cu121 torchaudio==2.1.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121
72+
73+
dev-setup: install-dev install-whisperx install-torch-cuda pre-commit-install ## Complete development setup (installs all deps including whisperx + hooks)
7074
@echo ""
7175
@echo "Development environment setup complete!"
7276
@echo ""

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ GPU-accelerated audio processing pipeline: vocal separation (Demucs), speaker di
99
uv venv --python 3.11.14
1010
source .venv/bin/activate
1111

12-
# Install PyTorch first (CUDA 12.1 wheel — adjust for your CUDA version)
13-
uv pip install torch==2.1.2 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121
12+
# Install all deps (uv sync, whisperx, CUDA torch wheels, pre-commit hooks)
13+
make dev-setup
1414

15-
# Install whisperx in isolation to avoid ctranslate2/torch version conflicts
16-
uv pip install "setuptools<74"
17-
uv pip install --no-deps --no-build-isolation "whisperx @ git+https://github.com/m-bain/whisperX.git@v3.1.1"
18-
# whisperx runtime deps (transformers must be <4.42 — newer versions require torch>=2.4)
19-
uv pip install "ctranslate2>=4.0" "faster-whisper>=1.0.0" "transformers>=4.35.0,<4.42.0" nltk
15+
# Copy the env template and add your HuggingFace token
16+
cp .env.example .env
17+
# Edit .env and set HF_TOKEN=hf_your_token_here
2018

21-
# Install the package and remaining deps
22-
uv pip install -e .
23-
uv pip install pytest pytest-mock # for development
19+
# Verify the install
20+
make test
21+
audio-refinery --help
2422
```
2523

24+
> **CUDA note:** `uv sync` resolves torch from PyPI and installs the CPU build. `make dev-setup` automatically reinstalls `torch==2.1.2+cu121` and `torchaudio==2.1.2+cu121` (CUDA 12.1) as its final step. If your system uses a different CUDA version, run `make install-torch-cuda` after editing the wheel URLs in the Makefile.
25+
2626
> **NumPy constraint:** `numpy<2.0.0` is pinned in `pyproject.toml`. Do not upgrade it — WhisperX and some audio libraries break with NumPy 2.x.
2727
2828
---
@@ -652,17 +652,22 @@ Notifications are fire-and-forget — a failure to deliver never blocks or abort
652652
```bash
653653
uv venv --python 3.11.14
654654
source .venv/bin/activate
655-
uv pip install -e ".[dev]"
655+
656+
# Install all deps including whisperx, CUDA torch, dev tools, and pre-commit hooks
657+
make dev-setup
658+
659+
# Copy the env template and add your HuggingFace token
660+
cp .env.example .env
656661

657662
# Run unit tests (no GPU required)
658-
pytest tests/ -m "not integration" -v
663+
make test
659664

660665
# Run integration tests (requires GPU, HF_TOKEN, and test audio)
661-
pytest tests/ -m integration -v
666+
make test-integration
662667

663668
# Lint and format
664-
ruff check src/ tests/
665-
ruff format src/ tests/
669+
make lint
670+
make format
666671
```
667672

668673
---

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies = [
3939
"ffmpeg-python",
4040
"click>=8.1",
4141
"rich>=13.0",
42-
"transformers>=4.30.0",
42+
"transformers>=4.30.0,<4.40.0",
4343
]
4444

4545
[project.optional-dependencies]

src/transcriber.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ def _suppress_output():
5353
DEFAULT_LANGUAGE = "en"
5454

5555

56-
class TranscriptionError(Exception):
57-
"""Raised when transcription fails."""
58-
59-
def __init__(self, message: str):
60-
super().__init__(message)
61-
62-
6356
def _parse_whisperx_device(device: str) -> tuple[str, int]:
6457
"""Split a PyTorch-style device string for ctranslate2's separate API.
6558
@@ -79,6 +72,13 @@ def _parse_whisperx_device(device: str) -> tuple[str, int]:
7972
return device, 0
8073

8174

75+
class TranscriptionError(Exception):
76+
"""Raised when transcription fails."""
77+
78+
def __init__(self, message: str):
79+
super().__init__(message)
80+
81+
8282
def transcribe(
8383
input_file: Path,
8484
device: str = DEFAULT_DEVICE,
@@ -117,12 +117,7 @@ def transcribe(
117117
try:
118118
import whisperx
119119
except ImportError as exc:
120-
raise TranscriptionError(
121-
"whisperx is not installed. Install it with:\n"
122-
" uv pip install setuptools\n"
123-
" uv pip install --no-deps --no-build-isolation "
124-
'"whisperx @ git+https://github.com/m-bain/whisperX.git@main"'
125-
) from exc
120+
raise TranscriptionError("whisperx is not installed. Install it with:\n make install-whisperx") from exc
126121

127122
input_info: AudioFileInfo = probe_audio_file(input_file)
128123

@@ -159,10 +154,6 @@ def transcribe(
159154
for _logger_name in _NOISY_LOGGERS:
160155
logging.getLogger(_logger_name).setLevel(logging.ERROR)
161156

162-
# ctranslate2 (whisperx backend) doesn't accept 'cuda:N' — split into device + index.
163-
# load_align_model and align use PyTorch directly and understand 'cuda:N' fine.
164-
ct2_device, ct2_device_index = _parse_whisperx_device(device)
165-
166157
alignment_fallback = False
167158

168159
with warnings.catch_warnings():
@@ -171,6 +162,7 @@ def transcribe(
171162
try:
172163
if _whisperx_model is None:
173164
with _suppress_output():
165+
ct2_device, ct2_device_index = _parse_whisperx_device(device)
174166
wx_model = whisperx.load_model(
175167
model,
176168
ct2_device,

0 commit comments

Comments
 (0)