Synthetic test sentence TypeError: bad operand type for abs(): 'NoneType' error

I’m training with the LJSpeech dataset and after about the 50th epoch I get the following error when it tries to generate the test sentences.

File "train.py", line 502, in evaluate
ap.save_wav(wav, file_path)
File "/home/username/Audio/TTS/tts_namespace/TTS/utils/audio.py", line 58, in save_wav
wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav))))
TypeError: bad operand type for abs(): 'NoneType'
Traceback (most recent call last):
File "train.py", line 502, in evaluate
ap.save_wav(wav, file_path)
File "/home/username/Audio/TTS/tts_namespace/TTS/utils/audio.py", line 58, in save_wav
wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav))))
TypeError: bad operand type for abs(): 'NoneType'
Traceback (most recent call last):
File "train.py", line 502, in evaluate
ap.save_wav(wav, file_path)
File "/home/username/Audio/TTS/tts_namespace/TTS/utils/audio.py", line 58, in save_wav
wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav))))
TypeError: bad operand type for abs(): 'NoneType'
Traceback (most recent call last):
File "train.py", line 502, in evaluate
ap.save_wav(wav, file_path)
 File "/home/username/Audio/TTS/tts_namespace/TTS/utils/audio.py", line 58, in save_wav
wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav))))
TypeError: bad operand type for abs(): 'NoneType'

Doing a little digging I notice the code in utils/synthesis.py and it’s not getting into the loop (if use_griffin_lim:) and it returns ‘wav’ as None and that value makes it’s way to the save_wav code in utils/audio.py and causes the error.

wav = None
if use_griffin_lim:
    print("We are using griffin_lim.")
    wav = inv_spectrogram(postnet_output, ap, CONFIG)
    # trim silence
    if do_trim_silence:
        wav = trim_silence(wav, ap)
print("In utils/synthesis is wav still None: " + str(wav))
return wav, alignment, decoder_output, postnet_output, stop_tokens

Is there somewhere that I need to set use_griffin_lim? config.json maybe?

This is already fixed in the current build. But you can add


to train.py

This should fix your issue