move vad config to json
This commit is contained in:
@@ -28,6 +28,39 @@ class SessionConfig:
|
||||
inactivity_timeout_sec: int = 60
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class VADConfig:
|
||||
"""Voice Activity Detection thresholds for the Silero analyzer.
|
||||
|
||||
These map directly to ``pipecat.audio.vad.vad_analyzer.VADParams``.
|
||||
Defaults are tuned a touch more conservative than upstream pipecat so
|
||||
short pauses in continuous speech don't end the user turn prematurely.
|
||||
"""
|
||||
|
||||
confidence: float = 0.7
|
||||
start_secs: float = 0.2
|
||||
stop_secs: float = 0.6
|
||||
min_volume: float = 0.6
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TurnConfig:
|
||||
"""User-turn segmentation policy.
|
||||
|
||||
``user_speech_timeout_sec`` is the grace window (in seconds) after VAD
|
||||
has confirmed silence during which the user is allowed to resume
|
||||
speaking before the aggregator finalizes the turn. Used by
|
||||
``SpeechTimeoutUserTurnStopStrategy``. Higher = more tolerant of
|
||||
natural mid-sentence pauses; lower = snappier turn-taking.
|
||||
|
||||
The combined "user pause before turn ends" budget is roughly
|
||||
``vad.stop_secs + user_speech_timeout_sec``.
|
||||
"""
|
||||
|
||||
vad: VADConfig = field(default_factory=VADConfig)
|
||||
user_speech_timeout_sec: float = 1.0
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AgentConfig:
|
||||
system_prompt: str = "You are a helpful, friendly voice assistant."
|
||||
@@ -90,6 +123,7 @@ class EngineConfig:
|
||||
server: ServerConfig = field(default_factory=ServerConfig)
|
||||
audio: AudioConfig = field(default_factory=AudioConfig)
|
||||
session: SessionConfig = field(default_factory=SessionConfig)
|
||||
turn: TurnConfig = field(default_factory=TurnConfig)
|
||||
agent: AgentConfig = field(default_factory=AgentConfig)
|
||||
services: ServicesConfig = field(default_factory=ServicesConfig)
|
||||
|
||||
@@ -116,10 +150,19 @@ def config_from_dict(data: dict) -> EngineConfig:
|
||||
if stt.get("language") == "":
|
||||
stt["language"] = None
|
||||
|
||||
turn = _dict(data.get("turn"))
|
||||
vad = _dict(turn.get("vad"))
|
||||
|
||||
return EngineConfig(
|
||||
server=ServerConfig(**_dict(data.get("server"))),
|
||||
audio=AudioConfig(**_dict(data.get("audio"))),
|
||||
session=SessionConfig(**_dict(data.get("session"))),
|
||||
turn=TurnConfig(
|
||||
vad=VADConfig(**vad),
|
||||
user_speech_timeout_sec=float(
|
||||
turn.get("user_speech_timeout_sec", TurnConfig().user_speech_timeout_sec)
|
||||
),
|
||||
),
|
||||
agent=AgentConfig(**agent),
|
||||
services=ServicesConfig(
|
||||
llm=LLMConfig(**_dict(services.get("llm"))),
|
||||
|
||||
Reference in New Issue
Block a user