Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tacotron2 convert onnx issue #103

Open
shakhbozabdigapporov opened this issue Dec 14, 2023 · 5 comments
Open

Tacotron2 convert onnx issue #103

shakhbozabdigapporov opened this issue Dec 14, 2023 · 5 comments

Comments

@shakhbozabdigapporov
Copy link

Hi, Thanks to this repository. I have a trained Text2Speech model(with custom data) on tacotron2 but when I try to convert my pytorch model to onnx, the outputted audio results are not as good as the pytorch model's results.
Also the length of the result audio file with onnx model is bigger than the result from my pytorch model.
I did not face any code errors while converting my model.
I am using the example provided on the espnet_onnx.

on issue 28, the author mentioned the same audio file problem when converting the tacotron2 pytorch model to onnx.
Is there any updates on this issue ?

Thank you!

@Masao-Someki
Copy link
Collaborator

Thank you for reporting your issue @shakhbozabdigapporov. I would like to confirm the following:

  1. What is your ESPnet and ESPnet-ONNX version? Does the same error occur with the latest version?
  2. Do you use vocoder in your model? If so, please check the vocoder_type config. The config file is located in the ~/.cache/espnet_onnx/<your model name>/config.yml. If it was set to not_used, then please check if your vocoder is supported here
  3. Is the sample_rate or other configuration correct?

@shakhbozabdigapporov
Copy link
Author

Thank you for your reply!

  1. I am using ESPnet-ONNX latest version.
  2. The vocoder I am using for my model config is:
    vocoder:
    model_path: .../PWGVocoder.onnx
    vocoder_type: OnnxVocoder
    And it is supported. But I have a trained vocoder as well but the result is the same with my trained vocoder as well.
    The model and the vocoder I am using is taken from this github: https://github.com/IS2AI/Kazakh_TTS.git
  3. The sample rate and other configurations are correct.

The problem is vits model is working perfect with great results when converted to onnx but this model only is not working well.

@Masao-Someki
Copy link
Collaborator

@shakhbozabdigapporov
After some analysis, I came to think that there might be bugs around the decoder part of the Tacotron2 implementation. If it is okay, would you share the tts_conf? I will further investigate the decoder part with your configuration...

@shakhbozabdigapporov
Copy link
Author

shakhbozabdigapporov commented Dec 26, 2023

Thanks for the reply. Here is my train config for tts with Tacotron2 model.
It is working fine with the pth model I have. Just some missing waves(information) while exporting to onnx format.

config: conf/train.yaml
print_config: false
log_level: INFO
dry_run: false
iterator_type: sequence
output_dir: exp/tts_train_raw_char
ngpu: 1
seed: 0
num_workers: 1
num_att_plot: 3
dist_backend: nccl
dist_init_method: env://
dist_world_size: null
dist_rank: null
local_rank: 0
dist_master_addr: null
dist_master_port: null
dist_launcher: null
multiprocessing_distributed: false
unused_parameters: false
sharded_ddp: false
cudnn_enabled: true
cudnn_benchmark: false
cudnn_deterministic: true
collect_stats: false
write_collected_feats: false
max_epoch: 200
patience: null
val_scheduler_criterion:
- valid
- loss
early_stopping_criterion:
- valid
- loss
- min
best_model_criterion:
-   - valid
    - loss
    - min
-   - train
    - loss
    - min
keep_nbest_models: 5
grad_clip: 1.0
grad_clip_type: 2.0
grad_noise: false
accum_grad: 1
no_forward_run: false
resume: true
train_dtype: float32
use_amp: false
log_interval: null
use_tensorboard: true
use_wandb: false
wandb_project: null
wandb_id: null
detect_anomaly: false
pretrain_path: null
init_param: []
freeze_param: []
num_iters_per_epoch: null
batch_size: 20
valid_batch_size: null
batch_bins: 5120000
valid_batch_bins: null
train_shape_file:
- exp/tts_stats_raw_char/train/text_shape.char
- exp/tts_stats_raw_char/train/speech_shape
valid_shape_file:
- exp/tts_stats_raw_char/valid/text_shape.char
- exp/tts_stats_raw_char/valid/speech_shape
batch_type: numel
valid_batch_type: null
fold_length:
- 150
- 204800
sort_in_batch: descending
sort_batch: descending
multiple_iterator: false
chunk_length: 500
chunk_shift_ratio: 0.5
num_cache_chunks: 1024
train_data_path_and_name_and_type:
-   - dump/raw/tr_no_dev/text
    - text
    - text
