class_docstr: Dynamically compute power_db and f0_hz with optional centered frames.
class_docstr_tok: ["Dynamically","compute","power_db","and","f0_hz","with","optional","centered","frames","."]
docstr: Compute power on the fly if it's not in the inputs.
docstr_tok: ["Compute","power","on","the","fly","if","it","'s","not","in","the","inputs","."]
code: def call(
      self, audio, f0_hz=None, f0_confidence=None, audio_16k=None
  ) -> ["f0_hz", "pw_db", "f0_scaled", "pw_scaled", "f0_confidence"]:
      """Compute power on the fly if it's not in the inputs."""
      # Compute features at 16kHz (needed for CREPE).
      if audio_16k is not None:
          audio = audio_16k
  
      # Compute power and f0 on the fly.
      if self.compute_power:
          pw_db = ddsp.spectral_ops.compute_power(
              audio,
              sample_rate=self.sample_rate,
              frame_rate=self.frame_rate,
              frame_size=self.frame_size,
              padding=self.padding,
          )
  
      if self.compute_f0:
          (
              f0_hz,
              f0_confidence,
          ) = self.crepe_model.predict_f0_and_confidence(
              audio, viterbi=self.viterbi, padding=self.padding
          )
          # Stop gradients from flowing to CREPE.
          f0_hz = tf.stop_gradient(f0_hz)
          f0_confidence = tf.stop_gradient(f0_confidence)
      elif f0_hz is None or f0_confidence is None:
          raise ValueError(
              "Preprocessor must either have `compute_f0=True`, or"
              "__call__ must be supplied 3 arguments, "
              "[audio, f0_hz, and f0_confidence]."
          )
  
      # For NN training, scale frequency and loudness to the range [0, 1].
      pw_db = at_least_3d(pw_db)
      f0_hz = at_least_3d(f0_hz)
  
      pw_scaled = scale_db(pw_db)
      f0_scaled = scale_f0_hz(f0_hz)
  
      # For sanity checking.
      # You need to define time_steps correctly just to make sure you know what
      # you're doing, and what the model output shape is (no interpolation).
      n_t = audio.shape[1]
      time_steps, _ = ddsp.spectral_ops.get_framed_lengths(
          n_t, self.frame_size, self.hop_size, self.padding
      )
      for k, output in {
          "f0_hz": f0_hz,
          "pw_db": pw_db,
          "f0_scaled": f0_scaled,
          "pw_scaled": pw_scaled,
          "f0_confidence": f0_confidence,
      }.items():
          if output.shape[1] != time_steps:
              raise ValueError(
                  f"OnlineF0PowerPreprocessor output: ({k}) does not have "
                  f"{time_steps} timesteps. Output shape: {output.shape}. "
                  f"\nInputs: seconds ({n_t/self.sample_rate}), "
                  f"frame_rate ({self.frame_rate}), "
                  f'padding ("{self.padding}").'
              )
  
      return f0_hz, pw_db, f0_scaled, pw_scaled, f0_confidence
  
imports: import ddsp
  from ddsp.training import nn
  import gin
  import tensorflow
label_desc: Use image node_id 2 for calling the OnlineF0PowerPreprocessor obj's underlying member method code with example usage: obj.call(audio, f0_hz, f0_confidence, audio_16k) and returns: f0_hz,  pw_db,  f0_scaled,  pw_scaled,  f0_confidence