class_docstr: A ready-to-use wrapper for Zero-Shot Multi-Speaker Tacotron2.
  For voice cloning: (text, reference_audio) -> (mel_spec).
  For generating a random speaker voice: (text) -> (mel_spec).
  
  
  Example
  -------
  >>> tmpdir_tts = getfixture('tmpdir') / "tts"
  >>> mstacotron2 = MSTacotron2.from_hparams(source="speechbrain/tts-mstacotron2-libritts", savedir=tmpdir_tts) # doctest: +SKIP
  >>> # Sample rate of the reference audio must be greater or equal to the sample rate of the speaker embedding model
  >>> reference_audio_path = "tests/samples/single-mic/example1.wav"
  >>> input_text = "Mary had a little lamb."
  >>> mel_output, mel_length, alignment = mstacotron2.clone_voice(input_text, reference_audio_path) # doctest: +SKIP
  >>> # One can combine the TTS model with a vocoder (that generates the final waveform)
  >>> # Intialize the Vocoder (HiFIGAN)
  >>> tmpdir_vocoder = getfixture('tmpdir') / "vocoder"
  >>> from speechbrain.inference.vocoders import HIFIGAN
  >>> hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-libritts-22050Hz", savedir=tmpdir_vocoder) # doctest: +SKIP
  >>> # Running the TTS
  >>> mel_output, mel_length, alignment = mstacotron2.clone_voice(input_text, reference_audio_path) # doctest: +SKIP
  >>> # Running Vocoder (spectrogram-to-waveform)
  >>> waveforms = hifi_gan.decode_batch(mel_output) # doctest: +SKIP
  >>> # For generating a random speaker voice, use the following
  >>> mel_output, mel_length, alignment = mstacotron2.generate_random_voice(input_text) # doctest: +SKIP
docstr: Generates mel-spectrogram using input text and reference audio
  
  Arguments
  ---------
  texts : str or list
      Input text
  audio_path : str
      Reference audio
  
  Returns
  -------
  tensors of output spectrograms, output lengths and alignments
docstr_tok: ["Generates","mel-spectrogram","using","input","text","and","reference","audio","Arguments","--","--","--","--","-","texts",":","str","or","list","Input","text","audio_path",":","str","Reference","audio","Returns","--","--","--","-","tensors","of","output","spectrograms",",","output","lengths","and","alignments"]
code: def clone_voice(self, texts, audio_path):
      """
      Generates mel-spectrogram using input text and reference audio
  
      Arguments
      ---------
      texts : str or list
          Input text
      audio_path : str
          Reference audio
  
      Returns
      -------
      tensors of output spectrograms, output lengths and alignments
      """
  
      # Loads audio
      ref_signal, signal_sr = torchaudio.load(audio_path)
  
      # Resamples the audio if required
      if signal_sr != self.hparams.spk_emb_sample_rate:
          ref_signal = torchaudio.functional.resample(
              ref_signal, signal_sr, self.hparams.spk_emb_sample_rate
          )
      ref_signal = ref_signal.to(self.device)
  
      # Computes speaker embedding
      if self.custom_mel_spec_encoder:
          spk_emb = self.spk_emb_encoder.encode_waveform(ref_signal)
      else:
          spk_emb = self.spk_emb_encoder.encode_batch(ref_signal)
  
      spk_emb = spk_emb.squeeze(0)
  
      # Converts input texts into the corresponding phoneme sequences
      if isinstance(texts, str):
          texts = [texts]
      phoneme_seqs = self.g2p(texts)
      for i in range(len(phoneme_seqs)):
          phoneme_seqs[i] = " ".join(phoneme_seqs[i])
          phoneme_seqs[i] = "{" + phoneme_seqs[i] + "}"
  
      # Repeats the speaker embedding to match the number of input texts
      spk_embs = spk_emb.repeat(len(texts), 1)
  
      # Calls __encode_batch to generate the mel-spectrograms
      return self.__encode_batch(phoneme_seqs, spk_embs)
  
imports: import re
  import logging
  import torch
  import torchaudio
  import random
  import speechbrain
  from speechbrain.utils.fetching import fetch
  from speechbrain.inference.interfaces import Pretrained
  from speechbrain.utils.text_to_sequence import text_to_sequence
  from speechbrain.inference.text import GraphemeToPhoneme
  from speechbrain.inference.encoders import MelSpectrogramEncoder
  from speechbrain.inference.classifiers import EncoderClassifier
label_desc: Use image node_id 3 for calling the MSTacotron2 obj's underlying member method code with example usage: obj.clone_voice(texts, audio_path) and returns: self