whisper-webui / src /whisper /whisperFactory.py
aadnk's picture
Adding support for faster_whisper
295de00
raw
history blame
985 Bytes
from typing import List
from src import modelCache
from src.config import ModelConfig
from src.whisper.abstractWhisperContainer import AbstractWhisperContainer
def create_whisper_container(whisper_implementation: str,
model_name: str, device: str = None, download_root: str = None,
cache: modelCache = None, models: List[ModelConfig] = []) -> AbstractWhisperContainer:
if (whisper_implementation == "whisper"):
from src.whisper.whisperContainer import WhisperContainer
return WhisperContainer(model_name, device, download_root, cache, models)
elif (whisper_implementation == "faster-whisper" or whisper_implementation == "faster_whisper"):
from src.whisper.fasterWhisperContainer import FasterWhisperContainer
return FasterWhisperContainer(model_name, device, download_root, cache, models)
else:
raise ValueError("Unknown Whisper implementation: " + whisper_implementation)