[TTS][refactor] Part 4 - nn.collections.tts.g2p.modules
State: closed | Pull request: yes
Labels: name: TTS

name: common

# What does this PR do ?

Task 4: break down `nemo/collections/tts/g2p/modules.py` and save to `nemo/collections/tts/g2p/models`. The “Modules” concept used by g2p is misleading in comparison to NeMo standards, i.e. modules usually mean `torch.nn.Module` or `NeuralModule`. We should remove any confusion. According to several offline discussion, we finalized below changes,
```
- nemo/collections/tts/g2p/data
  - ctc.py
  - heteronym_classification.py
  - t5.py
- nemo/collections/tts/g2p/models
  - base.py # only contains BaseG2p class in this file.
  - zh_cn_pinyin.py  # move nemo/collections/tts/g2p/modules.py::ChineseG2p class here.
  - en_us_arpabet.py  # move nemo/collections/tts/g2p/modules.py::EnglishG2p class here.
  - i18n_ipa.py  # move nemo/collections/tts/g2p/modules.py::IPAG2P class here. It is designed to support any language when specifying a locale code.
  - ctc.py
  - heteronym_classification.py
  - t5.py
- nemo/collections/tts/g2p/utils.py

- added deprecation notice for nemo/collections/tts/torch/g2ps.py
- renamed nemo/collections/tts/data/tts_dataset.py -> nemo/collections/tts/data/dataset.py
```

