Tacotron-2: An AttributeError?

Created on 30 Apr 2019  路  12Comments  路  Source: Rayhane-mamah/Tacotron-2

Hi, thx @Rayhane-mamah for this great job first.
When running python synthesize.py --model='Tacotron', i receive en error as follow:

Starting Synthesis
Traceback (most recent call last):
File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
return getattr(obj, method)(args, *kwds)
AttributeError: 'list' object has no attribute 'round'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "synthesize.py", line 101, in
main()
File "synthesize.py", line 91, in main
_ = tacotron_synthesize(args, hparams, taco_checkpoint, sentences)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize
return run_eval(args, checkpoint_path, output_dir, hparams, sentences)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval
mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 152, in synthesize
target_lengths = self._get_output_lengths(stop_tokens)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 256, in _get_output_lengths
output_lengths = [row.index(1) if 1 in row else len(row) for row in np.round(stop_tokens).tolist()]
File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2851, in round_
return around(a, decimals=decimals, out=out)
File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2837, in around
return _wrapfunc(a, 'round', decimals=decimals, out=out)
File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc
return _wrapit(obj, method, args, *kwds)
File "/root/anaconda3/envs/tibetan-tts/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit
result = getattr(asarray(obj), method)(args, *kwds)
AttributeError: 'numpy.ndarray' object has no attribute 'rint'

I think i do something wrong. Anyone can help me?

Most helpful comment

This is because mels and linears are lists and numpy cannot apply clip on them.
Changing line 183 of tacotron/synthesizer.py from
linears = np.clip(linears, T2_output_range[0], T2_output_range[1])
to
linears = [np.clip(i, T2_output_range[0], T2_output_range[1]) for i in linears],
line 186 from
mels = np.clip(mels, T2_output_range[0], T2_output_range[1])
to
mels = [np.clip(i, T2_output_range[0], T2_output_range[1]) for i in mels]
and line 296-297 to
output_lengths = [row.index(1) if 1 in row else len(row) for row in [np.round(i).tolist() for i in stop_tokens]]
works for me.

All 12 comments

I have the exact same error, except mine says: 'list' object has no attribute 'clip'. I've tried installing multiple different versions of numpy to no avail.

However, running synthesis on one GPU solved it. If you're training on multiple GPUs, try running synthesis just on one. Hope that helps.

@RytisKumpa I try to run with one GPU, but receive this error:

Starting Synthesis
Traceback (most recent call last):
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
return getattr(obj, method)(args, *kwds)
AttributeError: 'list' object has no attribute 'clip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "synthesize.py", line 101, in
main()
File "synthesize.py", line 91, in main
_ = tacotron_synthesize(args, hparams, taco_checkpoint, sentences)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize
return run_eval(args, checkpoint_path, output_dir, hparams, sentences)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval
mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 157, in synthesize
linears = np.clip(linears, T2_output_range[0], T2_output_range[1])
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 1775, in clip
return _wrapfunc(a, 'clip', a_min, a_max, out=out)
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc
return _wrapit(obj, method, args, *kwds)
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit
result = getattr(asarray(obj), method)(args, *kwds)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

@RytisKumpa It's ok when I train model with one gpu too.

I'm so sorry, but I receive this error again.

Starting Synthesis
Traceback (most recent call last):
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
return getattr(obj, method)(args, *kwds)
AttributeError: 'list' object has no attribute 'clip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "synthesize.py", line 103, in
main()
File "synthesize.py", line 93, in main
_ = tacotron_synthesize(args, hparams, taco_checkpoint, sentences)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize
return run_eval(args, checkpoint_path, output_dir, hparams, sentences)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval
mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None)
File "/data/Rayhane-mamah/Tacotron-2/tacotron/synthesizer.py", line 157, in synthesize
linears = np.clip(linears, T2_output_range[0], T2_output_range[1])
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 1775, in clip
return _wrapfunc(a, 'clip', a_min, a_max, out=out)
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc
return _wrapit(obj, method, args, *kwds)
File "/home/zzy/anaconda3/envs/Tacotron-2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit
result = getattr(asarray(obj), method)(args, *kwds)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I have no idea. Anyone can help me?

I already run synthesis on one GPU.

@RytisKumpa Can u tell me your numpy version? I have already run synthesis on one GPU, but got the same error.

Hmmm, I don't really know then...
My numpy version that it worked with was the same as in the requirements.txt (numpy==1.14.0)
Are you sure you did't change the num of GPUs used in hparams? From the code I can see that somewhere in the loop it returns a list if there are more than one GPU.

Yes, I'm sure. My hparams.py:

tacotron_num_gpus = 1,
wavenet_num_gpus = 1,

I have no idea how to fix it.

Hello,I have the same problem, 'The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()',did you solve it?

Hello. I get the same problem.

Starting Synthesis
0%| | 0/1 [00:00 Traceback (most recent call last):
File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
return getattr(obj, method)(args, *kwds)
AttributeError: 'list' object has no attribute 'clip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "synthesize.py", line 100, in
main()
File "synthesize.py", line 94, in main
synthesize(args, hparams, taco_checkpoint, wave_checkpoint, sentences)
File "synthesize.py", line 36, in synthesize
wavenet_in_dir = tacotron_synthesize(args, hparams, taco_checkpoint, sentences)
File "/home/csanta/tacotron2/Tacotron-2/tacotron/synthesize.py", line 135, in tacotron_synthesize
return run_eval(args, checkpoint_path, output_dir, hparams, sentences)
File "/home/csanta/tacotron2/Tacotron-2/tacotron/synthesize.py", line 67, in run_eval
mel_filenames, speaker_ids = synth.synthesize(texts, basenames, eval_dir, log_dir, None)
File "/home/csanta/tacotron2/Tacotron-2/tacotron/synthesizer.py", line 157, in synthesize
linears = np.clip(linears, T2_output_range[0], T2_output_range[1])
File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 1775, in clip
return _wrapfunc(a, 'clip', a_min, a_max, out=out)
File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc
return _wrapit(obj, method, args, *kwds)
File "/home/csanta/tacotron2/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit
result = getattr(asarray(obj), method)(args, *kwds)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I need to fix it.

Same issue as @sapinedamo. I am using two GPUs and a batch size of 1024

This is because mels and linears are lists and numpy cannot apply clip on them.
Changing line 183 of tacotron/synthesizer.py from
linears = np.clip(linears, T2_output_range[0], T2_output_range[1])
to
linears = [np.clip(i, T2_output_range[0], T2_output_range[1]) for i in linears],
line 186 from
mels = np.clip(mels, T2_output_range[0], T2_output_range[1])
to
mels = [np.clip(i, T2_output_range[0], T2_output_range[1]) for i in mels]
and line 296-297 to
output_lengths = [row.index(1) if 1 in row else len(row) for row in [np.round(i).tolist() for i in stop_tokens]]
works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pandaGst picture pandaGst  路  4Comments

wushicanASL picture wushicanASL  路  3Comments

begeekmyfriend picture begeekmyfriend  路  6Comments

a8568730 picture a8568730  路  6Comments

konek3 picture konek3  路  11Comments