def __init__()

in docker_images/speechbrain/app/pipelines/text_to_speech.py [0:0]


    def __init__(self, model_id: str):
        model_type = get_type(model_id)
        if model_type is ModelType.TACOTRON2:
            self.model = Tacotron2.from_hparams(source=model_id)
            self.type = "tacotron2"
        elif model_type is ModelType.FASTSPEECH2:
            self.model = FastSpeech2.from_hparams(source=model_id)
            self.type = "fastspeech2"
        else:
            raise ValueError(f"{model_type.value} is invalid for text-to-speech")

        vocoder_type = get_type(model_id, "vocoder_interface")
        vocoder_model_id = get_vocoder_model_id(model_id)
        if vocoder_type is ModelType.HIFIGAN:
            self.vocoder_model = HIFIGAN.from_hparams(source=vocoder_model_id)
        else:
            raise ValueError(
                f"{vocoder_type.value} is invalid vocoder for text-to-speech"
            )

        self.sampling_rate = self.model.hparams.sample_rate