```
$ pytest --nightly tests/collections/tts/models/
A valid `test_data.tar.gz` test archive (10445891B) found in the `/home/xueyang/workspace/NeMo/tests/.data` folder.
Setting numba compat : True
===================================================== test session starts ======================================================
platform linux -- Python 3.8.13, pytest-7.1.3, pluggy-1.0.0 -- /home/xueyang/miniconda3/envs/nemo/bin/python
cachedir: .pytest_cache
rootdir: /home/xueyang/workspace/NeMo, configfile: pyproject.toml
plugins: hydra-core-1.2.0, anyio-3.6.1
collected 26 items                                                                                                             

tests/collections/tts/models/test_aligner.py::test_inference[tts_en_radtts_aligner] PASSED                               [  3%]
tests/collections/tts/models/test_aligner.py::test_inference[tts_en_radtts_aligner_ipa] PASSED                           [  7%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch] PASSED                                  [ 11%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch_ipa] PASSED                              [ 15%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch_multispeaker] PASSED                     [ 19%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_singleSpeaker_thorstenNeutral_2102] PASSED [ 23%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_singleSpeaker_thorstenNeutral_2210] PASSED [ 26%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_multispeaker_5] PASSED                   [ 30%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_es_fastpitch_multispeaker] PASSED                     [ 34%]
tests/collections/tts/models/test_fastpitch.py::test_inference[tts_zh_fastpitch_sfspeech] PASSED                         [ 38%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_hifigan] PASSED                                      [ 42%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_lj_hifigan_ft_mixertts] PASSED                       [ 46%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_lj_hifigan_ft_mixerttsx] PASSED                      [ 50%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_hifitts_hifigan_ft_fastpitch] PASSED                 [ 53%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hifigan_singleSpeaker_thorstenNeutral_2102] PASSED   [ 57%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hifigan_singleSpeaker_thorstenNeutral_2210] PASSED   [ 61%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hui_hifigan_ft_fastpitch_multispeaker_5] PASSED      [ 65%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_es_hifigan_ft_fastpitch_multispeaker] PASSED            [ 69%]
tests/collections/tts/models/test_hifigan.py::test_inference[tts_zh_hifigan_sfspeech] PASSED                             [ 73%]
tests/collections/tts/models/test_mixerTTS.py::test_inference[tts_en_lj_mixertts] PASSED                                 [ 76%]
tests/collections/tts/models/test_mixerTTS.py::test_inference[tts_en_lj_mixerttsx] PASSED                                [ 80%]
tests/collections/tts/models/test_tacotron2.py::test_inference[tts_en_tacotron2] PASSED                                  [ 84%]
tests/collections/tts/models/test_univNet.py::test_inference[tts_en_lj_univnet] PASSED                                   [ 88%]
tests/collections/tts/models/test_univNet.py::test_inference[tts_en_libritts_univnet] PASSED                             [ 92%]
tests/collections/tts/models/test_vits.py::test_inference[tts_en_lj_vits] PASSED                                         [ 96%]
tests/collections/tts/models/test_waveGlow.py::test_inference[tts_en_waveglow_88m] PASSED                                [100%]

====================================================== slowest durations =======================================================
26.97s setup    tests/collections/tts/models/test_mixerTTS.py::test_inference[tts_en_lj_mixerttsx]
25.43s setup    tests/collections/tts/models/test_tacotron2.py::test_inference[tts_en_tacotron2]
25.30s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch_ipa]
24.99s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch_multispeaker]
24.87s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch]
24.55s setup    tests/collections/tts/models/test_vits.py::test_inference[tts_en_lj_vits]
23.77s setup    tests/collections/tts/models/test_aligner.py::test_inference[tts_en_radtts_aligner]
23.56s setup    tests/collections/tts/models/test_mixerTTS.py::test_inference[tts_en_lj_mixertts]
22.72s setup    tests/collections/tts/models/test_aligner.py::test_inference[tts_en_radtts_aligner_ipa]
21.13s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_multispeaker_5]
20.04s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_singleSpeaker_thorstenNeutral_22
10]
16.39s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_singleSpeaker_thorstenNeutral_21
02]
2.42s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_hifigan]
2.39s setup    tests/collections/tts/models/test_waveGlow.py::test_inference[tts_en_waveglow_88m]
2.38s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_es_fastpitch_multispeaker]
2.32s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_lj_hifigan_ft_mixertts]
2.31s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_lj_hifigan_ft_mixerttsx]
1.81s call     tests/collections/tts/models/test_mixerTTS.py::test_inference[tts_en_lj_mixerttsx]
1.81s call     tests/collections/tts/models/test_aligner.py::test_inference[tts_en_radtts_aligner]
1.56s setup    tests/collections/tts/models/test_fastpitch.py::test_inference[tts_zh_fastpitch_sfspeech]
1.40s setup    tests/collections/tts/models/test_univNet.py::test_inference[tts_en_libritts_univnet]
1.04s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hui_hifigan_ft_fastpitch_multispeaker_5]
0.99s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hifigan_singleSpeaker_thorstenNeutral_2210]
0.98s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_hifitts_hifigan_ft_fastpitch]
0.98s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_es_hifigan_ft_fastpitch_multispeaker]
0.97s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hifigan_singleSpeaker_thorstenNeutral_2102]
0.97s setup    tests/collections/tts/models/test_hifigan.py::test_inference[tts_zh_hifigan_sfspeech]
0.91s setup    tests/collections/tts/models/test_univNet.py::test_inference[tts_en_lj_univnet]
0.49s call     tests/collections/tts/models/test_vits.py::test_inference[tts_en_lj_vits]
0.47s call     tests/collections/tts/models/test_tacotron2.py::test_inference[tts_en_tacotron2]
0.46s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_zh_fastpitch_sfspeech]
0.28s call     tests/collections/tts/models/test_waveGlow.py::test_inference[tts_en_waveglow_88m]
0.07s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_multispeaker_5]
0.07s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_singleSpeaker_thorstenNeutral_210
2]
0.07s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_de_fastpitch_singleSpeaker_thorstenNeutral_221
0]
0.06s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch]
0.06s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch_ipa]
0.06s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_en_fastpitch_multispeaker]
0.05s call     tests/collections/tts/models/test_mixerTTS.py::test_inference[tts_en_lj_mixertts]
0.05s call     tests/collections/tts/models/test_aligner.py::test_inference[tts_en_radtts_aligner_ipa]
0.03s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_hifigan]
0.03s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hifigan_singleSpeaker_thorstenNeutral_2102]
0.03s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_hifitts_hifigan_ft_fastpitch]
0.03s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hui_hifigan_ft_fastpitch_multispeaker_5]
0.02s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_es_hifigan_ft_fastpitch_multispeaker]
0.02s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_lj_hifigan_ft_mixertts]
0.02s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_en_lj_hifigan_ft_mixerttsx]
0.02s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_de_hifigan_singleSpeaker_thorstenNeutral_2210]
0.02s call     tests/collections/tts/models/test_hifigan.py::test_inference[tts_zh_hifigan_sfspeech]
0.02s call     tests/collections/tts/models/test_fastpitch.py::test_inference[tts_es_fastpitch_multispeaker]
0.02s call     tests/collections/tts/models/test_univNet.py::test_inference[tts_en_lj_univnet]
0.01s call     tests/collections/tts/models/test_univNet.py::test_inference[tts_en_libritts_univnet]

(26 durations < 0.005s hidden.  Use -vv to show these durations.)
================================================ 26 passed in 307.59s (0:05:07) ================================================
```

**Collection**: [Note which collection this PR will affect]

# Changelog 
- Add specific line by line info of high level changes in this PR.

# Usage
* You can potentially add a usage example below

```python
# Add a code snippet demonstrating how to use this 
```

# Before your PR is "Ready for review"
**Pre checks**:
- [x] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [ ] 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**:
- [ ] 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](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
* Related to # (issue)