def init_whisper(model_id, device):
    """Initialize whisper model and processor"""
    torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
    print(f"Loading model {model_id}")  # model_id = "distil-whisper/distil-large-v2"
    distil_model = AutoModelForSpeechSeq2Seq.from_pretrained(
        model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=False
    )
    distil_model = distil_model.to(device)
    processor = AutoProcessor.from_pretrained(model_id)
    return distil_model, processor
Initialize whisper model and processor
utils/whisper_transcription.py