rhasspy / piper

A fast, local neural text to speech system
https://rhasspy.github.io/piper-samples/
MIT License
6.5k stars 478 forks source link

Converting a VITS model to onnx format. #99

Closed StoryHack closed 1 year ago

StoryHack commented 1 year ago

After I got the onnx runtime to install (needed onnx 1.12) along with all the other requirements, I tried to convert a VITS model .pth checkpoint to the .onnx format. From the piper/src/python directory, with the venv running, I attempted to run: python3 ./piper_train/export_onnx.py --checkpoint ./vitsmodel/vits_jenny-dioco_20230421_checkpoint_2100k.pth --output ./onnx/jenny.onnx --debug And I get the following error: Traceback (most recent call last): File "/home/bryce/piper-train/src/python/./piper_train/export_onnx.py", line 9, in <module> from .vits.lightning import VitsModel ImportError: attempted relative import with no known parent package Am I even attempting to do this right? Or would I need to train from scratch? The dataset for the voice is available, too, just not in LJ Format, but that wouldn't be hard to script. I was just hoping to save a month of training on my poor RTX 3060...

beqabeqa473 commented 1 year ago

You are doing it wrong. python3 -m piper_train.export_onnx is a correct command

StoryHack commented 1 year ago

Running "python3 -m piper_train.export_onnx" now results in a new error: Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/bryce/piper-train/src/python/piper_train/export_onnx.py", line 9, in <module> from .vits.lightning import VitsModel File "/home/bryce/piper-train/src/python/piper_train/vits/lightning.py", line 15, in <module> from .models import MultiPeriodDiscriminator, SynthesizerTrn File "/home/bryce/piper-train/src/python/piper_train/vits/models.py", line 10, in <module> from . import attentions, commons, modules, monotonic_align File "/home/bryce/piper-train/src/python/piper_train/vits/monotonic_align/__init__.py", line 4, in <module> from .monotonic_align.core import maximum_path_c ModuleNotFoundError: No module named 'piper_train.vits.monotonic_align.monotonic_align'

beqabeqa473 commented 1 year ago

run build script in root of src/python

On 6/9/23, StoryHack @.***> wrote:

Running "python3 -m piper_train.export_onnx" now results in a new error: Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/bryce/piper-train/src/python/piper_train/export_onnx.py", line 9, in <module> from .vits.lightning import VitsModel File "/home/bryce/piper-train/src/python/piper_train/vits/lightning.py", line 15, in <module> from .models import MultiPeriodDiscriminator, SynthesizerTrn File "/home/bryce/piper-train/src/python/piper_train/vits/models.py", line 10, in <module> from . import attentions, commons, modules, monotonic_align File "/home/bryce/piper-train/src/python/piper_train/vits/monotonic_align/__init__.py", line 4, in <module> from .monotonic_align.core import maximum_path_c ModuleNotFoundError: No module named 'piper_train.vits.monotonic_align.monotonic_align'

-- Reply to this email directly or view it on GitHub: https://github.com/rhasspy/piper/issues/99#issuecomment-1584879337 You are receiving this because you commented.

Message ID: @.***>

-- with best regards Beqa Gozalishvili Tell: +995593454005 Email: @.*** Web: https://gozaltech.org Skype: beqabeqa473 Telegram: https://t.me/gozaltech facebook: https://facebook.com/gozaltech twitter: https://twitter.com/beqabeqa473 Instagram: https://instagram.com/beqa.gozalishvili

eschmidbauer commented 1 year ago

I am also trying to convert a VITS model (coqui-ai trained) , I get the following error


> python3 -m piper_train.export_onnx best.pth ./best-onnx
Traceback (most recent call last):
  File "/miniconda3/envs/piper/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/miniconda3/envs/piper/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/piper/src/python/piper_train/export_onnx.py", line 109, in <module>
    main()
  File "/piper/src/python/piper_train/export_onnx.py", line 42, in main
    model = VitsModel.load_from_checkpoint(args.checkpoint, dataset=None)
  File "/miniconda3/envs/piper/lib/python3.10/site-packages/pytorch_lightning/core/saving.py", line 139, in load_from_checkpoint
    return _load_from_checkpoint(
  File "/miniconda3/envs/piper/lib/python3.10/site-packages/pytorch_lightning/core/saving.py", line 163, in _load_from_checkpoint
    checkpoint = _pl_migrate_checkpoint(
  File "/miniconda3/envs/piper/lib/python3.10/site-packages/pytorch_lightning/utilities/migration/utils.py", line 113, in _pl_migrate_checkpoint
    old_version = _get_version(checkpoint)
  File "/miniconda3/envs/piper/lib/python3.10/site-packages/pytorch_lightning/utilities/migration/utils.py", line 136, in _get_version
    return checkpoint["pytorch-lightning_version"]
KeyError: 'pytorch-lightning_version'```
synesthesiam commented 1 year ago

Piper is not designed to be compatible with Coqui models.