File size: 1,201 Bytes
1b64148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from functools import lru_cache

from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    """Configuracao por variaveis de ambiente (prefixo APP_) ou arquivo .env.



    As duas decisoes que voce ainda nao tomou viram simples flags aqui:

      - self-managed vs. gerenciado -> asr_backend / ocr_backend

      - GPU vs. CPU                 -> device (+ asr_compute_type)

    Nenhuma delas exige mexer no resto do codigo.

    """

    model_config = SettingsConfigDict(env_file=".env", env_prefix="APP_", extra="ignore")

    # --- inferencia de audio (ASR) ---
    asr_backend: str = "local"          # "local" hoje; amanha "azure" | "endpoint"
    asr_model: str = "large-v3"
    asr_compute_type: str = "int8"      # "int8" p/ CPU, "float16" p/ GPU

    # --- inferencia de texto (OCR) ---
    ocr_backend: str = "local"          # "local" hoje; amanha "azure" (Document Intelligence)...
    ocr_lang: str = "por"
    pdf_ocr_dpi: int = 300
    pdf_min_chars_per_page: int = 20

    # --- compute ---
    device: str = "cpu"                 # "cpu" | "cuda"


@lru_cache
def get_settings() -> Settings:
    return Settings()