Files
DocsGPT/docsgpt/stt/stt_creator.py
T
Alex 7da46c2bea feat: air-gapped deployment guide, no implicit downloads
- Ship tiktoken's cl100k_base inside the package and build the encoding
  from it, so token counting never downloads anything.
- Default EMBEDDINGS_CACHE_DIR to <data home>/models instead of FastEmbed's
  temp dir, and read tokenizer.json and repo metadata from that cache, so
  a model downloads once and survives reboots.
- TTS_PROVIDER=none and STT_PROVIDER=none switch the speech features off:
  the endpoints return 404, audio files fail to ingest with a clear
  message, /api/config reports tts_available/stt_available, and the UI
  hides the Speak and microphone buttons.
- Drop the Google Fonts Roboto import from the web UI.
- prefetch-models fills the cache the app reads; verify-offline checks the
  packaged encoding.
- Docs: new Air-Gapped Deployment guide, settings and cache notes.
2026-09-15 17:54:24 +01:00

28 lines
882 B
Python

from typing import Optional
from docsgpt.stt.base import BaseSTT
from docsgpt.stt.faster_whisper_stt import FasterWhisperSTT
from docsgpt.stt.openai_stt import OpenAISTT
#: STT_PROVIDER value that switches speech-to-text off.
DISABLED = "none"
class STTCreator:
stt_providers = {
"openai": OpenAISTT,
"faster_whisper": FasterWhisperSTT,
}
@staticmethod
def is_enabled(stt_type: Optional[str]) -> bool:
"""False when the provider is ``none`` or empty: speech-to-text is switched off."""
return (stt_type or "").strip().lower() not in ("", DISABLED)
@classmethod
def create_stt(cls, stt_type, *args, **kwargs) -> BaseSTT:
stt_class = cls.stt_providers.get(stt_type.lower())
if not stt_class:
raise ValueError(f"No stt class found for type {stt_type}")
return stt_class(*args, **kwargs)