import whisper import torch class WhisperModelSingleton: _instance = None _model = None @staticmethod def get_instance(model_name="whisper-large-v3"): if WhisperModelSingleton._instance is None: WhisperModelSingleton._instance = WhisperModelSingleton() device = "cuda" if torch.cuda.is_available() else "cpu" WhisperModelSingleton._model = whisper.load_model(model_name, device=device) return WhisperModelSingleton._model