-   - dump/raw/tr_no_dev/wav.scp
    - speech
    - sound
valid_data_path_and_name_and_type:
-   - dump/raw/dev/text
    - text
    - text
-   - dump/raw/dev/wav.scp
    - speech
    - sound
allow_variable_data_keys: false
max_cache_size: 0.0
max_cache_fd: 32
valid_max_cache_size: null
optim: adam
optim_conf:
    lr: 0.001
    eps: 1.0e-06
    weight_decay: 0.0
scheduler: null
scheduler_conf: {}
token_list:
- <blank>
- <unk>
- <space>
- а
- ы
- е
- н
- т
- р
- і
- л
- с
- д
- қ
- м
- к
- о
- б
- ж
- у
- з
- и
- ғ
- п
- ң
- ш
- й
- г
- .
- ү
- ','
- ө
- ұ
- ә
- '-'
- я
- в
- х
- ц
- ф
- э
- ь
- ю
- a
- i
- ч
- o
- n
- e
- t
- s
- r
- ':'
- l
- c
- d
- u
- k
- p
- m
- ;
- v
- b
- '?'
- z
- f
- g
- h
- һ
- '!'
- ъ
- y
- w
- щ
- q
- /
- j
- x
- ё
- ́
- ̩
- '3'
- '@'
- ü
- '1'
-- '0'
-- ı
- ǵ
- '9'
- '6'
- ý
- ¬
- ̤
- '&'
- ̇
- ç
- '7'
- <sos/eos>
odim: null
model_conf: {}
use_preprocessor: true
token_type: char
bpemodel: null
non_linguistic_symbols: null
cleaner: null
g2p: null
feats_extract: fbank
feats_extract_conf:
    fs: 22050
    fmin: 80
    fmax: 7600
    n_mels: 80
    hop_length: 256
    n_fft: 1024
    win_length: null
normalize: global_mvn
normalize_conf:
    stats_file: exp/tts_stats_raw_char/train/feats_stats.npz
tts: tacotron2
tts_conf:
    embed_dim: 512
    elayers: 1
    eunits: 512
    econv_layers: 3
    econv_chans: 512
    econv_filts: 5
    atype: location
    adim: 512
    aconv_chans: 32
    aconv_filts: 15
    cumulate_att_w: true
    dlayers: 2
    dunits: 1024
    prenet_layers: 2
    prenet_units: 256
    postnet_layers: 5
    postnet_chans: 512
    postnet_filts: 5
    output_activation: null
    use_batch_norm: true
    use_concate: true
    use_residual: false
    dropout_rate: 0.5
    zoneout_rate: 0.1
    reduction_factor: 1
    spk_embed_dim: null
    use_masking: true
    bce_pos_weight: 5.0
    use_guided_attn_loss: true
    guided_attn_loss_sigma: 0.4
    guided_attn_loss_lambda: 1.0
pitch_extract: null
pitch_extract_conf: {}
pitch_normalize: null
pitch_normalize_conf: {}
energy_extract: null
energy_extract_conf: {}
energy_normalize: null
energy_normalize_conf: {}
required:
- output_dir
- token_list
version: 0.9.8
distributed: false

@Masao-Someki
Copy link
Collaborator

Masao-Someki commented Jan 2, 2024

Hello @shakhbozabdigapporov, would you please review the following points? I've thoroughly investigated this issue but couldn't identify any bugs.

  • Could you attempt to reproduce this issue using the pretrained model on the Hugging Face Hub, such as kan-bayashi/ljspeech_tacotron2 (link)? If you encounter the same issue, please share the model name.
  • If this issue isn't reproducible with the mentioned model or others, would you compare the configurations and share the differences? I want to check the difference in configuration.
  • Would you share the melspectrogram generated by the torch mopdel and onnx model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants