- VoiceFrame dataclass: label, confidence, speaker_id, shift_magnitude, timestamp - MockVoiceIO: async generator of synthetic frames on a timer (CF_VOICE_MOCK=1) - ContextClassifier: passthrough stub wrapping VoiceIO; _enrich() hook for real classifiers - make_io() factory: mock mode auto-detected from env, raises NotImplementedError for real audio - cf-voice-demo CLI entry point for quick smoke-testing - 12 tests passing; editable install via pip install -e ../cf-voice
25 lines
740 B
Python
25 lines
740 B
Python
# cf_voice/cli.py — cf-voice-demo entry point
|
|
import asyncio
|
|
|
|
from cf_voice.context import ContextClassifier
|
|
|
|
|
|
async def _run() -> None:
|
|
print("cf-voice mock stream — Ctrl+C to stop\n")
|
|
classifier = ContextClassifier.mock(interval_s=2.0)
|
|
try:
|
|
async for frame in classifier.stream():
|
|
reliable = "+" if frame.is_reliable() else "?"
|
|
shift = " [SHIFT]" if frame.is_shift() else ""
|
|
print(
|
|
f"[{frame.timestamp:6.1f}s] {frame.speaker_id} "
|
|
f"{frame.label:<30} conf={frame.confidence:.2f}{reliable}{shift}"
|
|
)
|
|
except KeyboardInterrupt:
|
|
pass
|
|
finally:
|
|
await classifier.stop()
|
|
|
|
|
|
def demo() -> None:
|
|
asyncio.run(_run())
|