save code

This commit is contained in:
xsl
2026-03-29 23:01:39 +08:00
parent 36e838caec
commit 4dcae11c1b
30 changed files with 1094 additions and 203 deletions
+25 -2
View File
@@ -1,9 +1,17 @@
from pydantic import AliasChoices, Field
from pydantic import AliasChoices, Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
@field_validator("webrtc_host", mode="before")
@classmethod
def normalize_listen_host(cls, value: str) -> str:
host = str(value or "0.0.0.0").strip().lower()
if host in {"127.0.0.1", "localhost", "::1"}:
return "0.0.0.0"
return host or "0.0.0.0"
hf_token: str = ""
llm_api_key: str = Field(
@@ -20,6 +28,21 @@ class Settings(BaseSettings):
)
llm_timeout: int = 8
llm_max_tokens: int = 150
llm_temperature: float = 0.55
llm_system_prompt: str = (
"你是一个自然、友好的中文语音助手。"
"请像真人当面聊天一样回答,口语化、简洁、自然,通常 1 到 2 句。"
"不要使用书面公告腔,不要分点,不要长段解释,不要夸张语气词。"
"不要虚构身份关系,不要自称家人、恋人或其他私人身份。"
"避免客服套话,比如‘随时为你服务’、‘很高兴为你服务’、‘请问有什么可以帮您’。"
"优先使用短句和自然停顿,适合直接语音播报。"
)
tts_voice: str = "zf_xiaoxiao"
tts_speed: float = 0.9
tts_sentence_max_len: int = 64
tts_segment_pause_ms: int = 90
tts_fade_ms: int = 12
webrtc_host: str = "0.0.0.0"
webrtc_port: int = 8080