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

Add aishell recipe #30

Merged
merged 16 commits into from
Nov 18, 2021
Merged

Add aishell recipe #30

merged 16 commits into from
Nov 18, 2021

Conversation

pkufool
Copy link
Collaborator

@pkufool pkufool commented Aug 30, 2021

Add aishell recipe to icefall. It contains two models now, one is phone based Tdnn-Lstm model, the other is char based (with chinese chars as modelling units) comformer-ctc model.

The decoding results seems not as good as expected now, I am still tuning the models.

TODOs:

  • update results and documents.
  • add pre-trained models

@fanlu
Copy link
Contributor

fanlu commented Sep 19, 2021

I have an error with the newest master branch of k2.

2021-09-19 09:40:39,362 INFO [decode.py:419] Decoding started
2021-09-19 09:40:39,362 INFO [decode.py:420] {'exp_dir': PosixPath('conformer_ctc/exp'), 'lang_dir': PosixPath('data/lang_char'), 'lm_dir': PosixPath('data/lm'), 'subsampling_factor': 4, 'feature_dim': 80, 'nhead': 4, 'attention_dim': 512, 'num_en$
oder_layers': 12, 'num_decoder_layers': 6, 'vgg_frontend': False, 'use_feat_batchnorm': True, 'search_beam': 20, 'output_beam': 7, 'min_active_states': 30, 'max_active_states': 10000, 'use_double_scores': True, 'epoch': 40, 'avg': 18, 'method': 'a$
tention-decoder', 'num_paths': 100, 'lattice_score_scale': 0.5, 'export': False, 'feature_dir': PosixPath('data/fbank'), 'max_duration': 20, 'bucketing_sampler': True, 'num_buckets': 30, 'concatenate_cuts': False, 'duration_factor': 1.0, 'gap': 1.$
, 'on_the_fly_feats': False, 'shuffle': True, 'return_cuts': True, 'num_workers': 2}
2021-09-19 09:40:39,633 INFO [lexicon.py:113] Loading pre-compiled data/lang_char/Linv.pt
2021-09-19 09:40:39,834 INFO [decode.py:430] device: cuda:0
2021-09-19 09:40:50,195 INFO [decode.py:470] averaging ['conformer_ctc/exp/epoch-23.pt', 'conformer_ctc/exp/epoch-24.pt', 'conformer_ctc/exp/epoch-25.pt', 'conformer_ctc/exp/epoch-26.pt', 'conformer_ctc/exp/epoch-27.pt', 'conformer_ctc/exp/epoch-2$
.pt', 'conformer_ctc/exp/epoch-29.pt', 'conformer_ctc/exp/epoch-30.pt', 'conformer_ctc/exp/epoch-31.pt', 'conformer_ctc/exp/epoch-32.pt', 'conformer_ctc/exp/epoch-33.pt', 'conformer_ctc/exp/epoch-34.pt', 'conformer_ctc/exp/epoch-35.pt', 'conformer$
ctc/exp/epoch-36.pt', 'conformer_ctc/exp/epoch-37.pt', 'conformer_ctc/exp/epoch-38.pt', 'conformer_ctc/exp/epoch-39.pt', 'conformer_ctc/exp/epoch-40.pt']
2021-09-19 09:41:17,977 INFO [decode.py:483] Number of model parameters: 115125888
[F] /asr_storage/fanlu/k2/k2/csrc/array.h:501:void k2::Array1<T>::Init(k2::ContextPtr, int32_t, k2::Dtype) [with T = int; k2::ContextPtr = std::shared_ptr<k2::Context>; int32_t = int] Check failed: size >= 0 (-119123572 vs. 0) Array size MUST be g$
eater than or equal to 0, given :-119123572


[ Stack-Trace: ]
/asr_storage/fanlu/k2/build_release/lib/libk2_log.so(k2::internal::GetStackTrace()+0x3c) [0x2af6a59029fc]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::internal::Logger::~Logger()+0x2a) [0x2af6a40b037a]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::Array1<int>::Init(std::shared_ptr<k2::Context>, int, k2::Dtype)+0x26d) [0x2af6a40c56dd]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(+0x25a19d) [0x2af6a425619d]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(+0x272d92) [0x2af6a426ed92]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::Index(k2::RaggedShape&, int, k2::Array1<int> const&, k2::Array1<int>*)+0x1b2) [0x2af6a4270eb2]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x147977) [0x2af6a329e977]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x1197b0) [0x2af6a32707b0]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x10be3d) [0x2af6a3262e3d]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x10c08e) [0x2af6a326308e]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x24663) [0x2af6a317b663]

@danpovey
Copy link
Collaborator

danpovey commented Sep 19, 2021 via email

@danpovey
Copy link
Collaborator

danpovey commented Sep 19, 2021 via email

