class_docstr: Speech-to-text alignment model (https://arxiv.org/pdf/2108.10447.pdf) that is used to learn alignments between mel spectrogram and text.
class_docstr_tok: ["Speech-to-text","alignment","model","(","https",":","\/\/arxiv.org\/pdf\/2108.10447.pdf",")","that","is","used","to","learn","alignments","between","mel","spectrogram","and","text","."]
code: def __init__(self, cfg: DictConfig, trainer: "Trainer" = None):
      # Convert to Hydra 1.0 compatible DictConfig
      cfg = model_utils.convert_model_config_to_dict_config(cfg)
      cfg = model_utils.maybe_update_config_version(cfg)
  
      # Setup normalizer
      self.normalizer = None
      self.text_normalizer_call = None
      self.text_normalizer_call_kwargs = {}
      self._setup_normalizer(cfg)
  
      # Setup tokenizer
      self.tokenizer = None
      self._setup_tokenizer(cfg)
      assert self.tokenizer is not None
  
      num_tokens = len(self.tokenizer.tokens)
      self.tokenizer_pad = self.tokenizer.pad
      self.tokenizer_unk = self.tokenizer.oov
  
      super().__init__(cfg=cfg, trainer=trainer)
  
      self.embed = nn.Embedding(num_tokens, cfg.symbols_embedding_dim)
      self.preprocessor = instantiate(cfg.preprocessor)
      self.alignment_encoder = instantiate(cfg.alignment_encoder)
  
      self.forward_sum_loss = ForwardSumLoss()
      self.bin_loss = BinLoss()
      self.add_bin_loss = False
      self.bin_loss_scale = 0.0
      self.bin_loss_start_ratio = cfg.bin_loss_start_ratio
      self.bin_loss_warmup_epochs = cfg.bin_loss_warmup_epochs
  
imports: from typing import List
  import numpy
  import omegaconf
  import torch
  from hydra.utils import instantiate
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from pytorch_lightning.loggers import WandbLogger
  from torch import nn
  from nemo.collections.tts.losses.aligner_loss import BinLoss, ForwardSumLoss
  from nemo.collections.tts.parts.utils.helpers import binarize_attention, g2p_backward_compatible_support, get_mask_from_lengths, plot_alignment_to_numpy
  from nemo.core.classes import ModelPT
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 1 to create a new AlignerModel object from inherited base classes: ModelPT with example: obj = AlignerModel(cfg, trainer)