[Pipeline 状态机]:完成TurnController重构,包含wake到standby闭环和错误恢复

This commit is contained in:
mkbk
2026-06-17 21:29:28 +08:00
parent a251ff379d
commit f9da304568
5 changed files with 364 additions and 7 deletions
+4 -3
View File
@@ -5,6 +5,7 @@ from dataclasses import dataclass, field
from typing import Protocol
from .config import AppConfig
from .assistant_pipeline import VoiceAssistantPipeline
from .conversation import ConversationContext
from .events import (
ACK_STARTED,
@@ -325,7 +326,7 @@ class LiveVoiceRuntime:
dispatch_pipeline_event(self.reporter, event)
def build_live_runtime(config: AppConfig, reporter: RuntimeReporter | None = None) -> LiveVoiceRuntime:
def build_live_runtime(config: AppConfig, reporter: RuntimeReporter | None = None) -> VoiceAssistantPipeline:
errors = config.validate_basic()
if errors:
raise errors[0]
@@ -344,7 +345,7 @@ def build_live_runtime(config: AppConfig, reporter: RuntimeReporter | None = Non
vad_provider = SherpaOnnxVadProvider(config.speech_models_dir, threshold=config.vad_threshold)
else:
vad_provider = EnergyVadProvider()
return LiveVoiceRuntime(
return VoiceAssistantPipeline(
config=config,
transport=SoundDeviceAudioTransport(output_device=config.audio_output_device),
wakeword=SherpaOnnxKeywordWakeWordProvider(
@@ -369,5 +370,5 @@ def build_live_runtime(config: AppConfig, reporter: RuntimeReporter | None = Non
max_messages=config.context_max_messages,
max_chars=config.context_max_chars,
),
reporter=reporter,
reporter=reporter or TerminalRuntimeReporter(),
)