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 "", 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:

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 develop`

Interesting, because I installed TTS with command:

python develop

and I got different errors:

File “”, line 704, in
File “”, 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
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 "", line 704, in <module>
  File "", line 615, in main
    global_step, epoch)
  File "", line 100, in train
    for num_iter, data in enumerate(data_loader):
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/", line 819, in __next__
    return self._process_data(data)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/", line 846, in _process_data
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/", 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/", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/", 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/", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/marta/Desktop/inż/TTS/tts_namespace/TTS/datasets/", line 164, in __getitem__
    return self.load_data(idx)
  File "/home/marta/Desktop/inż/TTS/tts_namespace/TTS/datasets/", 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/", line 68, in load_wav
    audio = self.ap.load_wav(filename)
  File "/home/marta/Desktop/inż/TTS/tts_namespace/TTS/utils/", line 239, in load_wav
    x, sr =
  File "/home/marta/anaconda3/lib/python3.7/site-packages/", line 257, in read
    subtype, endian, format, closefd) as f:
  File "/home/marta/anaconda3/lib/python3.7/site-packages/", line 627, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/home/marta/anaconda3/lib/python3.7/site-packages/", line 1182, in _open
    "Error opening {0!r}: ".format(
  File "/home/marta/anaconda3/lib/python3.7/site-packages/", 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 "", line 704, in <module>
  File "", line 615, in main
    global_step, epoch)
  File "", line 163, in train
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/nn/modules/", 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/", line 30, in forward
    loss = loss / mask.sum()
  File "/home/marta/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/", line 66, in handler

Starting training again:

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

Everything has to do with TORCH, as I see. And 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 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:


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

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

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: (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:

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

Could you try sudo python 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:
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?