class_docstr: Align text to audio using CTC segmentation.
  
  Usage
  -----
  Initialize with given ASR model and parameters.
  If needed, parameters for CTC segmentation can be set with ``set_config(·)``.
  Then call the instance as function to align text within an audio file.
  
  Attributes
  ---------
  asr_model : EncoderDecoderASR
      Speechbrain ASR interface. This requires a model that has a
      trained CTC layer for inference. It is better to use a model with
      single-character tokens to get a better time resolution.
      Please note that the inference complexity with Transformer models
      usually increases quadratically with audio length.
      It is therefore recommended to use RNN-based models, if available.
  kaldi_style_text : bool
      A kaldi-style text file includes the name of the
      utterance at the start of the line. If True, the utterance name
      is expected as first word at each line. If False, utterance
      names are automatically generated. Set this option according to
      your input data. Default: True.
  text_converter : str
      How CTC segmentation handles text.
      "tokenize": Use the ASR model tokenizer to tokenize the text.
      "classic": The text is preprocessed as text pieces which takes
      token length into account. If the ASR model has longer tokens,
      this option may yield better results. Default: "tokenize".
  time_stamps : str
      Choose the method how the time stamps are
      calculated. While "fixed" and "auto" use both the sample rate,
      the ratio of samples to one frame is either automatically
      determined for each inference or fixed at a certain ratio that
      is initially determined by the module, but can be changed via
      the parameter ``samples_to_frames_ratio``. Recommended for
      longer audio files: "auto".
  **ctc_segmentation_args
      Parameters for CTC segmentation.
      The full list of parameters is found in ``set_config``.
  
  Example
  -------
      >>> # using example file included in the SpeechBrain repository
      >>> from speechbrain.inference.ASR import EncoderDecoderASR
      >>> from speechbrain.alignment.ctc_segmentation import CTCSegmentation
      >>> # load an ASR model
      >>> pre_trained = "speechbrain/asr-transformer-transformerlm-librispeech"
      >>> asr_model = EncoderDecoderASR.from_hparams(source=pre_trained)  # doctest: +SKIP
      >>> aligner = CTCSegmentation(asr_model, kaldi_style_text=False)  # doctest: +SKIP
      >>> # load data
      >>> audio_path = "tests/samples/single-mic/example1.wav"
      >>> text = ["THE BIRCH CANOE", "SLID ON THE", "SMOOTH PLANKS"]
      >>> segments = aligner(audio_path, text, name="example1")  # doctest: +SKIP
  
  On multiprocessing
  ------------------
  To parallelize the computation with multiprocessing, these three steps
  can be separated:
  (1) ``get_lpz``: obtain the lpz,
  (2) ``prepare_segmentation_task``: prepare the task, and
  (3) ``get_segments``: perform CTC segmentation.
  Note that the function `get_segments` is a staticmethod and therefore
  independent of an already initialized CTCSegmentation obj́ect.
  
  References
  ----------
  CTC-Segmentation of Large Corpora for German End-to-end Speech Recognition
  2020, Kürzinger, Winkelbauer, Li, Watzel, Rigoll
  https://arxiv.org/abs/2007.09127
  
  More parameters are described in https://github.com/lumaku/ctc-segmentation
docstr: Align utterances.
  
  Arguments
  ---------
  speech : Union[torch.Tensor, np.ndarray, str, Path]
      Audio file that can be given as path or as array.
  text : Union[List[str], str]
      List or multiline-string with utterance ground truths.
      The required formatting depends on the setting ``kaldi_style_text``.
  name : str
      Name of the file. Utterance names are derived from it.
  
  Returns
  -------
  CTCSegmentationTask
      Task object with segments. Apply str(·) or print(·) on it
      to obtain the segments list.
docstr_tok: ["Align","utterances",".","Arguments","--","--","--","--","-","speech",":","Union","[","torch.Tensor",",","np.ndarray",",","str",",","Path","]","Audio","file","that","can","be","given","as","path","or","as","array",".","text",":","Union","[","List","[","str","]",",","str","]","List","or","multiline-string","with","utterance","ground","truths",".","The","required","formatting","depends","on","the","setting","``","kaldi_style_text","``",".","name",":","str","Name","of","the","file",".","Utterance","names","are","derived","from","it",".","Returns","--","--","--","-","CTCSegmentationTask","Task","object","with","segments",".","Apply","str","(","\u00b7",")","or","print","(","\u00b7",")","on","it","to","obtain","the","segments","list","."]
code: def __call__(
      self,
      speech: Union[torch.Tensor, np.ndarray, str, Path],
      text: Union[List[str], str],
      name: Optional[str] = None,
  ) -> CTCSegmentationTask:
      """Align utterances.
  
      Arguments
      ---------
      speech : Union[torch.Tensor, np.ndarray, str, Path]
          Audio file that can be given as path or as array.
      text : Union[List[str], str]
          List or multiline-string with utterance ground truths.
          The required formatting depends on the setting ``kaldi_style_text``.
      name : str
          Name of the file. Utterance names are derived from it.
  
      Returns
      -------
      CTCSegmentationTask
          Task object with segments. Apply str(·) or print(·) on it
          to obtain the segments list.
      """
      if isinstance(speech, str) or isinstance(speech, Path):
          speech = self.asr_model.load_audio(speech)
      # Get log CTC posterior probabilities
      lpz = self.get_lpz(speech)
      # Conflate text & lpz & config as a segmentation task object
      task = self.prepare_segmentation_task(
          text, lpz, name, speech.shape[0]
      )
      # Apply CTC segmentation
      segments = self.get_segments(task)
      task.set(**segments)
      return task
  
imports: import logging
  from pathlib import Path
  from types import SimpleNamespace
  from typing import Optional
  from typing import Union
  import numpy
  import torch
  from typing import List
  from speechbrain.inference.ASR import EncoderASR, EncoderDecoderASR
label_desc: Use image node_id 9 for calling the CTCSegmentation obj's underlying member method code with example usage: obj.__call__(speech, text, name) and returns: task