diff --git a/pyproject.toml b/pyproject.toml index 21d3b2e..c435f83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,25 +29,11 @@ classifiers = [ dependencies = [ "aiohttp>=3.8.4", "aiofiles>=23.1.0", - "argon2-cffi>=21.3.0", - "ctranslate2>=3.18.0", - "fastapi>=0.96.0", - "faster-whisper @ git+https://github.com/Wordcab/faster-whisper@master", "ffmpeg-python>=0.2.0", - "librosa>=0.9.0", "loguru>=0.6.0", - "numpy==1.23.1", - "onnxruntime>=1.15.0", "pydantic>=1.10.9", "python-dotenv>=1.0.0", - "python-jose[cryptography]>=3.3.0", - "python-multipart>=0.0.6", - "shortuuid>=1.0.0", - "svix>=0.85.1", - "torch>=2.0.0", - "torchaudio>=2.0.1", "yt-dlp>=2023.3.4", - "wget>=3.2.0", ] [project.urls] @@ -62,7 +48,26 @@ path = "src/wordcab_transcribe/__init__.py" allow-direct-references = true [project.optional-dependencies] -runtime = ["uvicorn>=0.21.1"] +inference = [ + "ctranslate2>=3.18.0", + "faster-whisper @ git+https://github.com/Wordcab/faster-whisper@master", + "librosa>=0.9.0", + "numpy==1.23.1", + "onnxruntime>=1.15.0", + "torch>=2.0.0", + "torchaudio>=2.0.1", + "wget>=3.2.0", +] +runtime = [ + "argon2-cffi>=21.3.0", + "fastapi>=0.96.0", + "python-jose[cryptography]>=3.3.0", + "python-multipart>=0.0.6", + "shortuuid>=1.0.0", + "svix>=0.85.1", + "uvicorn>=0.21.1", + "wordcab_transcribe[inference]", +] quality = [ "black>=22.10.0", "ruff>=0.0.263", @@ -73,15 +78,9 @@ tests = [ "pytest>=7.4", "pytest-asyncio>=0.21.1", "pytest-cov>=4.1", + "wordcab_transcribe[inference]", ] -dev = [ - "black>=22.10.0", - "httpx>=0.23.3", - "pre-commit>=2.20.0", - "pytest>=7.4", - "pytest-cov>=4.1", - "ruff>=0.0.263", -] +dev = ["wordcab_transcribe[quality,inference,runtime,tests]"] [tool.hatch.envs.runtime] features = [ diff --git a/src/wordcab_transcribe/config.py b/src/wordcab_transcribe/config.py index 4e7547a..53dd89c 100644 --- a/src/wordcab_transcribe/config.py +++ b/src/wordcab_transcribe/config.py @@ -29,6 +29,8 @@ from pydantic import field_validator from pydantic.dataclasses import dataclass +from wordcab_transcribe import __version__ + @dataclass class Settings: @@ -253,7 +255,7 @@ def __post_init__(self): settings = Settings( # General configuration project_name=getenv("PROJECT_NAME", "Wordcab Transcribe"), - version=getenv("VERSION", "0.3.0"), + version=getenv("VERSION", __version__), description=getenv( "DESCRIPTION", "💬 ASR FastAPI server using faster-whisper and Auto-Tuning Spectral Clustering" @@ -264,7 +266,7 @@ def __post_init__(self): # Models configuration # Transcription whisper_model=getenv("WHISPER_MODEL", "large-v2"), - compute_type=getenv("COMPUTE_TYPE", "int8_float16"), + compute_type=getenv("COMPUTE_TYPE", "float16"), extra_languages=extra_languages, extra_languages_model_paths={lang: "" for lang in extra_languages}, # Diarization diff --git a/src/wordcab_transcribe/utils.py b/src/wordcab_transcribe/utils.py index e02de80..728934e 100644 --- a/src/wordcab_transcribe/utils.py +++ b/src/wordcab_transcribe/utils.py @@ -24,17 +24,19 @@ import subprocess # noqa: S404 import sys from pathlib import Path -from typing import Awaitable, Dict, List, Optional, Tuple, Union +from typing import TYPE_CHECKING, Awaitable, Dict, List, Optional, Tuple, Union import aiofiles import aiohttp import huggingface_hub import torch import torchaudio -from fastapi import UploadFile from loguru import logger from yt_dlp import YoutubeDL +if TYPE_CHECKING: + from fastapi import UploadFile + # pragma: no cover async def async_run_subprocess(command: List[str]) -> tuple: @@ -534,7 +536,7 @@ def retrieve_user_platform() -> str: return sys.platform -async def save_file_locally(filename: str, file: UploadFile) -> bool: +async def save_file_locally(filename: str, file: "UploadFile") -> bool: """ Save a file locally from an UploadFile object. diff --git a/tests/test_config.py b/tests/test_config.py index 1d347e9..60a2cc9 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -77,8 +77,8 @@ def test_config() -> None: assert settings.whisper_model == "large-v2" assert settings.compute_type == "float16" - assert settings.extra_languages == [""] - assert settings.extra_languages_model_paths == {"": ""} + assert settings.extra_languages == [] + assert settings.extra_languages_model_paths == {} assert settings.window_lengths == [1.5, 1.25, 1.0, 0.75, 0.5] assert settings.shift_lengths == [0.75, 0.625, 0.5, 0.375, 0.25]