@danpovey
Copy link
Collaborator

danpovey commented Sep 19, 2021 via email

@csukuangfj
Copy link
Collaborator

csukuangfj commented Sep 19, 2021

I have an error with the newest master branch of k2.


2021-09-19 09:40:39,362 INFO [decode.py:419] Decoding started

2021-09-19 09:40:39,362 INFO [decode.py:420] {'exp_dir': PosixPath('conformer_ctc/exp'), 'lang_dir': PosixPath('data/lang_char'), 'lm_dir': PosixPath('data/lm'), 'subsampling_factor': 4, 'feature_dim': 80, 'nhead': 4, 'attention_dim': 512, 'num_en$

oder_layers': 12, 'num_decoder_layers': 6, 'vgg_frontend': False, 'use_feat_batchnorm': True, 'search_beam': 20, 'output_beam': 7, 'min_active_states': 30, 'max_active_states': 10000, 'use_double_scores': True, 'epoch': 40, 'avg': 18, 'method': 'a$

tention-decoder', 'num_paths': 100, 'lattice_score_scale': 0.5, 'export': False, 'feature_dir': PosixPath('data/fbank'), 'max_duration': 20, 'bucketing_sampler': True, 'num_buckets': 30, 'concatenate_cuts': False, 'duration_factor': 1.0, 'gap': 1.$

, 'on_the_fly_feats': False, 'shuffle': True, 'return_cuts': True, 'num_workers': 2}

2021-09-19 09:40:39,633 INFO [lexicon.py:113] Loading pre-compiled data/lang_char/Linv.pt

2021-09-19 09:40:39,834 INFO [decode.py:430] device: cuda:0

2021-09-19 09:40:50,195 INFO [decode.py:470] averaging ['conformer_ctc/exp/epoch-23.pt', 'conformer_ctc/exp/epoch-24.pt', 'conformer_ctc/exp/epoch-25.pt', 'conformer_ctc/exp/epoch-26.pt', 'conformer_ctc/exp/epoch-27.pt', 'conformer_ctc/exp/epoch-2$

.pt', 'conformer_ctc/exp/epoch-29.pt', 'conformer_ctc/exp/epoch-30.pt', 'conformer_ctc/exp/epoch-31.pt', 'conformer_ctc/exp/epoch-32.pt', 'conformer_ctc/exp/epoch-33.pt', 'conformer_ctc/exp/epoch-34.pt', 'conformer_ctc/exp/epoch-35.pt', 'conformer$

ctc/exp/epoch-36.pt', 'conformer_ctc/exp/epoch-37.pt', 'conformer_ctc/exp/epoch-38.pt', 'conformer_ctc/exp/epoch-39.pt', 'conformer_ctc/exp/epoch-40.pt']

2021-09-19 09:41:17,977 INFO [decode.py:483] Number of model parameters: 115125888

[F] /asr_storage/fanlu/k2/k2/csrc/array.h:501:void k2::Array1<T>::Init(k2::ContextPtr, int32_t, k2::Dtype) [with T = int; k2::ContextPtr = std::shared_ptr<k2::Context>; int32_t = int] Check failed: size >= 0 (-119123572 vs. 0) Array size MUST be g$

eater than or equal to 0, given :-119123572





[ Stack-Trace: ]

/asr_storage/fanlu/k2/build_release/lib/libk2_log.so(k2::internal::GetStackTrace()+0x3c) [0x2af6a59029fc]

/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::internal::Logger::~Logger()+0x2a) [0x2af6a40b037a]

/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::Array1<int>::Init(std::shared_ptr<k2::Context>, int, k2::Dtype)+0x26d) [0x2af6a40c56dd]

/asr_storage/fanlu/k2/build_release/lib/libk2context.so(+0x25a19d) [0x2af6a425619d]

/asr_storage/fanlu/k2/build_release/lib/libk2context.so(+0x272d92) [0x2af6a426ed92]

/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::Index(k2::RaggedShape&, int, k2::Array1<int> const&, k2::Array1<int>*)+0x1b2) [0x2af6a4270eb2]

/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x147977) [0x2af6a329e977]

/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x1197b0) [0x2af6a32707b0]

/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x10be3d) [0x2af6a3262e3d]

/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x10c08e) [0x2af6a326308e]

/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x24663) [0x2af6a317b663]

There are instructions at the end of the log, telling you how to use gdb to debug your Python code.

@csukuangfj
Copy link
Collaborator

Are there Python stack traces at the end of the log that are not posted?

@fanlu
Copy link
Contributor

fanlu commented Sep 22, 2021

@csukuangfj the end of the log is

python conformer_ctc/decode.py --lattice-score-scale 0.5                                --epoch 40                                --avg 18                                --method attention-decoder
                      --max-duration 20                                --num-paths 100
