Skip to content

refactor: move torch/deepfilternet to optional [full] extra#97

Merged
zh-plus merged 1 commit intozh-plus:masterfrom
iautolab:decouple-torch-deps-akieh
Apr 7, 2026
Merged

refactor: move torch/deepfilternet to optional [full] extra#97
zh-plus merged 1 commit intozh-plus:masterfrom
iautolab:decouple-torch-deps-akieh

Conversation

@MaleicAcid
Copy link
Copy Markdown
Collaborator

Move torch/deepfilternet to optional [full] extra

Motivation

torch, torchaudio, and deepfilternet (~2GB+) are only used in the noise suppression path (noise_suppress=True), which is off by default. Every pip install openlrc currently pulls in these heavy dependencies even though most users only need transcription and translation.

Additionally, torchvision is declared as a dependency but never imported anywhere in the codebase.

Changes

pyproject.toml

  • Move torch, torchaudio, and deepfilternet from dependencies to a new [project.optional-dependencies] full extra.
  • Remove torchvision entirely (unused).

openlrc/preprocess.py

  • Wrap import torch and from df.enhance import ... in noise_suppression() with a try/except ImportError that raises a clear message: "Install them with: pip install openlrc[full]".

openlrc/utils.py

  • Make release_memory() gracefully handle missing torch (return early instead of crashing).
  • Remove unused import torch from TYPE_CHECKING block.

.github/workflows/ci.yml

  • Change uv run python -m unittest to uv run --extra full python -m unittest so CI continues to test the full feature set including noise suppression.

README.md

  • Simplify installation steps: remove manual PyTorch, faster-whisper GitHub commit, and typing-extensions install instructions (no longer needed).
  • Add step 5 documenting the optional pip install openlrc[full] for noise suppression.
  • Update the Lightweight Imports note to reflect that the base install no longer includes torch.
  • Annotate the noise_suppress=True code example with (requires openlrc[full]).

Migration

Use case Install command
Transcription + translation (most users) pip install openlrc
Transcription + translation + noise suppression pip install openlrc[full]

Existing users who rely on noise_suppress=True need to change their install command to pip install openlrc[full].

@MaleicAcid MaleicAcid requested a review from zh-plus March 30, 2026 07:11
@MaleicAcid
Copy link
Copy Markdown
Collaborator Author

Hi @zh-plus, this PR is the concrete implementation of the dependency decoupling in #88.

The core change is simple: torch, torchaudio, and deepfilternet move from required dependencies to pip install openlrc[full]. Since noise suppression is off by default, the vast majority of users — those who only need transcription and translation — will never trigger these imports. This cuts ~2GB from the base install, removes the Rust toolchain requirement (deepfilternet), and unblocks torch version upgrades for downstream consumers.

The change is non-breaking for the default install path: all existing code works identically without any modifications. Only users who explicitly pass noise_suppress=True need to add [full] to their install command. The PR also includes an ImportError guard with a clear message pointing them to pip install openlrc[full], so no one will be left confused.

On versioning: since the default install surface changes (fewer packages installed), would you prefer to release this as 1.7.0, or 1.6.3 given that no code behavior changes for the default path?

@zh-plus
Copy link
Copy Markdown
Owner

zh-plus commented Apr 7, 2026

Thanks for the cleanup here. The dependency split looks good overall, and I’m fine merging this PR.

I did notice two small follow-up items:

  1. quote the openlrc[full] install command for zsh users
  2. realign TranslationConfig type hints with the runtime API/docs (ModelConfig and dict glossary usage)

I’ll handle those separately, so they’re not blocking this PR. Happy to merge.

@zh-plus zh-plus merged commit e163612 into zh-plus:master Apr 7, 2026
10 checks passed
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