Closed jeannekamikaze closed 1 year ago
Answering my own question: there is a model
member in the model
returned by torch.hub.load()
. That is the actual model that needs to be saved and then loaded by torch::jit::load()
(Silero models are apparently already jitted, and re-jitting results in a no-op.)
Answering my own question: there is a
model
member in themodel
returned bytorch.hub.load()
. That is the actual model that needs to be saved and then loaded bytorch::jit::load()
(Silero models are apparently already jitted, and re-jitting results in a no-op.)
Hello. Did you manage to import this model into c++? Is it even possible to do it?
Yeah, it's possible, you need to replicate the non-model code in the python file that massages the input into the vector format that the model consumes. I don't have the code anymore, though, as I abandoned this due to the non-free license.
Yeah, it's possible, you need to replicate the non-model code in the python file that massages the input into the vector format that the model consumes. I don't have the code anymore, though, as I abandoned this due to the non-free license.
Thank you very much. That's answer enough for me that it can be done.
Update: I found the stuff I had written and uploaded it here: https://filetransfer.io/data-package/HDNdnkp1#link
I haven't run this shit in a long while, but this is roughly what's in the zip:
ttsmod.py
-- Run with some combination of --export
and --lut
to export the Silero model in a format that the C++ Torch library understands and also generate a C++ header with a LUT that translates ASCII to the symbols the model understands.src/tts/
-- A C++ library that consumes the generated header above and wraps the whole inference shenanigan.src/tts-bin/
-- A demo program that uses the library to synthesize sample text and write the result to a wave file. This consumes the model you --export
ed with the Python script above.All that being said, there are better models out there, both in terms of ease of use and licensing. I remember experimenting with ONNX models and having a much easier time, if you can put up with Microsoft bait-and-switch software ecosystems, though I don't remember what model was it that I tried.
Update: I found the stuff I had written and uploaded it here
Wow, that's cool! I'll try to figure it out.
I am trying to import the
v3_en
model into C++. I have downloaded the model using a Python script with:This caches the model in the path:
If in my C++ program I run
torch::jit::load()
on the cached model path, I get the error:A quick search suggests that the error occurs because the model has not been converted to TorchScript (though I see a
constants.pkl
file in thev3_en.pt
file, which is just a zip.) I then try to convert to TorchScript back in Python via:But this results in the error:
If you have imported a Silero TTS model into C++ before or know how to get this to work, any guidance would be appreciated. Thank you.