[TTS] Add Python 3 type hints and module docstring to helpers.py#15708
Open
shivansh023023 wants to merge 1 commit into
Open
[TTS] Add Python 3 type hints and module docstring to helpers.py#15708shivansh023023 wants to merge 1 commit into
shivansh023023 wants to merge 1 commit into
Conversation
Adds complete type annotations to 26 public functions and a module-level docstring in nemo/collections/tts/parts/utils/helpers.py as required by CONTRIBUTING.md: 'Use Python 3 type hints for every class and method exposed to the user.' Changes: - Added module-level docstring describing the utility module - Added Iterable to typing imports - Annotated 26 public functions covering: attention binarization, Griffin-Lim, audio logging, pitch/spectrogram plotting, segment slicing, path generation, TTS input sampling, and speaker embeddings - Fixed torch.tensor -> torch.Tensor in regulate_len signature - No logic changes — annotations and docstring only black and isort checks pass locally. Signed-off-by: Hackathon User <hackathon@example.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds complete Python 3 type annotations to 26 public functions and a module-level
docstring in
nemo/collections/tts/parts/utils/helpers.py, as required byCONTRIBUTING.md: "Use Python 3 type hints for every class and method exposed to the user."
Collection: TTS
Changelog
Iterableto the existingtypingimportsget_batch_size,get_num_workers— training utility helpersbinarize_attention,binarize_attention_parallel— attention alignmentmas,mas_width1,b_mas— monotonic alignment search (numba@jit)griffin_lim— spectrogram-to-audio conversionlog_audio_to_tb— TensorBoard audio logging (@rank_zero_only)regulate_len,slice_segments,rand_slice_segments— length/segment opsclip_grad_value_,convert_pad_shape,generate_path— training utilitiesprocess_batch,sample_tts_input,get_speaker_embeddings_from_filepaths— data pipelineplot_alignment_to_numpy,plot_alignment_to_numpy_for_speechllm,plot_pitch_to_numpy,plot_multipitch_to_numpy,plot_spectrogram_to_numpy,create_plot,plot_gate_outputs_to_numpy,save_figure_to_numpy— visualization helperstorch.tensor→torch.Tensorinregulate_lensignature (incorrect type reference)Usage
No API changes. Type hints are purely additive and improve IDE autocompletion
and static analysis for downstream users of these TTS utilities.
Before your PR is "Ready for review"
Pre checks:
@jitfunctions — type hints on@jitfunctions are safely stripped at runtime by numba)PR Type:
Additional Information
black,isort, andpy_compileall pass locallyspeech_to_text_finetune.py)