2021-09-19 09:40:39,362 INFO [decode.py:419] Decoding started
2021-09-19 09:40:39,362 INFO [decode.py:420] {'exp_dir': PosixPath('conformer_ctc/exp'), 'lang_dir': PosixPath('data/lang_char'), 'lm_dir': PosixPath('data/lm'), 'subsampling_factor': 4, 'feature_dim': 80, 'nhead': 4, 'attention_dim': 512, 'num_enc
oder_layers': 12, 'num_decoder_layers': 6, 'vgg_frontend': False, 'use_feat_batchnorm': True, 'search_beam': 20, 'output_beam': 7, 'min_active_states': 30, 'max_active_states': 10000, 'use_double_scores': True, 'epoch': 40, 'avg': 18, 'method': 'at
tention-decoder', 'num_paths': 100, 'lattice_score_scale': 0.5, 'export': False, 'feature_dir': PosixPath('data/fbank'), 'max_duration': 20, 'bucketing_sampler': True, 'num_buckets': 30, 'concatenate_cuts': False, 'duration_factor': 1.0, 'gap': 1.0
, 'on_the_fly_feats': False, 'shuffle': True, 'return_cuts': True, 'num_workers': 2}
2021-09-19 09:40:39,633 INFO [lexicon.py:113] Loading pre-compiled data/lang_char/Linv.pt
2021-09-19 09:40:39,834 INFO [decode.py:430] device: cuda:0
2021-09-19 09:40:50,195 INFO [decode.py:470] averaging ['conformer_ctc/exp/epoch-23.pt', 'conformer_ctc/exp/epoch-24.pt', 'conformer_ctc/exp/epoch-25.pt', 'conformer_ctc/exp/epoch-26.pt', 'conformer_ctc/exp/epoch-27.pt', 'conformer_ctc/exp/epoch-28
.pt', 'conformer_ctc/exp/epoch-29.pt', 'conformer_ctc/exp/epoch-30.pt', 'conformer_ctc/exp/epoch-31.pt', 'conformer_ctc/exp/epoch-32.pt', 'conformer_ctc/exp/epoch-33.pt', 'conformer_ctc/exp/epoch-34.pt', 'conformer_ctc/exp/epoch-35.pt', 'conformer_
ctc/exp/epoch-36.pt', 'conformer_ctc/exp/epoch-37.pt', 'conformer_ctc/exp/epoch-38.pt', 'conformer_ctc/exp/epoch-39.pt', 'conformer_ctc/exp/epoch-40.pt']
2021-09-19 09:41:17,977 INFO [decode.py:483] Number of model parameters: 115125888
[F] /asr_storage/fanlu/k2/k2/csrc/array.h:501:void k2::Array1<T>::Init(k2::ContextPtr, int32_t, k2::Dtype) [with T = int; k2::ContextPtr = std::shared_ptr<k2::Context>; int32_t = int] Check failed: size >= 0 (-119123572 vs. 0) Array size MUST be gr
eater than or equal to 0, given :-119123572


[ Stack-Trace: ]
/asr_storage/fanlu/k2/build_release/lib/libk2_log.so(k2::internal::GetStackTrace()+0x3c) [0x2af6a59029fc]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::internal::Logger::~Logger()+0x2a) [0x2af6a40b037a]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::Array1<int>::Init(std::shared_ptr<k2::Context>, int, k2::Dtype)+0x26d) [0x2af6a40c56dd]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(+0x25a19d) [0x2af6a425619d]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(+0x272d92) [0x2af6a426ed92]
/asr_storage/fanlu/k2/build_release/lib/libk2context.so(k2::Index(k2::RaggedShape&, int, k2::Array1<int> const&, k2::Array1<int>*)+0x1b2) [0x2af6a4270eb2]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x147977) [0x2af6a329e977]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x1197b0) [0x2af6a32707b0]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x10be3d) [0x2af6a3262e3d]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x10c08e) [0x2af6a326308e]
/asr_storage/fanlu/k2/build_release/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x24663) [0x2af6a317b663]
python(PyCFunction_Call+0x58) [0x558070ade348]
python(_PyObject_MakeTpCall+0x23c) [0x558070acddbc]
python(+0x19a74c) [0x558070b2474c]
python(+0x10343c) [0x558070a8d43c]
python(_PyEval_EvalCodeWithName+0x300) [0x558070b23270]
python(_PyFunction_Vectorcall+0x1e3) [0x558070b240a3]
python(+0x10343c) [0x558070a8d43c]
python(_PyEval_EvalCodeWithName+0x8b1) [0x558070b23821]
python(_PyFunction_Vectorcall+0x1e3) [0x558070b240a3]
python(+0x10343c) [0x558070a8d43c]
python(_PyEval_EvalCodeWithName+0x300) [0x558070b23270]
python(_PyFunction_Vectorcall+0x1e3) [0x558070b240a3]
python(+0x10343c) [0x558070a8d43c]
python(_PyFunction_Vectorcall+0x10b) [0x558070b23fcb]
python(PyObject_Call+0x414) [0x558070ace754]
python(_PyEval_EvalFrameDefault+0x1fe6) [0x558070b570b6]
python(_PyEval_EvalCodeWithName+0x8b1) [0x558070b23821]
python(_PyFunction_Vectorcall+0x1e3) [0x558070b240a3]
python(+0x1035db) [0x558070a8d5db]
python(_PyEval_EvalCodeWithName+0x300) [0x558070b23270]
python(PyEval_EvalCode+0x23) [0x558070bb8543]
python(+0x22e5e4) [0x558070bb85e4]
python(+0x254854) [0x558070bde854]
python(+0x115390) [0x558070a9f390]
python(PyRun_SimpleFileExFlags+0x384) [0x558070aa20d2]
python(+0x118bf0) [0x558070aa2bf0]
python(Py_BytesMain+0x39) [0x558070be1a09]
/usr/lib64/libc.so.6(__libc_start_main+0xf5) [0x2af5752c8495]
python(+0x1e6fe5) [0x558070b70fe5]

