DigitalPhonetics / IMS-Toucan

Controllable and fast Text-to-Speech for over 7000 languages!
Apache License 2.0
1.47k stars 166 forks source link

Dependencies Conflicts #171

Closed AlexSteveChungAlvarez closed 5 months ago

AlexSteveChungAlvarez commented 5 months ago

I got this ERROR both on Windows 64-bits and on Google Colab,

ERROR: Cannot install -r requirements.txt (line 26), -r requirements.txt (line 30), -r requirements.txt (line 9), torch and torch~=2.0.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested torch~=2.0.0
    transphone 1.5.3 depends on torch
    audioseal 0.1.0 depends on torch>=1.13.0
    triton 2.0.0 depends on torch
    torchaudio 2.0.2 depends on torch==2.0.1

This can be solved by installing each dependency manually, after installing pytorch independently, but it would be better if you fix it directly in the requirements @Flux9665 . By the way, on Windows there's also an issue with Mecab library, apparently Windows (64-bits) users need to install it appart from pip installing it, as stated in their pypi page: https://pypi.org/project/mecab/

AlexSteveChungAlvarez commented 5 months ago

When installing each dependency manually, another issue appeared: ModuleNotFoundError: No module named 'speechbrain.pretrained' which I overcame by editting line 17 in ToucanTTSInterface.py as stated in this issue https://github.com/speechbrain/speechbrain/issues/2472:

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    from audioseal.builder import create_generator
    from omegaconf import DictConfig
    from omegaconf import OmegaConf
    from speechbrain.inference import EncoderClassifier
    from torchaudio.transforms import Resample

This is when running on Google colab.

lpscr commented 5 months ago

hi @AlexSteveChungAlvarez i have same problem and here how i fix the requirements problems

#requirements windows 10

pip install dragonmapper pypinyin wandb dotwiz pyloudnorm einops speechbrain==0.5.13 torch_complex praat-parselmouth transphone jamo g2pk phonemizer soundfile audioseal sounddevice matplotlib numpy==1.23.4 gradio cvxopt geopy librosa

pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118

solution on mecab not found i remove manual because also if install the pip install mecab from me not working ModuleNotFoundError: No module named 'mecab'

i fix by go in IMS-Toucan\Preprocessing\TextFrontend.py

in line 38 replace only solution i found yes i know it's not the best but for me working because i dont use g2p

https://github.com/DigitalPhonetics/IMS-Toucan/blob/1525e60054f84ffb94aed085ebad85dbb2357dc6/Preprocessing/TextFrontend.py#L38

from transphone.g2p import read_g2p to #from transphone.g2p import read_g2p

OSError: [WinError 1314] A required privilege is not held by the client: you need run the python like admin and working after

#requirements on colab

!pip install dragonmapper pypinyin wandb dotwiz pyloudnorm einops speechbrain==0.5.13 torch_complex praat-parselmouth transphone jamo g2pk sounddevice audioseal gradio phonemizer py-espeak-ng

!apt-get install libportaudio2
!apt-get -y install python-espeak
!apt-get -y install espeak-ng
Flux9665 commented 5 months ago

Thanks for letting me know, I will try to improve the dependencies. On my windows machine they work and on my linux server they work as well, but things just constantly keep breaking.

Flux9665 commented 5 months ago

I updated the audioseal dependency, which got rid of the audiocraft dependency. I also made sure that the torchaudio dependency is compatible with the torch dependency. The commit I just made contains a requirements.txt file that I can install on both my windows and linux machine without any issue. Please let me know if there's still a problem.

lpscr commented 5 months ago

i just try to test

i use python 3.10.0 version

and here what i get

here what you get in windows full error when you run the demo_cli

