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 timestamp support #11591

Merged
merged 10 commits into from
Dec 20, 2024
Merged

add timestamp support #11591

merged 10 commits into from
Dec 20, 2024

Conversation

kevinhu-nv
Copy link
Collaborator

@kevinhu-nv kevinhu-nv commented Dec 13, 2024

What does this PR do ?

Add support for parsing timestamp data for training.

Collection: [Note which collection this PR will affect]

Changelog

  • Filter out transcription with text by regex
  • Tokenize word by word and insert start and end timestamps for each word

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • [X ] New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

if has_no_timestamp:
return super().text_to_ids(text_no_eos, lang_id) + [self.eos_id]
else:
word_text = time_pattern.sub("", text_no_eos).strip()
Copy link
Collaborator

Choose a reason for hiding this comment

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

please refactor into a method def _text_with_timestamps_to_ids(...) and use return self._text_with_timestamps_to_ids(...) here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

if time_index < len(time_ids) and result_ids[-1] != (time_ids[-1]):
result_ids.append(time_ids[-1])
return result_ids + [self.eos_id]

return super().text_to_ids(text, lang_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

you missed this branch (when lang_id isn't CANARY_SPECIAL_TOKENIZER and the text doesn't end in EOS) - it also needs to support tokenizing timestamps

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for catching that - fixed.

Copy link
Collaborator

@pzelasko pzelasko left a comment

Choose a reason for hiding this comment

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

Please add a unit test showing how a transcript with timestamp gets correctly tokenized (see tests/collections/asr/test_asr_multitask_model_bpe.py for reference tests you can use as a starting point)

@github-actions github-actions bot added the ASR label Dec 16, 2024
@kevinhu-nv
Copy link
Collaborator Author

PTAL @pzelasko

pzelasko
pzelasko previously approved these changes Dec 18, 2024
kevinhu-nv and others added 3 commits December 18, 2024 06:41
@kevinhu-nv
Copy link
Collaborator Author

@pzelasko Can you approve again? Rebased the repo for the tests.

@kevinhu-nv
Copy link
Collaborator Author

@titu1994 @stevehuang52 Could you take a look to trigger the workflow checks?

@kevinhu-nv kevinhu-nv enabled auto-merge (squash) December 18, 2024 23:10
Copy link
Contributor

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.


Your code was analyzed with PyLint. The following annotations have been identified:

************* Module nemo.collections.common.tokenizers.canary_tokenizer
nemo/collections/common/tokenizers/canary_tokenizer.py:133:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/common/tokenizers/canary_tokenizer.py:56:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/tokenizers/canary_tokenizer.py:60:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/tokenizers/canary_tokenizer.py:64:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/tokenizers/canary_tokenizer.py:68:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/tokenizers/canary_tokenizer.py:158:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/common/tokenizers/canary_tokenizer.py:164:4: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.42/10

Mitigation guide:

  • Add sensible and useful docstrings to functions and methods
  • For trivial methods like getter/setters, consider adding # pylint: disable=C0116 inside the function itself
  • To disable multiple functions/methods at once, put a # pylint: disable=C0116 before the first and a # pylint: enable=C0116 after the last.

By applying these rules, we reduce the occurance of this message in future.

Thank you for improving NeMo's documentation!

@kevinhu-nv kevinhu-nv merged commit 24b9e92 into NVIDIA:main Dec 20, 2024
188 of 191 checks passed
BoxiangW pushed a commit that referenced this pull request Dec 20, 2024
* add timestamp support

Signed-off-by: kevinhu <[email protected]>

* Add unit test, fix a branch, and refactor.

Signed-off-by: kevinhu <[email protected]>

* Apply isort and black reformatting

Signed-off-by: kevinhu-nv <[email protected]>
Signed-off-by: kevinhu <[email protected]>

* Apply isort and black reformatting

Signed-off-by: kevinhu-nv <[email protected]>

---------

Signed-off-by: kevinhu <[email protected]>
Signed-off-by: kevinhu-nv <[email protected]>
Co-authored-by: kevinhu-nv <[email protected]>
BoxiangW pushed a commit that referenced this pull request Dec 23, 2024
* add timestamp support

Signed-off-by: kevinhu <[email protected]>

* Add unit test, fix a branch, and refactor.

Signed-off-by: kevinhu <[email protected]>

* Apply isort and black reformatting

Signed-off-by: kevinhu-nv <[email protected]>
Signed-off-by: kevinhu <[email protected]>

* Apply isort and black reformatting

Signed-off-by: kevinhu-nv <[email protected]>

---------

Signed-off-by: kevinhu <[email protected]>
Signed-off-by: kevinhu-nv <[email protected]>
Co-authored-by: kevinhu-nv <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants