TensorSpeech / TensorFlowTTS

:stuck_out_tongue_closed_eyes: TensorFlowTTS: Real-Time State-of-the-art Speech Synthesis for Tensorflow 2 (supported including English, French, Korean, Chinese, German and Easy to adapt for other languages)
https://tensorspeech.github.io/TensorFlowTTS/
Apache License 2.0
3.85k stars 815 forks source link

how can i change num_mel in tacotron2? #401

Closed hynkang closed 3 years ago

hynkang commented 4 years ago

I just want to change dimension of mel-spectrum from 80 to 20 in tacotron2 so i change the value as n_mels = 20 in conf/tacotron2.v1.yaml

but i've got the error message

Exception has occurred: InvalidArgumentError

Incompatible shapes: [1,80] vs. [1,20] [Op:AddV2] File "/home/TensorFlowTTS/examples/tacotron2/train_tacotron2.py", line 437, in main tacotron2._build() File "/home/TensorFlowTTS/examples/tacotron2/train_tacotron2.py", line 488, in main()

Even though I change the value of mel_outputs (1, 50, 80) in def _build() as mel_outputs (1, 50, 20) i've got the same error

def _build(self):
    input_ids = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9]])
    input_lengths = np.array([9])
    speaker_ids = np.array([0])
    mel_outputs = np.random.normal(size=(1, 50, 80)).astype(np.float32) #
    mel_lengths = np.array([50])
    self(
        input_ids,
        input_lengths,
        speaker_ids,
        mel_outputs,
        mel_lengths,
        10,
        training=True,
    )

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.6/dist-packages/tensorflow_tts/models/tacotron2.py", line 796, in _build training=True, File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py", line 985, in call outputs = call_fn(inputs, *args, *kwargs) File "/usr/local/lib/python3.6/dist-packages/tensorflow_tts/models/tacotron2.py", line 856, in call enable_tflite_convertible=self.enable_tflite_convertible, File "/usr/local/lib/python3.6/dist-packages/tensorflow_tts/utils/decoder.py", line 281, in dynamic_decode swap_memory=swap_memory, File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py", line 574, in new_func return func(args, *kwargs) File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2499, in while_loop_v2 return_same_structure=True) File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2735, in while_loop loop_vars = body(loop_vars) File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2726, in body = lambda i, lv: (i + 1, orig_body(*lv)) File "/usr/local/lib/python3.6/dist-packages/tensorflow_tts/utils/decoder.py", line 182, in body time, inputs, state, training File "/usr/local/lib/python3.6/dist-packages/tensorflow_tts/models/tacotron2.py", line 736, in step stop_token_prediction=stop_tokens, File "/usr/local/lib/python3.6/dist-packages/tensorflow_tts/models/tacotron2.py", line 319, in next_inputs

  • (1.0 - self._ratio) outputs[:, -self.config.n_mels :] File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py", line 1124, in binary_op_wrapper return func(x, y, name=name) File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper return target(args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py", line 1446, in _add_dispatch return gen_math_ops.add_v2(x, y, name=name) File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 486, in add_v2 _ops.raise_from_not_ok_status(e, name) File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 6843, in raise_from_not_ok_status six.raise_from(core._status_to_exception(e.code, message), None) File "", line 3, in raise_from tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [1,80] vs. [1,20] [Op:AddV2]
OnceJune commented 4 years ago

you might need to redo preprocess to get 20 dim mel.

hynkang commented 4 years ago

you might need to redo preprocess to get 20 dim mel.

I already redo preprocess but it does not work

dathudeptrai commented 4 years ago

you should change the n_mels value in config.yaml also. And also here (https://github.com/TensorSpeech/TensorFlowTTS/blob/master/examples/tacotron2/tacotron_dataset.py#L227-L229)

hynkang commented 3 years ago

oh...the reason of failure was my tacotron2 in tensorflowTTS refers internal package code ( /usr/local/lib/python3.6/dist-packages/tensorflow_tts/ ) ... while fastspeech2 code does not refers internal package code.. why do they refer different locations?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.