mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-24 21:38:09 +02:00
27 lines
812 B
Python
27 lines
812 B
Python
"""The TTS providers we carry voices for, and how to name one from config."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import StrEnum
|
|
|
|
|
|
class TtsProvider(StrEnum):
|
|
"""A speech provider whose voices the catalog enumerates."""
|
|
|
|
KOKORO = "kokoro"
|
|
OPENAI = "openai"
|
|
AZURE = "azure"
|
|
VERTEX_AI = "vertex_ai"
|
|
|
|
|
|
def provider_from_service(service: str) -> TtsProvider:
|
|
"""Map a ``TTS_SERVICE`` string to its provider.
|
|
|
|
The config value is a LiteLLM-style ``provider/model`` string
|
|
(``openai/tts-1``, ``vertex_ai/...``) except for local Kokoro, which is
|
|
spelled ``local/kokoro``; both halves of that special case resolve here.
|
|
"""
|
|
prefix = service.split("/", 1)[0].strip().lower()
|
|
if prefix == "local":
|
|
return TtsProvider.KOKORO
|
|
return TtsProvider(prefix)
|