use conditional imports and show help errors if modules not found

This commit is contained in:
Aleix Conchillo Flaqué
2024-04-03 15:09:12 -07:00
parent 23735cb3a3
commit 3528f5d735
19 changed files with 137 additions and 67 deletions

View File

@@ -3,10 +3,18 @@ import asyncio
from enum import Enum
import logging
from typing import BinaryIO
from faster_whisper import WhisperModel
from dailyai.services.local_stt_service import LocalSTTService
try:
from faster_whisper import WhisperModel
except ModuleNotFoundError as e:
print(f"Exception: {e}")
print(
"In order to use Whisper, you need to `pip install dailyai[whisper]`.")
raise Exception(f"Missing module: {e}")
class Model(Enum):
"""Class of basic Whisper model selection options"""
TINY = "tiny"