-
Notifications
You must be signed in to change notification settings - Fork 110
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
Refactoring streaming transducer #78
Conversation
@csukuangfj I started only for streaming rnn-t at the moment. Could you have a quick look and tell me what you think about it. If this refactoring is satisfactory for you, I will do the same for the other models. |
sherpa/bin/streaming_pruned_transducer_statelessX/beam_search.py
Outdated
Show resolved
Hide resolved
sherpa/bin/streaming_pruned_transducer_statelessX/beam_search.py
Outdated
Show resolved
Hide resolved
Thanks! It looks good to me. |
sherpa/bin/streaming_pruned_transducer_statelessX/beam_search.py
Outdated
Show resolved
Hide resolved
@csukuangfj The PR should be ready to be reviewed. I tested all the streaming models but not the offline yet (will do next week). |
offline_asr.py does not involve network communication. It's standalone, taking sound files as inputs and outputs text. |
Thanks. I will review it when I come to home(in 30 minutes). |
Great ! Thank you ! There is no rush |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Left some minor comments.
sherpa/bin/conv_emformer_transducer_stateless2/streaming_server.py
Outdated
Show resolved
Hide resolved
Sorry, there are conflicts now. |
@csukuangfj I will take care of the conflicts, hopefully it won't be too bad. |
@csukuangfj Just rebased, it was quite straightforward. |
sherpa/bin/conv_emformer_transducer_stateless2/streaming_server.py
Outdated
Show resolved
Hide resolved
I suggest ignoring errors reported by flake8 in https://github.com/k2-fsa/sherpa/runs/7479612670?check_suite_focus=true We can edit https://github.com/k2-fsa/sherpa/blob/master/.flake8 to do that. (Either ignore the whole file or ignore You can use |
if decoding_method == "greedy_search": | ||
nn_and_decoding_func = run_model_and_do_greedy_search | ||
self.beam_search = GreedySearchOffline( | ||
self.model, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI complains
https://github.com/k2-fsa/sherpa/runs/7479632765?check_suite_focus=true
2022-07-23 08:00:57,024 INFO [offline_server.py:258] Using device: cpu
Traceback (most recent call last):
File "sherpa/bin/pruned_transducer_statelessX/offline_server.py", line 675, in <module>
main()
File "/opt/hostedtoolcache/Python/3.7.13/x64/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line [28](https://github.com/k2-fsa/sherpa/runs/7479632765?check_suite_focus=true#step:11:29), in decorate_context
return func(*args, **kwargs)
File "sherpa/bin/pruned_transducer_statelessX/offline_server.py", line 643, in main
num_active_paths=num_active_paths,
File "sherpa/bin/pruned_transducer_statelessX/offline_server.py", line [29](https://github.com/k2-fsa/sherpa/runs/7479632765?check_suite_focus=true#step:11:30)5, in __init__
self.model,
AttributeError: 'OfflineServer' object has no attribute 'model'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't test this part of the code yet. I need to do some extra testing before moving to merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@csukuangfj Seems like everything passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
Merging
This PR is about refactoring beam search code for offline and online.
The idea is to create one class per beam search type. When we add new beam search (fast_beam_search_nbest, etc), we can inherit the necessary class and write as little code as possible.