Traceback (most recent call last):
  File "C:\PythonApps\test\IMS-Toucan\run_CLI_demo.py", line 18, in <module>
    tts = ToucanTTSInterface(device=device, tts_model_path=PATH_TO_TTS_MODEL)
  File "C:\PythonApps\test\IMS-Toucan\InferenceInterfaces\ToucanTTSInterface.py", line 55, in __init__
    self.text2phone = ArticulatoryCombinedTextFrontend(language=language, add_silence_to_end=True)
  File "C:\PythonApps\test\IMS-Toucan\Preprocessing\TextFrontend.py", line 38, in __init__
    from transphone.g2p import read_g2p
  File "C:\PythonApps\test\.venv\lib\site-packages\transphone\__init__.py", line 1, in <module>
    from transphone.tokenizer import read_tokenizer
  File "C:\PythonApps\test\.venv\lib\site-packages\transphone\tokenizer.py", line 9, in <module>
    from transphone.lang.epitran_tokenizer import read_epitran_tokenizer
  File "C:\PythonApps\test\.venv\lib\site-packages\transphone\lang\epitran_tokenizer.py", line 14, in <module>
    from epitran.ppprocessor import PrePostProcessor
  File "C:\PythonApps\test\.venv\lib\site-packages\epitran\__init__.py", line 1, in <module>
    from epitran._epitran import Epitran
  File "C:\PythonApps\test\.venv\lib\site-packages\epitran\_epitran.py", line 9, in <module>
    from epitran.simple import SimpleEpitran
  File "C:\PythonApps\test\.venv\lib\site-packages\epitran\simple.py", line 15, in <module>
    from g2pk import G2p
  File "C:\PythonApps\test\.venv\lib\site-packages\g2pk\__init__.py", line 6, in <module>
    from .g2pk import G2p
  File "C:\PythonApps\test\.venv\lib\site-packages\g2pk\g2pk.py", line 9, in <module>
    import mecab
ModuleNotFoundError: No module named 'mecab'

so again need to comment the like i say up

from transphone.g2p import read_g2p

OSError: [WinError 1314] A required privilege is not held by the client: so i need run as admin the python and run the code

the pytorch now correct

and then i can run just fine the demo_cli

lpscr commented 5 months ago

here i found this working and solution in windows 10 for mecab with this requirements.txt

the correct version for pytorch

torch~=2.0.1
torchaudio~=2.0.2 

here requirements.txt

torch~=2.0.1
torchaudio~=2.0.2 
speechbrain==0.5.13
torch_complex~=0.4.3
tqdm~=4.64.1
librosa~=0.9.2
praat-parselmouth~=0.4.2
numpy~=1.23.4
soundfile~=0.12.0
pypinyin~=0.47.1
pyloudnorm~=0.1.0
cvxopt~=1.3.0
sounddevice~=0.4.5
matplotlib~=3.6.2
phonemizer~=3.2.1
gradio~=3.19.1
wandb~=0.13.5
dragonmapper~=0.2.6
alias_free_torch~=0.0.6
scipy~=1.9.3
dotwiz==0.4.0
transphone==1.5.3
phonepiece==1.4.2
geopy==2.4.1
einops==0.7.0
audioseal==0.1.3
urllib3~=1.26.12
jamo~=0.4.1
g2pk~=0.9.4

ModuleNotFoundError: No module named 'mecab' i found what curse the problem module it's wrong name when import in g2p easy to fix

go to .venv\Lib\site-packages where all install packages and rename it

find the MeCab and rename to mecab make all lowcase and then mecab working ! image

or

just run this help python script to rename automatic for you

import os
import site
site_packages_dir = site.getsitepackages()[0]
path_mecab = os.path.join(site_packages_dir, "lib/site-packages/MeCab")
path_mecab_lowercase = os.path.join(site_packages_dir, "lib/site-packages/mecab")

if os.path.isdir(path_mecab):
    os.rename(path_mecab, path_mecab_lowercase)
    print(f"Renamed {path_mecab} to {path_mecab_lowercase}")
else:
    print(f"{path_mecab} does not exist")

i hope this help both solution working

AlexSteveChungAlvarez commented 5 months ago

Getting this on Windows after your workaround:

