152334H / tortoise-tts-fast

Fast TorToiSe inference (5x or your money back!)
GNU Affero General Public License v3.0
771 stars 179 forks source link

Issues trying to load voicefixer #41

Closed KevinKrames closed 1 year ago

KevinKrames commented 1 year ago

Hey guys I'm trying to run the code on my machine and I'm having trouble loading the checkpoint using torch: warn(f"Failed to load image Python extension: {e}") ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ X:\tortoise-tts-faster2\scripts\tortoise_tts.py:223 in │ │ │ │ 220 │ # app = import_module("app") │ │ 221 │ # sys.exit(app.main()) │ │ 222 │ │ │ ❱ 223 │ from tortoise.inference import ( │ │ 224 │ │ check_pydub, │ │ 225 │ │ get_all_voices, │ │ 226 │ │ get_seed, │ │ │ │ X:\tortoise-tts-faster2\tortoise\inference.py:167 in │ │ │ │ 164 │ │ 165 from voicefixer import VoiceFixer │ │ 166 │ │ ❱ 167 vfixer = VoiceFixer() │ │ 168 │ │ 169 │ │ 170 def save_gen_with_voicefix(g, fpath, squeeze=True, voicefixer=True): │ │ │ │ C:\Users*\AppData\Local\Programs\Python\Python310\lib\site-packages\voicefixer\base. │ │ py:13 in init │ │ │ │ 10 class VoiceFixer(nn.Module): │ │ 11 │ def init(self): │ │ 12 │ │ super(VoiceFixer, self).init() │ │ ❱ 13 │ │ self._model = voicefixer_fe(channels=2, sample_rate=44100) │ │ 14 │ │ # print(os.path.join(os.path.expanduser('~'), ".cache/voicefixer/analysis_module │ │ 15 │ │ self.analysis_module_ckpt = os.path.join( │ │ 16 │ │ │ │ │ os.path.expanduser("~"), │ │ │ │ C:\Users*r\AppData\Local\Programs\Python\Python310\lib\site-packages\voicefixer\resto │ │ rer\model.py:180 in init │ │ │ │ 177 │ │ # self.am = AudioMetrics() │ │ 178 │ │ # self.im = ImgMetrics() │ │ 179 │ │ │ │ ❱ 180 │ │ self.vocoder = Vocoder(sample_rate=44100) │ │ 181 │ │ │ │ 182 │ │ self.valid = None │ │ 183 │ │ self.fake = None │ │ │ │ C:\Users*\AppData\Local\Programs\Python\Python310\lib\site-packages\voicefixer\vocod │ │ er\base.py:19 in init │ │ │ │ 16 │ │ │ raise RuntimeError("Error 1: The checkpoint for synthesis module / vocoder ( │ │ 17 │ │ │ │ │ │ │ │ By default the checkpoint should be download automatical │ │ 18 │ │ │ │ │ │ │ │ But don't worry! Alternatively you can download it direc │ │ ❱ 19 │ │ self._load_pretrain(Config.ckpt) │ │ 20 │ │ self.weight_torch = Config.get_mel_weight_torch(percent=1.0)[ │ │ 21 │ │ │ None, None, None, ... │ │ 22 │ │ ] │ │ │ │ C:\Users*\AppData\Local\Programs\Python\Python310\lib\site-packages\voicefixer\vocod │ │ er\base.py:26 in _load_pretrain │ │ │ │ 23 │ │ │ 24 │ def _load_pretrain(self, pth): │ │ 25 │ │ self.model = Generator(Config.cin_channels) │ │ ❱ 26 │ │ checkpoint = load_checkpoint(pth, torch.device("cpu")) │ │ 27 │ │ load_try(checkpoint["generator"], self.model) │ │ 28 │ │ self.model.eval() │ │ 29 │ │ self.model.remove_weight_norm() │ │ │ │ C:\Users*\AppData\Local\Programs\Python\Python310\lib\site-packages\voicefixer\vocod │ │ er\model\util.py:111 in load_checkpoint │ │ │ │ 108 │ │ 109 │ │ 110 def load_checkpoint(checkpoint_path, device): │ │ ❱ 111 │ checkpoint = torch.load(checkpoint_path, map_location=device) │ │ 112 │ return checkpoint │ │ 113 │ │ 114 │ │ │ │ C:\Users*\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\serializat │ │ ion.py:777 in load │ │ │ │ 774 │ │ │ # If we want to actually tail call to torch.jit.load, we need to │ │ 775 │ │ │ # reset back to the original position. │ │ 776 │ │ │ orig_position = opened_file.tell() │ │ ❱ 777 │ │ │ with _open_zipfile_reader(opened_file) as opened_zipfile: │ │ 778 │ │ │ │ if _is_torchscript_zip(opened_zipfile): │ │ 779 │ │ │ │ │ warnings.warn("'torch.load' received a zip file that looks like a To │ │ 780 │ │ │ │ │ │ │ │ " dispatching to 'torch.jit.load' (call 'torch.jit.loa │ │ │ │ C:\Users***\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\serializat │ │ ion.py:282 in init │ │ │ │ 279 │ │ 280 class _open_zipfile_reader(_opener): │ │ 281 │ def init(self, name_or_buffer) -> None: │ │ ❱ 282 │ │ super(_open_zipfile_reader, self).init(torch._C.PyTorchFileReader(name_or_bu │ │ 283 │ │ 284 │ │ 285 class _open_zipfile_writer_file(_opener): │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

I thought maybe the file was imcomplete and tried to delete it and dowload it manually through the browser but I'm still having the same issue. Thanks for any help!

KevinKrames commented 1 year ago

Looks like I was finally able to solve my issue, Poetry was using the wrong version of python. For some reason I could not change the python version in poetry by defining setting the path to my local version (Was getting access denied even in admin cmd). Instead I had to install pyenv here: https://github.com/pyenv-win/pyenv-win Then I had to change the python env using pyenv: pyenv install 3.9.11 poetry env use $(pyenv which python)