TTS icon indicating copy to clipboard operation
TTS copied to clipboard

[Bug] ModuleNotFoundError: No module named 'TTS.vc'

Open All-Ki opened this issue 1 year ago • 2 comments

Describe the bug

Using this code ( from the docs ) I get : Adding an empty init.py file to the vc folder fixes it

To Reproduce

from TTS.api import TTS model_name = TTS.list_models()[0] tts = TTS(model_name) wav = tts.tts("This is a test! This is also a test!!", speaker=tts.speakers[0], language=tts.languages[0]) tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")

Expected behavior

No response

Logs

File ".\test.py", line 1, in <module>
    from TTS.api import TTS
  File "H:\Code\AI\tts\TTS\TTS\api.py", line 15, in <module>
    from TTS.utils.synthesizer import Synthesizer
  File "H:\Code\AI\tts\TTS\TTS\utils\synthesizer.py", line 16, in <module>
    from TTS.vc.models import setup_model as setup_vc_model
ModuleNotFoundError: No module named 'TTS.vc

Environment

{
    "CUDA": {
        "GPU": [
            "NVIDIA GeForce RTX 3090"
        ],
        "available": true,
        "version": "10.1"
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "1.8.0+cu101",
        "TTS": "0.13.3",
        "numpy": "1.21.6"
    },
    "System": {
        "OS": "Windows",
        "architecture": [
            "64bit",
            "WindowsPE"
        ],
        "processor": "AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD",
        "python": "3.8.16",
        "version": "10.0.22621"
    }
}

Additional context

No response

All-Ki avatar Apr 21 '23 01:04 All-Ki

Same error, fresh install via pip.

anphex avatar Apr 22 '23 08:04 anphex

It seems it has to do with Japanese phonemizers.py calling MeCab.Tagger(). The error disappeared when I replaced the init definition at line 355 in the file coquitts\lib\site-packages\MeCab.py : def init(self, *args): #_MeCab.Tagger_swiginit(self, _MeCab.new_Tagger(*args)) return None

dalphil avatar Apr 29 '23 14:04 dalphil

It seems it has to do with Japanese phonemizers.py calling MeCab.Tagger(). The error disappeared when I replaced the init definition at line 355 in the file coquitts\lib\site-packages\MeCab.py : def init(self, *args): #_MeCab.Tagger_swiginit(self, _MeCab.new_Tagger(*args)) return None

I am not being able to find the MeCab.py file, so I cannot comment on that.

But I'd like to add that it seems related to the fact that the import: from TTS.vc.models import setup_model as setup_vc_mode Tries to import the function "setup_model" from the vc.models.__init__.py script. However, even though the script is there, it is not being able to read from it for some reason. To solve this, I made a copy of the __init__.py file (inside of the TTS/vc/Models folder) and pasted it directly into the TTS folder with a new name vc_setup_model.py, and changed the line: from TTS.vc.models import setup_model as setup_vc_mode to from TTS.vc_setup_model import setup_model as setup_vc_mode and it worked!

exast avatar May 02 '23 00:05 exast

can't reproduced

erogol avatar May 08 '23 09:05 erogol

I get the exact same error

frederikdangel avatar May 10 '23 13:05 frederikdangel

@frederikdangel post a sample code for me to reproduce pls.

erogol avatar May 11 '23 08:05 erogol

I can reproduce this:

from TTS.api import TTS

# List available 🐸TTS models and choose the first one
model_name = TTS.list_models()[0]
# Init TTS
tts = TTS(model_name)
# Run TTS
# ❗ Since this model is multi-speaker and multi-lingual, we must set the target speaker and the language
# Text to speech with a numpy output
wav = tts.tts("This is a test! This is also a test!!", speaker=tts.speakers[0], language=tts.languages[0])
# Text to speech to a file
tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")

Code copied straight from the docs. Host system is Arch Linux, 13700K + Arc A770. Installed from GitHub. PyPi package does not have this bug.

tazz4843 avatar Jul 03 '23 17:07 tazz4843

@erogol I'm also having this exact same issue. All I run is:

from TTS.api import TTS

and I get:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 from TTS.api import TTS

File /home/user/TTS/TTS/api.py:15
     13 from TTS.utils.audio.numpy_transforms import save_wav
     14 from TTS.utils.manage import ModelManager
---> 15 from TTS.utils.synthesizer import Synthesizer
     18 class Speaker(object):
     19     """Convert dict to object."""

File  /home/user/TTS/TTS/utils/synthesizer.py:19
     17 from TTS.utils.audio import AudioProcessor
     18 from TTS.utils.audio.numpy_transforms import save_wav
---> 19 from TTS.vc.models import setup_model as setup_vc_model
     20 from TTS.vocoder.models import setup_model as setup_vocoder_model
     21 from TTS.vocoder.utils.generic_utils import interpolate_vocoder_input

ModuleNotFoundError: No module named 'TTS.vc'

I installed TTS using the following script:

virtualenv -p $(which python)
source ./ttsenv/bin/activate
git clone https://github.com/coqui-ai/TTS.git
pip install -e TTS/
pip install mecab-python3 unidic-lite

That last pip install is necessary because TTS complains about not finding them (something about JP models).

ddpasa avatar Jul 29 '23 13:07 ddpasa

Nevermind this happens because I'm running it in the same folder the github is cloned into. Changing the directory name fixes it.

ddpasa avatar Jul 29 '23 13:07 ddpasa