Traceback (most recent call last):
  File "conformer_ctc/decode.py", line 515, in <module>
    main()
  File "/asr_storage/fanlu/miniconda3/envs/k2_cu111/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "conformer_ctc/decode.py", line 494, in main
    results_dict = decode_dataset(
  File "conformer_ctc/decode.py", line 330, in decode_dataset
    hyps_dict = decode_one_batch(
  File "conformer_ctc/decode.py", line 266, in decode_one_batch
    best_path_dict = rescore_with_attention_decoder(
  File "/mnt/cfs1_alias2/asr/users/fanlu/task/icefall/icefall/decode.py", line 826, in rescore_with_attention_decoder
    token_seq, _ = token_seq.index(
RuntimeError:
    Some bad things happened. Please read the above error messages and stack
    trace. If you are using Python, the following command may be helpful:

      gdb --args python /path/to/your/code.py

    (You can use `gdb` to debug the code. Please consider compiling
    a debug version of k2.).

    If you are unable to fix it, please open an issue at:

      https://github.com/k2-fsa/k2/issues/new

@csukuangfj
Copy link
Collaborator

File "/mnt/cfs1_alias2/asr/users/fanlu/task/icefall/icefall/decode.py", line 826, in rescore_with_attention_decoder
token_seq, _ = token_seq.index(
RuntimeError:

Could you set a pdb breakpoint at line 826 and print the shape information of token_seq and new2old?

Some useful instructions are:

import pdb
pdb.set_trace()
print(token_seq.shape.tot_sizes())
print(new2old.shape)
# token_seq, _ = token_seq.index(...

@fanlu
Copy link
Contributor

fanlu commented Sep 22, 2021

File "/mnt/cfs1_alias2/asr/users/fanlu/task/icefall/icefall/decode.py", line 826, in rescore_with_attention_decoder
token_seq, _ = token_seq.index(
RuntimeError:

Could you set a pdb breakpoint at line 826 and print the shape information of token_seq and new2old?

Some useful instructions are:

import pdb
pdb.set_trace()
print(token_seq.shape.tot_sizes())
print(new2old.shape)
# token_seq, _ = token_seq.index(...

image

@csukuangfj
Copy link
Collaborator

Does this token_seq cause the above runtime error?
Could you also show

print(new2old.max(), new2old.min())

@fanlu
Copy link
Contributor

fanlu commented Sep 22, 2021

Does this token_seq cause the above runtime error?
Could you also show

print(new2old.max(), new2old.min())

image
yes,token_seq.index cause the above runtime error

@csukuangfj
Copy link
Collaborator

We resolved it offline.

It is a bug that has been fixed in #50

# |-- lexicon.txt
# `-- speaker.info

if [ ! -d $dl_dir/aishell/wav ]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$dl_dir/aishell/data_aishell/wav

@pkufool pkufool added the ready label Nov 17, 2021
@pkufool pkufool changed the title WIP: Add aishell recipe Add aishell recipe Nov 17, 2021
@pkufool
Copy link
Collaborator Author

pkufool commented Nov 17, 2021

Latest result:
image

Tensorboard: https://tensorboard.dev/experiment/WE1DocDqRRCOSAgmGyClhg/#scalars

image

@pkufool pkufool added ready and removed ready labels Nov 18, 2021
@pkufool pkufool merged commit 30c43b7 into k2-fsa:master Nov 18, 2021
@csukuangfj
Copy link
Collaborator

Could you also update https://github.com/k2-fsa/icefall/blob/master/README.md ?

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

Successfully merging this pull request may close these issues.

4 participants