fix(audio/indextts2): declare the missing IndexTTS2 virtualenv dependencies (#5201)#5223
Open
OliverBryant wants to merge 2 commits into
Open
fix(audio/indextts2): declare the missing IndexTTS2 virtualenv dependencies (#5201)#5223OliverBryant wants to merge 2 commits into
OliverBryant wants to merge 2 commits into
Conversation
…encies The IndexTTS2 model spec's virtualenv package list omitted most of the runtime dependencies of the bundled thirdparty/indextts inference code (librosa, soundfile, einops, omegaconf, sentencepiece, textstat, and the WeTextProcessing/wetext text normalizers). On the slim v3 GPU image, which no longer ships these globally, launching IndexTTS2 fails with a chain of ModuleNotFoundError before inference can start. Complete the declaration with the packages actually imported on the infer_v2 code path, add #system_torchaudio# (infer_v2 imports torchaudio), and select the text normalizer per platform: WeTextProcessing on linux x86_64, wetext elsewhere, since pynini only publishes x86_64 manylinux wheels. Teach TextNormalizer.load() to fall back to wetext when WeTextProcessing is unavailable so linux aarch64 works as well.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the virtualenv package dependencies for an audio model specification and refactors the text normalizer import logic in xinference/thirdparty/indextts/utils/front.py to fall back to wetext on non-x86_64 Linux architectures. Feedback suggests raising the ImportError on x86_64 Linux instead of falling back to wetext (which is not installed on that architecture) to avoid a secondary ModuleNotFoundError, and recommends passing the machine architecture as an explicit parameter to the utility function.
On linux x86_64 the venv installs WeTextProcessing, not wetext; falling back to wetext there would mask a broken tn/pynini environment behind a misleading wetext ModuleNotFoundError. Only fall back on architectures where pynini has no prebuilt wheels.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #5201 (and complementary to #5203). As reported in #5201 (comment), IndexTTS2 cannot launch at all on the slim
v3.0.0GPU image: the model spec's virtualenv package list omits most of the runtime dependencies of the bundledthirdparty/indexttsinference code, and the slim image no longer provides them globally. Launch fails with a chain ofModuleNotFoundError(librosa, theneinops, then more) before inference can start.Changes
xinference/model/audio/model_spec.json— complete the IndexTTS2 virtualenv declaration with the packages actually imported on theinfer_v2code path (traced statically frominfer_v2.pythrough theindextts.*import graph, then verified empirically, see below):librosa,soundfile— audio I/O (infer_v2loads prompts vialibrosa.load; the wrapper encodes responses withsoundfile)einops,omegaconf,sentencepiece,textstat— imported by the GPT/s2mel/text-frontend modulesaccelerate— declared by upstream index-tts as a hard dependency#system_torchaudio#—infer_v2importstorchaudioat module level (only#system_torch#was declared)WeTextProcessing ; sys_platform == 'linux' and platform_machine == 'x86_64'andwetext ; sys_platform != 'linux' or platform_machine != 'x86_64'— the text normalizersindextts/utils/front.pyselects at runtime.WeTextProcessingdepends onpynini, which only publishes x86_64 manylinux wheels, hence the split markers (standard PEP 508 markers pass through the spec filter to uv untouched).xinference/thirdparty/indextts/utils/front.py—TextNormalizer.load()hard-selectedtn(WeTextProcessing) wheneverplatform.system() == "Linux", which can never work on linux aarch64 (no pynini wheel; the image is built for both amd64 and arm64). It now falls back towetextwhentnis not importable. Behavior on linux x86_64 is unchanged (stilltn).Verification
All checks were run in containers reproducing the slim image's environment:
torch/torchaudio/numpy;modelscopepresent as in the parent env),import indextts.infer_v2succeeds, andTextNormalizer().load()+normalize()work for both zh and en via WeTextProcessing 1.2.0.wetext(+kaldifst, which does ship aarch64 wheels), and the new fallback path normalizes zh text correctly.ubuntu:22.04with the Dockerfile's exact deadsnakes python3.12 + aptffmpeg(4.4, shared libs) layers andtorch==2.11.0/torchaudio==2.11.0/torchcodec==0.14.0perrequirements-runtime.txt, torchcodec loads its FFmpeg-4 core andtorchaudio.save/loadround-trip successfully — the v2.12.0-era loading failure from [Bug] IndexTTS2 /v1/audio/speech returns 500 at WAV save: libtorchcodec cannot load in v2.12.0 Docker #5201/升级到v2.9.0后,加载Eembedding和reranker模型报错 Could not load libtorchcodec. #4960 (mismatched torchcodec 0.10 + a static FFmpeg 6 without shared libraries) is already resolved by the current slim-image pins. The remaining launch blocker was purely the venv declaration fixed here.Fixes the launch failure reported in #5201's v3.0.0 follow-up testing; with #5203 merged, the original WAV-save failure is bypassed as well.