Spaces:
Running
Running
File size: 509 Bytes
acabbdd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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 |