code: def __init__(self, speaker_audio: str = None, output_dir: str = "./"):
      super(VoiceCloner, self).__init__()
  
      speaker_encoder_ckpt = os.path.join(
          MODULE_HOME,
          "ge2e_fastspeech2_pwgan",
          "assets",
          "ge2e_ckpt_0.3/step-3000000.pdparams",
      )
      synthesizer_res_dir = os.path.join(
          MODULE_HOME,
          "ge2e_fastspeech2_pwgan",
          "assets",
          "fastspeech2_nosil_aishell3_vc1_ckpt_0.5",
      )
      vocoder_res_dir = os.path.join(
          MODULE_HOME,
          "ge2e_fastspeech2_pwgan",
          "assets",
          "pwg_aishell3_ckpt_0.5",
      )
  
      # Speaker encoder
      self.speaker_processor = SpeakerVerificationPreprocessor(
          sampling_rate=16000,
          audio_norm_target_dBFS=-30,
          vad_window_length=30,
          vad_moving_average_width=8,
          vad_max_silence_length=6,
          mel_window_length=25,
          mel_window_step=10,
          n_mels=40,
          partial_n_frames=160,
          min_pad_coverage=0.75,
          partial_overlap_ratio=0.5,
      )
      self.speaker_encoder = LSTMSpeakerEncoder(
          n_mels=40, num_layers=3, hidden_size=256, output_size=256
      )
      self.speaker_encoder.set_state_dict(
          paddle.load(speaker_encoder_ckpt)
      )
      self.speaker_encoder.eval()
  
      # Voice synthesizer
      with open(
          os.path.join(synthesizer_res_dir, "default.yaml"), "r"
      ) as f:
          fastspeech2_config = CfgNode(yaml.safe_load(f))
      with open(
          os.path.join(synthesizer_res_dir, "phone_id_map.txt"), "r"
      ) as f:
          phn_id = [line.strip().split() for line in f.readlines()]
  
      model = FastSpeech2(
          idim=len(phn_id),
          odim=fastspeech2_config.n_mels,
          **fastspeech2_config["model"],
      )
      model.set_state_dict(
          paddle.load(
              os.path.join(
                  synthesizer_res_dir, "snapshot_iter_96400.pdz"
              )
          )["main_params"]
      )
      model.eval()
  
      stat = np.load(
          os.path.join(synthesizer_res_dir, "speech_stats.npy")
      )
      mu, std = stat
      mu = paddle.to_tensor(mu)
      std = paddle.to_tensor(std)
      fastspeech2_normalizer = ZScore(mu, std)
      self.sample_rate = fastspeech2_config.fs
  
      self.fastspeech2_inference = FastSpeech2Inference(
          fastspeech2_normalizer, model
      )
      self.fastspeech2_inference.eval()
  
      # Vocoder
      with open(os.path.join(vocoder_res_dir, "default.yaml")) as f:
          pwg_config = CfgNode(yaml.safe_load(f))
  
      vocoder = PWGGenerator(**pwg_config["generator_params"])
      vocoder.set_state_dict(
          paddle.load(
              os.path.join(vocoder_res_dir, "snapshot_iter_1000000.pdz")
          )["generator_params"]
      )
      vocoder.remove_weight_norm()
      vocoder.eval()
  
      stat = np.load(os.path.join(vocoder_res_dir, "feats_stats.npy"))
      mu, std = stat
      mu = paddle.to_tensor(mu)
      std = paddle.to_tensor(std)
      pwg_normalizer = ZScore(mu, std)
  
      self.pwg_inference = PWGInference(pwg_normalizer, vocoder)
      self.pwg_inference.eval()
  
      # Text frontend
      self.frontend = Frontend(
          phone_vocab_path=os.path.join(
              synthesizer_res_dir, "phone_id_map.txt"
          )
      )
  
      # Speaking embedding
      self._speaker_embedding = None
      if speaker_audio is None or not os.path.isfile(speaker_audio):
          speaker_audio = os.path.join(
              MODULE_HOME,
              "ge2e_fastspeech2_pwgan",
              "assets",
              "voice_cloning.wav",
          )
          logger.warning(
              f"Due to no speaker audio is specified, speaker encoder will use defult "
              f"waveform({speaker_audio}) to extract speaker embedding. You can use "
              '"set_speaker_embedding()" method to reset a speaker audio for voice cloning.'
          )
      self.set_speaker_embedding(speaker_audio)
  
      self.output_dir = os.path.abspath(output_dir)
      if not os.path.exists(self.output_dir):
          os.makedirs(self.output_dir)
  
imports: import os
  from typing import List, Union
  import numpy
  import paddle
  import soundfile
  import yaml
  from yacs.config import CfgNode
  from paddlehub.env import MODULE_HOME
  from paddlehub.module.module import moduleinfo, serving
  from paddlehub.utils.log import logger
  from paddlespeech.t2s.frontend.zh_frontend import Frontend
  from paddlespeech.t2s.models.fastspeech2 import FastSpeech2
  from paddlespeech.t2s.models.fastspeech2 import FastSpeech2Inference
  from paddlespeech.t2s.models.parallel_wavegan import PWGGenerator
  from paddlespeech.t2s.models.parallel_wavegan import PWGInference
  from paddlespeech.t2s.modules.normalizer import ZScore
  from paddlespeech.vector.exps.ge2e.audio_processor import SpeakerVerificationPreprocessor
  from paddlespeech.vector.models.lstm_speaker_encoder import LSTMSpeakerEncoder
label_desc: Use image node_id 1 to create a new VoiceCloner object from inherited base classes: paddle.nn with example: obj = VoiceCloner(speaker_audio, output_dir)