mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-13 08:15:43 +00:00
- 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.
28 lines
867 B
Python
28 lines
867 B
Python
from typing import Optional
|
|
|
|
from docsgpt.tts.google_tts import GoogleTTS
|
|
from docsgpt.tts.elevenlabs import ElevenlabsTTS
|
|
from docsgpt.tts.base import BaseTTS
|
|
|
|
#: TTS_PROVIDER value that switches text-to-speech off.
|
|
DISABLED = "none"
|
|
|
|
|
|
class TTSCreator:
|
|
tts_providers = {
|
|
"google_tts": GoogleTTS,
|
|
"elevenlabs": ElevenlabsTTS,
|
|
}
|
|
|
|
@staticmethod
|
|
def is_enabled(tts_type: Optional[str]) -> bool:
|
|
"""False when the provider is ``none`` or empty: text-to-speech is switched off."""
|
|
return (tts_type or "").strip().lower() not in ("", DISABLED)
|
|
|
|
@classmethod
|
|
def create_tts(cls, tts_type, *args, **kwargs)-> BaseTTS:
|
|
tts_class = cls.tts_providers.get(tts_type.lower())
|
|
if not tts_class:
|
|
raise ValueError(f"No tts class found for type {tts_type}")
|
|
return tts_class(*args, **kwargs)
|