

deprecate `config.preload_models`
@4aa5cf9c49b0becfb5282f0e8e0bb4d48c00c9e5
--- src/speaches/config.py
+++ src/speaches/config.py
... | ... | @@ -216,17 +216,6 @@ |
216 | 216 |
""" |
217 | 217 |
default_response_format: ResponseFormat = ResponseFormat.JSON |
218 | 218 |
whisper: WhisperConfig = WhisperConfig() |
219 |
- preload_models: list[str] = Field( |
|
220 |
- default_factory=list, |
|
221 |
- examples=[ |
|
222 |
- ["Systran/faster-whisper-small"], |
|
223 |
- ["Systran/faster-whisper-medium.en", "Systran/faster-whisper-small.en"], |
|
224 |
- ], |
|
225 |
- ) |
|
226 |
- """ |
|
227 |
- List of Whisper models to preload on startup. By default, the model is first loaded on first request. |
|
228 |
- WARNING: I'd recommend not setting this, as it may be deprecated in the future. |
|
229 |
- """ |
|
230 | 219 |
max_no_data_seconds: float = 1.0 |
231 | 220 |
""" |
232 | 221 |
Max duration to wait for the next audio chunk before transcription is finilized and connection is closed. |
--- src/speaches/main.py
+++ src/speaches/main.py
... | ... | @@ -1,16 +1,14 @@ |
1 | 1 |
from __future__ import annotations |
2 | 2 |
|
3 |
-from contextlib import asynccontextmanager |
|
4 | 3 |
import logging |
5 | 4 |
import platform |
6 |
-from typing import TYPE_CHECKING |
|
7 | 5 |
|
8 | 6 |
from fastapi import ( |
9 | 7 |
FastAPI, |
10 | 8 |
) |
11 | 9 |
from fastapi.middleware.cors import CORSMiddleware |
12 | 10 |
|
13 |
-from speaches.dependencies import ApiKeyDependency, get_config, get_model_manager |
|
11 |
+from speaches.dependencies import ApiKeyDependency, get_config |
|
14 | 12 |
from speaches.logger import setup_logger |
15 | 13 |
from speaches.routers.misc import ( |
16 | 14 |
router as misc_router, |
... | ... | @@ -24,9 +22,6 @@ |
24 | 22 |
from speaches.routers.stt import ( |
25 | 23 |
router as stt_router, |
26 | 24 |
) |
27 |
- |
|
28 |
-if TYPE_CHECKING: |
|
29 |
- from collections.abc import AsyncGenerator |
|
30 | 25 |
|
31 | 26 |
# https://swagger.io/docs/specification/v3_0/grouping-operations-with-tags/ |
32 | 27 |
# https://fastapi.tiangolo.com/tutorial/metadata/#metadata-for-tags |
... | ... | @@ -52,19 +47,11 @@ |
52 | 47 |
if platform.machine() == "x86_64": |
53 | 48 |
logger.warning("`POST /v1/audio/speech` with `model=rhasspy/piper-voices` is only supported on x86_64 machines") |
54 | 49 |
|
55 |
- model_manager = get_model_manager() # HACK |
|
56 |
- |
|
57 |
- @asynccontextmanager |
|
58 |
- async def lifespan(_app: FastAPI) -> AsyncGenerator[None, None]: |
|
59 |
- for model_name in config.preload_models: |
|
60 |
- model_manager.load_model(model_name) |
|
61 |
- yield |
|
62 |
- |
|
63 | 50 |
dependencies = [] |
64 | 51 |
if config.api_key is not None: |
65 | 52 |
dependencies.append(ApiKeyDependency) |
66 | 53 |
|
67 |
- app = FastAPI(lifespan=lifespan, dependencies=dependencies, openapi_tags=TAGS_METADATA) |
|
54 |
+ app = FastAPI(dependencies=dependencies, openapi_tags=TAGS_METADATA) |
|
68 | 55 |
|
69 | 56 |
app.include_router(stt_router) |
70 | 57 |
app.include_router(models_router) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?