Traceback (most recent call last):
  File "d:\IMS-Toucan\run_text_to_file_reader.py", line 100, in <module>
    sound_of_silence_single_utt(version="new_voc",
  File "d:\IMS-Toucan\run_text_to_file_reader.py", line 42, in sound_of_silence_single_utt
    read_texts(model_id=model_id,
  File "d:\IMS-Toucan\run_text_to_file_reader.py", line 9, in read_texts
    tts = ToucanTTSInterface(device=device, tts_model_path=model_id)
  File "d:\IMS-Toucan\InferenceInterfaces\ToucanTTSInterface.py", line 55, in __init__
    self.text2phone = ArticulatoryCombinedTextFrontend(language=language, add_silence_to_end=True)        
  File "d:\IMS-Toucan\Preprocessing\TextFrontend.py", line 38, in __init__
    from transphone.g2p import read_g2p
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\transphone\__init__.py", line 1, in <module>
    from transphone.tokenizer import read_tokenizer
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\transphone\tokenizer.py", line 9, in <module>
    from transphone.lang.epitran_tokenizer import read_epitran_tokenizer
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\transphone\lang\epitran_tokenizer.py", line 14, in <module>
    from epitran.ppprocessor import PrePostProcessor
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\epitran\__init__.py", line 1, in <module>
    from epitran._epitran import Epitran
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\epitran\_epitran.py", line 9, in <module>
    from epitran.simple import SimpleEpitran
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\epitran\simple.py", line 15, in <module>
    from g2pk import G2p
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\g2pk\__init__.py", line 6, in <module>
    from .g2pk import G2p
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\g2pk\g2pk.py", line 9, in <module>    
    import mecab
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\mecab\__init__.py", line 13, in <module>
    from .mecab import MeCab, MeCabError, mecabrc_path
  File "C:\Users\Windows 11\anaconda3\envs\prueba\lib\site-packages\mecab\mecab.py", line 8, in <module>  
    import _mecab
ModuleNotFoundError: No module named '_mecab'
lpscr commented 5 months ago

i think the problem it's windows 11 i use windows 10 so i am not sure why this happend for me working fine in windows 10 , also i use python 3.10.0 version maybe also this the problem see what python version you use

lpscr commented 5 months ago

for me in windows 10 rename simple the module for MeCab to mecab working fine

but i make working also with this method it's most complex because now you change the script module code and correct all the names here just need change 2 files the mecab.py and g2pk.py

make use you have name in folder MeCab like install

in .venv\Lib\site-packages\MeCab\mecab.py open to edit the script

line 8,9

from mecab.types import Dictionary, Morpheme from mecab.utils import create_lattice, ensure_list, to_csv to from MeCab.types import Dictionary, Morpheme from MeCab.utils import create_lattice, ensure_list, to_csv

in .venv\Lib\site-packages\g2pk\g2pk.py open to edit the script

in line 9 import mecab to import MeCab

in line 38 return mecab.MeCab() to return MeCab.MeCab()

then must working fine let me know

lpscr commented 5 months ago

i make script just run and rename all automatic corrent all the names

import os
import site

site_packages_dir = site.getsitepackages()[0]
path_mecab = os.path.join(site_packages_dir, "lib/site-packages/mecab")
path_mecab_lowercase = os.path.join(site_packages_dir, "lib/site-packages/MeCab")

if os.path.isdir(path_mecab):
    os.rename(path_mecab, path_mecab_lowercase)
    print(f"Renamed {path_mecab} to {path_mecab_lowercase}")
else:
    print(f"{path_mecab} does not exist")

path_mecab_mecab = os.path.join(site_packages_dir, "lib/site-packages/MeCab/mecab.py")
path_g2p = os.path.join(site_packages_dir, "Lib/site-packages/g2pk/g2pk.py")

if os.path.isfile(path_mecab_mecab):
    with open(path_mecab_mecab, 'r', encoding="utf-8") as f:
        content = f.read().replace("from mecab.", "from MeCab.")
    with open(path_mecab_mecab, 'w', encoding="utf-8") as f:
         f.write(content)
    print(f"Updated in {path_mecab_mecab}")

if os.path.isfile(path_g2p):
    with open(path_g2p, 'r', encoding="utf-8") as f:
        content = f.read().replace("import mecab", "import MeCab").replace("return mecab.MeCab()", "return MeCab.MeCab()")
    with open(path_g2p, 'w', encoding="utf-8") as f:
         f.write(content)
    print(f"Updated in {path_g2p}")
Flux9665 commented 5 months ago

I figured it out: mecab is a dependency of g2pk, but as pointed out previously, under windows the name of mecab is case sensitive. g2pk is in turn a dependency of epitran. Epitran is in turn a dependency of transphone, which is a dependency of toucan. The previous version of epitran, 1.24 does not use g2pk and therefore does not need the broken mecab dependency.

I updated the requirements file to require epitran==1.24, which fixes this issue. Now installing the requirements from requirements.txt should work on all systems. Please let me know whether the fix works if you find the time. For an existing environment you can just run pip install epitran==1.24

AlexSteveChungAlvarez commented 5 months ago

@Flux9665 The mecab thing is solved now. There's only one thing to point out which is that for using cuda people should install torch with cuda instead of the torch from requirements.txt. Now the only issue left which I don't know if it's related to the dependencies is #172, so I'll leave this issue alive until that issue is solved.

lpscr commented 5 months ago

it will work fine when you install the dependencies listed in requirements.txt. great work @Flux9665 thank you for the fix

if you need cuda you need install after this other working only in cpu pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118 -U

You need to run the installation as an administrator the first time; otherwise, you will encounter the following error: OSError: [WinError 1314] A required privilege is not held by the client

AlexSteveChungAlvarez commented 5 months ago

All dependencies are updated now!