# Audio Foundry — main service venv (plugins/audio_foundry/venv/).
#
# Hosts the FastAPI dispatcher + three of four backends:
#   - audio_fx   (Stable Audio Open via diffusers)
#   - voice_gen  (Chatterbox primary, Kokoro fallback)
#
# ACE-Step lives in a SIBLING venv (plugins/audio_foundry/venv-music/) — see
# requirements-music.txt — because it pins transformers==4.50.0, which this
# venv cannot run. music_gen_acestep.py drives that venv via subprocess.
#
# Install order (scripts/venv_sync.sh, used by setup_venv.sh and start.sh):
#   1. scripts/install_pytorch.sh --venv <this venv>   torch for this machine's GPU
#   2. pip install -r requirements.txt                 this file
#   3. pip install --no-deps -r requirements-nodeps.txt   chatterbox-tts itself
# torch goes in first so step 2 keeps that build instead of pulling the default
# PyPI wheel and then swapping it.

# Core service
fastapi>=0.115.0
uvicorn>=0.30.0
PyYAML>=6.0
pydantic>=2.0
httpx>=0.27.0
pydub>=0.25.1

# Testing
pytest>=8.0.0

# Audio I/O — used by every backend
soundfile>=0.12

# ── Security floors ──────────────────────────────────────────────────────────
# torch below 2.10.0 carries CVE-2026-24747 (code execution from a crafted
# checkpoint); transformers below 5.10.0 carries CVE-2026-4372, -5241 and -9856.
# setup_venv.sh treats a venv that does not satisfy this file as unhealthy and
# repairs it, so these floors are what keeps an old venv from staying old.
torch>=2.10.0
torchaudio
transformers>=5.10.0

# ── voice_gen: Chatterbox ────────────────────────────────────────────────────
# chatterbox-tts 0.1.7 (the newest release) pins torch==2.6.0, torchaudio==2.6.0,
# transformers==5.2.0, diffusers==0.29.0 and safetensors==0.5.3 exactly. Installed
# with its dependencies it drags the whole venv back to those versions, so the
# package itself is in requirements-nodeps.txt and what it imports is listed
# here without the exact pins. `pip check` reports the ignored pins; that is
# expected.
#
# Measured through the voice service on CPU, torch 2.14.1 + transformers 5.23.0
# against the pinned torch 2.6.0 + transformers 5.2.0, 54 cloned Chatterbox
# takes per stack: duration, loudness, pitch, speaker similarity to the
# reference clip and Whisper word accuracy all match (53/54 against 54/54
# takes transcribed exactly). Moving transformers alone leaves a seeded take
# sample-identical. Moving torch changes which take a seed produces, so a seed
# saved on torch 2.6.0 gives a different read of the same quality.
#
# Left out on purpose: gradio. Upstream lists it for its demo apps; nothing in
# the chatterbox package imports it.
librosa==0.11.0
s3tokenizer
resemble-perth>=1.0.0
conformer==0.3.2
safetensors>=0.5.3
einops>=0.6.1
scipy
tqdm
omegaconf
pyloudnorm
# Imported only by the multilingual tokenizer (Japanese, Chinese).
pykakasi==2.3.0
spacy-pkuseg
# Same split as chatterbox-tts declares: numpy 2 only on Python 3.13+.
numpy>=1.26.4,<2.0; python_version < "3.13"
numpy>=2.0.0; python_version >= "3.13"

# audio_fx (Stable Audio Open) needs StableAudioPipeline, added in diffusers
# 0.30.0. Chatterbox uses only scheduler, attention and activation classes
# that are stable across this range.
diffusers>=0.30,<0.40

# Stable Audio Open's CosineDPMSolverMultistepScheduler requires torchsde.
torchsde>=0.2.6

# diffusers emits a noisy LoRACompatibleLinear deprecation warning on every
# Chatterbox load unless PEFT is installed.
peft>=0.10

# Chatterbox depends on `resemble-perth`, which still uses the legacy
# `pkg_resources` API. setuptools >=81 removed pkg_resources, which makes
# perth fail to import, which makes ChatterboxTTS.from_pretrained crash
# with `'NoneType' object is not callable` (perth's __init__ silently
# swallows the ImportError and leaves the watermarker class as None).
# Pinning setuptools<81 keeps pkg_resources around. Once perth ships a
# fix that drops pkg_resources, this pin can come off.
setuptools<81

# voice_gen fallback — Kokoro.
# Non-English Kokoro languages (e/f/h/i/p — Spanish, French, Hindi, Italian,
# Portuguese) use `phonemizer-fork` + espeak-ng, both pulled transitively by
# `kokoro` and already wired here. Requires `espeak-ng` on the host (Ubuntu
# ships it; check `which espeak-ng`). Japanese/Chinese (j/z) would need
# misaki[ja]/misaki[zh] additionally — not wired today.
kokoro>=0.7

# audio_fx — SAO needs accelerate for fp16 device placement.
accelerate>=0.30
