How to train a model?

Hi Everyone!
I am new to the topic and I want to try setting my own model for Polish language.
First of all, I tried this one (but on my computer):


to see how the model behaves etc.
My next step is to prepare .csv file as in the example above.
I got some samples already in Polish.
Unfortunately, I wasn’t able to run the example model due to the error:

File "train.py", line 13, in <module>
    from TTS.datasets.TTSDataset import MyDataset
ModuleNotFoundError: No module named 'TTS'

I work in TTS project directory, LJSpeech is in subfile in that directory.
I know it’s dedicated to Jupyter… but maybe I am doing something wrong?

Hi @shad94, I suspect it’s related to this issue: https://github.com/mozilla/TTS/issues/264

Have a go with adding import TTS

Or you could add the path of tts to your pythonpath variable.

Check out erogol’s answer,

you need to do one of these;

`export PYTHONPATH="/path/to/TTS"`

or install TTS with ;

`python setup.py develop`

Interesting, because I installed TTS with command:

python setup.py develop

and I got different errors:

File “train.py”, line 704, in
main(args)
File “train.py”, line 515, in main
meta_data_train, meta_data_eval = load_meta_data(c.datasets)
AttributeError: ‘AttrDict’ object has no attribute ‘datasets’

Using CUDA: False
Number of GPUs: 0
Git Hash: 7eb291c
Experiment folder: /home/marta/PycharmProjects/TTS/…/keep/mozilla-tacotron-tagent-bn-November-18-2019_07+42AM-7eb291c
Setting up Audio Processor…
| > sample_rate:22050
| > num_mels:80
| > min_level_db:-100
| > frame_shift_ms:12.5
| > frame_length_ms:50
| > ref_level_db:20
| > num_freq:1025
| > power:1.5
| > preemphasis:0.98
| > griffin_lim_iters:60
| > signal_norm:True
| > symmetric_norm:False
| > mel_fmin:0
| > mel_fmax:8000.0
| > max_norm:1.0
| > clip_norm:True
| > do_trim_silence:True
| > sound_norm:False
| > n_fft:2048
| > hop_length:275
| > win_length:1100
! Run is removed from /home/marta/PycharmProjects/TTS/…/keep/mozilla-tacotron-tagent-bn-November-18-2019_07+42AM-7eb291c

I did:

apt-get install espeak

but it was already installed.
As you can see, I don’t use CUDA, and I wonder- maybe this is the cause of the problem?

Your config.json is probably missing the datasets “key”. Check other example json and add that. You will possibly get more similar errors, when you do just find them from other examples and add them.

Ok, I run it in Jupyter Notebook, after a change in https://gist.github.com/erogol/97516ad65b44dbddb8cd694953187c5b?short_path=221d607
and I received other errors… I wonder why I am receiving errors, while @erogol did not in his Notebook run.
Any idea?
I would like to contribute to the project with Polish, however I am still facing problems.

> Epoch 0/1000
Traceback (most recent call last):
  File "train.py", line 704, in <module>
    main(args)
  File "train.py", line 615, in main
    global_step, epoch)
  File "train.py", line 100, in train
    for num_iter, data in enumerate(data_loader):
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 819, in __next__
    return self._process_data(data)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data
    data.reraise()
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/_utils.py", line 385, in reraise
    raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/marta/Desktop/inż/TTS/tts_namespace/TTS/datasets/TTSDataset.py", line 164, in __getitem__
    return self.load_data(idx)
  File "/home/marta/Desktop/inż/TTS/tts_namespace/TTS/datasets/TTSDataset.py", line 110, in load_data
    wav = np.asarray(self.load_wav(wav_file), dtype=np.float32)
  File "/home/marta/Desktop/inż/TTS/tts_namespace/TTS/datasets/TTSDataset.py", line 68, in load_wav
    audio = self.ap.load_wav(filename)
  File "/home/marta/Desktop/inż/TTS/tts_namespace/TTS/utils/audio.py", line 239, in load_wav
    x, sr = sf.read(filename)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/soundfile.py", line 257, in read
    subtype, endian, format, closefd) as f:
  File "/home/marta/anaconda3/lib/python3.7/site-packages/soundfile.py", line 627, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/soundfile.py", line 1182, in _open
    "Error opening {0!r}: ".format(self.name))
  File "/home/marta/anaconda3/lib/python3.7/site-packages/soundfile.py", line 1355, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening '../LJSpeech-1.1/wavs/LJ002-0020.wav': System error

I’ve put a comment on the gist that may help

yes, this was a case; removing that file from .csv should be enough to solve the problem, right?

Yes, I expect so. Hope it works!

Indeed, there was something with unpacking, however- still, the same errors appear:

File "train.py", line 704, in <module>
    main(args)
  File "train.py", line 615, in main
    global_step, epoch)
  File "train.py", line 163, in train
    mel_lengths)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/TTS-0.0.1+7eb291c-py3.7.egg/TTS/layers/losses.py", line 30, in forward
    loss = loss / mask.sum()
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler
    _error_if_any_worker_fails()

Starting training again:

File "train.py", line 704, in <module>
    main(args)
  File "train.py", line 615, in main
    global_step, epoch)
  File "train.py", line 177, in train
    loss.backward()
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/tensor.py", line 166, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/autograd/__init__.py", line 99, in backward
    allow_unreachable=True)  # allow_unreachable flag
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler
    _error_if_any_worker_fails()

Everything has to do with TORCH, as I see. And train.py. What else may I do?

Please post your config and the execution command. I don’t think there’s enough information in what you posted for most to help you.

I am using that Notebook:



and that’s how my ‘tree’ looks like.

Ok, I am trying right now that code execution on colab, let’s see what happens

I reinstalled the system, installed PIP instead of conda, having both version of Python.
Now I am using pure Jupyter Notebook.
Do you know what I should do? I mean, how to fix that problem? I am a little bit tired of trying different methods to run the model… :frowning:

!python setup.py install

running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-26209.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python2.7/dist-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.

@shad94 I’m sorry to hear about these ongoing issues.

Whilst there have been a variety of problems, with the more recent ones you seem to be running into issues that are largely outside the scope of this project. It might be best to research them on Google or even simply read the advice linked to in your error message in this case.

Also based on your latest output I see you’ve used Python 2.7 - I wouldn’t recommend that, for any projects, given it’ll be EOL shortly: https://pythonclock.org/ (this isn’t the cause of your problems above I’m sure, but you’ll run into yet more soon enough if you stick with Python 2 unless you’ve a compelling reason to)

Also, you are not root. Create an environment and you should be able to install everything just fine.

It is pretty strange (ok, I set Python 3.6 as my MAIN one at the system), but I should have all persmissions since I have root, sudo and adm:
Selection_001

The error is the same, just version of python has changed.

Could you try sudo python setup.py install?

You should not be getting the permission error, but I believe you will get a python version error. At the very least, you’ll know if you can set up a user env to fix this.


Still getting nothing.
I also checked Python version:
Selection_003
Maybe should I set up virtual env…?

I do not know what to do now…

So that looks like it ran without errors when you used sudo, right?