File size: 717 Bytes
5397a6e
442ee69
 
5397a6e
 
 
 
 
 
 
 
 
 
 
 
442ee69
 
 
 
5397a6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from transformers import WhisperProcessor, WhisperForConditionalGeneration
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
from transformers import pipeline

def load_model_and_processor(model_name="openai/whisper-base"):
    """
    Loads the Whisper model and processor.
    
    Parameters:
        model_name (str): The model to load. Defaults to 'openai/whisper-base'.
    
    Returns:
        model (WhisperForConditionalGeneration): Loaded Whisper model.
        processor (WhisperProcessor): Loaded processor for the model.
    """

    processor = AutoProcessor.from_pretrained(model_name)
    model = AutoModelForSpeechSeq2Seq.from_pretrained(model_name)
    
    return model, processor