Skip to content

fix: remove torch dependency from ONNX runtime - #84

Open
z2z23n0 wants to merge 1 commit into
OpenMOSS:mainfrom
z2z23n0:fix/onnx-runtime-remove-torch-audio
Open

fix: remove torch dependency from ONNX runtime#84
z2z23n0 wants to merge 1 commit into
OpenMOSS:mainfrom
z2z23n0:fix/onnx-runtime-remove-torch-audio

Conversation

@z2z23n0

@z2z23n0 z2z23n0 commented Jun 30, 2026

Copy link
Copy Markdown

Summary

  • replace torch/torchaudio usage in onnx_tts_runtime.py with soundfile + NumPy
  • keep reference-audio output shape compatible with the ONNX codec encoder: (1, channels, samples)
  • add soundfile>=0.12.0 to pyproject.toml because the ONNX runtime now imports it directly

Closes #73.

Root Cause

The ONNX runtime path still imported PyTorch because reference-audio loading used torchaudio.load, torch.float32, and torchaudio.functional.resample. That meant app_onnx.py could fail at import time in lightweight ONNX-only environments without PyTorch installed.

Validation

  • Created a fresh Python 3.12 venv with only lightweight ONNX-path dependencies: numpy soundfile sentencepiece onnxruntime
  • Verified torch_available=False and torchaudio_available=False
  • Verified import onnx_tts_runtime succeeds without PyTorch installed
  • Verified _load_reference_audio() loads a temporary mono WAV, resamples it, duplicates channels, and returns float32 shape (1, 2, 4000)
  • Ran python -m py_compile onnx_tts_runtime.py
  • Ran git diff --check

@z2z23n0
z2z23n0 marked this pull request as ready for review June 30, 2026 15:15
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.

ONNX runtime still imports torch/torchaudio in onnx_tts_runtime.py

1 participant