[OpenSpec 与项目骨架]:完成实施型变更与 Python 基础骨架,包含 OpenSpec 工件、核心模型、配置边界和基础测试
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable, Sequence
|
||||
from typing import Protocol
|
||||
|
||||
from .models import (
|
||||
AudioFrame,
|
||||
AudioSegment,
|
||||
Message,
|
||||
PlaybackResult,
|
||||
ReplyDelta,
|
||||
Transcript,
|
||||
TransportHealth,
|
||||
VadResult,
|
||||
WakeEvent,
|
||||
)
|
||||
|
||||
|
||||
class AudioTransport(Protocol):
|
||||
def start_input(
|
||||
self, device_id: str | None = None, sample_rate: int = 16000, channels: int = 1
|
||||
) -> None:
|
||||
...
|
||||
|
||||
def read_frames(self, timeout_ms: int) -> list[AudioFrame]:
|
||||
...
|
||||
|
||||
def play_pcm(self, segment: AudioSegment, interrupt: bool = False) -> PlaybackResult:
|
||||
...
|
||||
|
||||
def stop(self) -> None:
|
||||
...
|
||||
|
||||
def health(self) -> TransportHealth:
|
||||
...
|
||||
|
||||
|
||||
class WakeWordProvider(Protocol):
|
||||
def load(self) -> None:
|
||||
...
|
||||
|
||||
def detect(self, frame: AudioFrame) -> WakeEvent | None:
|
||||
...
|
||||
|
||||
def reset(self) -> None:
|
||||
...
|
||||
|
||||
|
||||
class VadProvider(Protocol):
|
||||
def load(self) -> None:
|
||||
...
|
||||
|
||||
def analyze(self, frame: AudioFrame) -> VadResult:
|
||||
...
|
||||
|
||||
def reset(self) -> None:
|
||||
...
|
||||
|
||||
|
||||
class SttProvider(Protocol):
|
||||
def load(self) -> None:
|
||||
...
|
||||
|
||||
def transcribe(self, segment: AudioSegment) -> Transcript:
|
||||
...
|
||||
|
||||
|
||||
class LlmProvider(Protocol):
|
||||
def stream_reply(self, messages: Sequence[Message]) -> Iterable[ReplyDelta]:
|
||||
...
|
||||
|
||||
|
||||
class TtsProvider(Protocol):
|
||||
def load(self) -> None:
|
||||
...
|
||||
|
||||
def synthesize(self, text: str) -> AudioSegment:
|
||||
...
|
||||
Reference in New Issue
Block a user