dummy_input_length when exporting a vits model to onnx #566
Replies: 2 comments
-
|
The value of # /// script
# requires-python = ">=3.12"
# dependencies = [
# "coqui-tts[cpu,codec]",
# "onnxruntime>=1.24.4",
# "onnxscript>=0.6.2",
# ]
# ///
import numpy as np
from TTS.api import TTS
from TTS.tts.configs.vits_config import VitsConfig
from TTS.tts.models.vits import Vits
from TTS.utils.audio.numpy_transforms import save_wav
ONNX_FN = "coqui_vits.onnx"
tts = TTS("tts_models/en/ljspeech/vits")
tts.synthesizer.tts_model.export_onnx(verbose=False, output_path=ONNX_FN)
del tts
config_path = "~/.local/share/tts/tts_models--en--ljspeech--vits/config.json"
config = VitsConfig()
config.load_json(config_path)
vits = Vits(config)
vits.load_onnx(ONNX_FN)
text = "Hello world, this is the widely known voice of ljspeech dataset Hello world, this is the widely known voice of ljspeech dataset."
text_inputs = np.asarray(
vits.tokenizer.text_to_ids(text, language=None),
dtype=np.int64,
)[None, :]
audio = vits.inference_onnx(text_inputs)
save_wav(wav=audio[0], path="test_onnx_coqui.wav", sample_rate=config.audio.sample_rate) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thank you, it's works. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everybody,
I was fixing the vits model export to onnx and thanks for accepting my pull request.
But, I have a help question about the dummy_input_length in the export_onnx function which is 100 by default
When I try an exported onnx model using the onnx runtime, I'm getting only 2 sec of audio even if a text is bigger.
If I increase the dummy_input length, I AM getting a larger audio but with a noice at the end if a text is less.
Maybe I have a misstake in my python script for testing the onnx model, or I need to export a vits model to be dynammic, and I'm interesting how to do that.
MY test.py script is in the attachemt here.
Best regards,
Darko
test.py
Beta Was this translation helpful? Give feedback.
All reactions