class_docstr: ESPnet model for text-to-speech task.
docstr: Caclualte features and return them as a dict.
  
  Args:
      text (Tensor): Text index tensor (T_text).
      speech (Tensor): Speech waveform tensor (T_wav).
      spembs (Optional[Tensor]): Speaker embedding tensor (D,).
      sids (Optional[Tensor]): Speaker ID tensor (1,).
      lids (Optional[Tensor]): Language ID tensor (1,).
      durations (Optional[Tensor): Duration tensor.
      pitch (Optional[Tensor): Pitch tensor.
      energy (Optional[Tensor): Energy tensor.
  
  Returns:
      Dict[str, Tensor]: Dict of outputs.
docstr_tok: ["Caclualte","features","and","return","them","as","a","dict",".","Args",":","text","(","Tensor",")",":","Text","index","tensor","(","T_text",")",".","speech","(","Tensor",")",":","Speech","waveform","tensor","(","T_wav",")",".","spembs","(","Optional","[","Tensor","]",")",":","Speaker","embedding","tensor","(","D",",",")",".","sids","(","Optional","[","Tensor","]",")",":","Speaker","ID","tensor","(","1",",",")",".","lids","(","Optional","[","Tensor","]",")",":","Language","ID","tensor","(","1",",",")",".","durations","(","Optional","[","Tensor",")",":","Duration","tensor",".","pitch","(","Optional","[","Tensor",")",":","Pitch","tensor",".","energy","(","Optional","[","Tensor",")",":","Energy","tensor",".","Returns",":","Dict","[","str",",","Tensor","]",":","Dict","of","outputs","."]
code: def inference(
      self,
      text: torch.Tensor,
      speech: Optional[torch.Tensor] = None,
      spembs: Optional[torch.Tensor] = None,
      sids: Optional[torch.Tensor] = None,
      lids: Optional[torch.Tensor] = None,
      durations: Optional[torch.Tensor] = None,
      pitch: Optional[torch.Tensor] = None,
      energy: Optional[torch.Tensor] = None,
      **decode_config,
  ) -> Dict[str, torch.Tensor]:
      """Caclualte features and return them as a dict.
  
      Args:
          text (Tensor): Text index tensor (T_text).
          speech (Tensor): Speech waveform tensor (T_wav).
          spembs (Optional[Tensor]): Speaker embedding tensor (D,).
          sids (Optional[Tensor]): Speaker ID tensor (1,).
          lids (Optional[Tensor]): Language ID tensor (1,).
          durations (Optional[Tensor): Duration tensor.
          pitch (Optional[Tensor): Pitch tensor.
          energy (Optional[Tensor): Energy tensor.
  
      Returns:
          Dict[str, Tensor]: Dict of outputs.
  
      """
      input_dict = dict(text=text)
      if decode_config["use_teacher_forcing"] or getattr(
          self.tts, "use_gst", False
      ):
          if speech is None:
              raise RuntimeError("missing required argument: 'speech'")
          if self.feats_extract is not None:
              feats = self.feats_extract(speech[None])[0][0]
          else:
              # Use precalculated feats (feats_type != raw case)
              feats = speech
          if self.normalize is not None:
              feats = self.normalize(feats[None])[0][0]
          input_dict.update(feats=feats)
  
      if decode_config["use_teacher_forcing"]:
          if durations is not None:
              input_dict.update(durations=durations)
  
          if self.pitch_extract is not None:
              pitch = self.pitch_extract(
                  speech[None],
                  feats_lengths=torch.LongTensor([len(feats)]),
                  durations=durations[None],
              )[0][0]
          if self.pitch_normalize is not None:
              pitch = self.pitch_normalize(pitch[None])[0][0]
          if pitch is not None:
              input_dict.update(pitch=pitch)
  
          if self.energy_extract is not None:
              energy = self.energy_extract(
                  speech[None],
                  feats_lengths=torch.LongTensor([len(feats)]),
                  durations=durations[None],
              )[0][0]
          if self.energy_normalize is not None:
              energy = self.energy_normalize(energy[None])[0][0]
          if energy is not None:
              input_dict.update(energy=energy)
  
      if spembs is not None:
          input_dict.update(spembs=spembs)
      if sids is not None:
          input_dict.update(sids=sids)
      if lids is not None:
          input_dict.update(lids=lids)
  
      output_dict = self.tts.inference(**input_dict, **decode_config)
  
      if (
          self.normalize is not None
          and output_dict.get("feat_gen") is not None
      ):
          # NOTE: normalize.inverse is in-place operation
          feat_gen_denorm = self.normalize.inverse(
              output_dict["feat_gen"].clone()[None]
          )[0][0]
          output_dict.update(feat_gen_denorm=feat_gen_denorm)
  
      return output_dict
  
file_path: espnet/espnet2/tts/espnet_model.py
imports: from contextlib import contextmanager
  from typing import Dict, Optional, Tuple
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.layers.inversible_interface import InversibleInterface
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  from espnet2.tts.abs_tts import AbsTTS
  from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract
label_desc: Use image node_id 4 for calling the ESPnetTTSModel obj's underlying member method code with example usage: obj.inference(text, speech, spembs, sids, lids, durations, pitch, energy) and returns: output_dict