独立依赖
This commit is contained in:
@@ -1,11 +1,35 @@
|
||||
from pydantic import AliasChoices, Field, field_validator
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic import Field, field_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def asr_bundle_dir() -> Path:
|
||||
return PROJECT_ROOT / "models" / "asr" / "SenseVoiceSmall"
|
||||
|
||||
|
||||
def kokoro_bundle_dir() -> Path:
|
||||
return PROJECT_ROOT / "models" / "tts" / "Kokoro-82M"
|
||||
|
||||
|
||||
def vad_bundle_path() -> Path:
|
||||
return PROJECT_ROOT / "models" / "vad" / "silero_vad.jit"
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||||
|
||||
@field_validator("webrtc_host", mode="before")
|
||||
@field_validator("llm_api_key", "llm_base_url", "llm_model", mode="before")
|
||||
@classmethod
|
||||
def llm_required_nonempty(cls, value: str) -> str:
|
||||
text = str(value or "").strip()
|
||||
if not text:
|
||||
raise ValueError("LLM_API_KEY, LLM_BASE_URL and LLM_MODEL must be set (non-empty).")
|
||||
return text
|
||||
|
||||
@field_validator("http_host", mode="before")
|
||||
@classmethod
|
||||
def normalize_listen_host(cls, value: str) -> str:
|
||||
host = str(value or "0.0.0.0").strip().lower()
|
||||
@@ -13,19 +37,20 @@ class Settings(BaseSettings):
|
||||
return "0.0.0.0"
|
||||
return host or "0.0.0.0"
|
||||
|
||||
hf_token: str = ""
|
||||
llm_api_key: str = Field(
|
||||
default="",
|
||||
validation_alias=AliasChoices("LLM_API_KEY", "DEEPSEEK_API_KEY", "OPENAI_API_KEY"),
|
||||
)
|
||||
llm_base_url: str = Field(
|
||||
default="https://api.deepseek.com/v1",
|
||||
validation_alias=AliasChoices("LLM_BASE_URL", "DEEPSEEK_BASE_URL", "OPENAI_BASE_URL"),
|
||||
)
|
||||
llm_model: str = Field(
|
||||
default="deepseek-chat",
|
||||
validation_alias=AliasChoices("LLM_MODEL", "DEEPSEEK_MODEL", "OPENAI_MODEL"),
|
||||
)
|
||||
@field_validator("ssl_certfile", "ssl_keyfile", mode="after")
|
||||
@classmethod
|
||||
def resolve_ssl_path(cls, value: str) -> str:
|
||||
text = (value or "").strip()
|
||||
if not text:
|
||||
return ""
|
||||
p = Path(text)
|
||||
if not p.is_absolute():
|
||||
p = PROJECT_ROOT / p
|
||||
return str(p.resolve())
|
||||
|
||||
llm_api_key: str = Field(..., validation_alias="LLM_API_KEY")
|
||||
llm_base_url: str = Field(..., validation_alias="LLM_BASE_URL")
|
||||
llm_model: str = Field(..., validation_alias="LLM_MODEL")
|
||||
llm_timeout: int = 8
|
||||
llm_max_tokens: int = 150
|
||||
llm_temperature: float = 0.55
|
||||
@@ -44,26 +69,15 @@ class Settings(BaseSettings):
|
||||
tts_segment_pause_ms: int = 90
|
||||
tts_fade_ms: int = 12
|
||||
|
||||
webrtc_host: str = "0.0.0.0"
|
||||
webrtc_port: int = 8080
|
||||
http_host: str = Field(default="0.0.0.0", validation_alias="HTTP_HOST")
|
||||
http_port: int = Field(default=8080, validation_alias="HTTP_PORT")
|
||||
avatar_fps: int = 25
|
||||
avatar_driver_mode: str = "blendshape_stream"
|
||||
avatar_control_protocol: str = "ws"
|
||||
avatar_blendshape_schema: str = "arkit"
|
||||
stun_url: str = "stun:stun.l.google.com:19302"
|
||||
cors_origins: str = "*"
|
||||
ssl_certfile: str = ""
|
||||
ssl_keyfile: str = ""
|
||||
|
||||
# Legacy MuseTalk settings retained for migration reference only.
|
||||
musetalk_enabled: bool = True
|
||||
musetalk_repo_dir: str = "/home/xsl/work/MuseTalk"
|
||||
musetalk_infer_script: str = "/home/xsl/work/MuseTalk/scripts/inference.py"
|
||||
musetalk_source_video: str = "/home/xsl/work/MuseTalk/data/video/yongen.mp4"
|
||||
musetalk_unet_model: str = "/home/xsl/work/MuseTalk/models/musetalkV15/unet.pth"
|
||||
musetalk_unet_config: str = "/home/xsl/work/MuseTalk/models/musetalkV15/musetalk.json"
|
||||
musetalk_whisper_dir: str = "/home/xsl/work/MuseTalk/models/whisper"
|
||||
musetalk_result_dir: str = "/home/xsl/work/MuseTalk/results/visual-chat"
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
Reference in New Issue
Block a user