Skip to content

feat: Add ONNX support for inference acceleration #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

paulsunnypark
Copy link

This commit introduces ONNX-based inference capabilities to the project.

Key changes include:

  • Added onnx and onnxruntime to dependencies.
  • Created export_onnx.py script to convert PyTorch models to ONNX format. This script supports dynamic axes for variable sequence lengths.
  • Modified melo/api.py by adding a TTS_ONNX class that uses onnxruntime for inference, mirroring the existing TTS class structure.
  • Updated melo/infer.py to allow selection between PyTorch and ONNX models via CLI flags (--use_onnx, --onnx_path).
  • Added test/test_onnx_inference.py to provide basic testing for the ONNX inference pipeline, including model export and audio generation.
  • Updated README.md to document the new ONNX export and inference functionalities, including installation, model conversion, and usage instructions.

This allows you to potentially achieve faster inference speeds by converting models to ONNX and using the ONNX Runtime.

This commit introduces ONNX-based inference capabilities to the project.

Key changes include:
- Added `onnx` and `onnxruntime` to dependencies.
- Created `export_onnx.py` script to convert PyTorch models to ONNX format. This script supports dynamic axes for variable sequence lengths.
- Modified `melo/api.py` by adding a `TTS_ONNX` class that uses `onnxruntime` for inference, mirroring the existing `TTS` class structure.
- Updated `melo/infer.py` to allow selection between PyTorch and ONNX models via CLI flags (`--use_onnx`, `--onnx_path`).
- Added `test/test_onnx_inference.py` to provide basic testing for the ONNX inference pipeline, including model export and audio generation.
- Updated `README.md` to document the new ONNX export and inference functionalities, including installation, model conversion, and usage instructions.

This allows you to potentially achieve faster inference speeds by converting models to ONNX and using the ONNX Runtime.
@hindevth
Copy link

export_onnx.py is not working, it has an error.

Model loaded successfully. Traceback (most recent call last): File "MeloTTS/melo/export_onnx.py", line 89, in export_model_to_onnx( File "MeloTTS/melo/export_onnx.py", line 37, in export_model_to_onnx bert_feature_dim = hps.data.text_encoder.inter_channels # Example, verify actual attribute ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'HParams' object has no attribute 'text_encoder'

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