OthmaneLKH's picture
Update models/speech_to_text/transcriber/model.py
442ee69 verified
raw
history blame
717 Bytes
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