static async getInstance()

in speecht5-web/src/worker.js [21:50]


  static async getInstance(progress_callback = null) {
    this.tokenizer_instance ??= AutoTokenizer.from_pretrained(this.model_id, {
      progress_callback,
    });

    this.model_instance ??= SpeechT5ForTextToSpeech.from_pretrained(
      this.model_id,
      {
        dtype: "fp32",
        progress_callback,
      },
    );

    this.vocoder_instance ??= SpeechT5HifiGan.from_pretrained(this.vocoder_id, {
      dtype: "fp32",
      progress_callback,
    });

    return new Promise(async (resolve, reject) => {
      const result = await Promise.all([
        this.tokenizer_instance,
        this.model_instance,
        this.vocoder_instance,
      ]);
      self.postMessage({
        status: "ready",
      });
      resolve(result);
    });
  }