How ujwalpandey1/turncraft works
Turncraft is a Python library and offline CLI for explicit voice-turn boundaries, PCM16 framing, and generation-aware barge-in—not a speech recognizer or audio device. Its streaming workflow frames incoming bytes, scores each frame, segments confirmed speech into bounded utterances, and signals playback cancellation; hosts deliver utterances downstream and coordinate their own sink. Offline WAV segmentation and ordered event replay produce inspectable JSON, HTML, and WAV clips. The shown source supports the core calls; the host and audio sink remain external.
Main entry points: session.py WAV and event replay · pipeline.py Voice pipeline · reports.py Session reports and bundles · audio.py PCM framer and WAV I/O
Components 12
Audio framing
- PCM framer and WAV I/O
src/turncraft/audio.py
Turn processing
- Activity detectors
src/turncraft/detectors.py - Turn state machine
src/turncraft/segmenter.py - Voice pipeline
src/turncraft/pipeline.py
Playback coordination
- Playback generation gate
src/turncraft/playback.py
Offline inspection
- WAV and event replay
src/turncraft/session.py - Synthetic fixtures
src/turncraft/fixtures.py - Offline CLI
src/turncraft/cli.py - Session reports and bundles
src/turncraft/reports.py
Other components
- Voice application
- Host playback sink
- Downstream utterance consumer
Connections 19
- Voice application → PCM framer and WAV I/O: feeds bytes
README.md - PCM framer and WAV I/O → Voice pipeline: provides frames
README.md - Voice pipeline → Activity detectors: scores frames
src/turncraft/pipeline.py - Voice pipeline → Turn state machine: segments frames
src/turncraft/pipeline.py - Voice pipeline → Playback generation gate: cancels on start
src/turncraft/pipeline.py - Voice pipeline → Voice application: returns updates
README.md - Voice application → Downstream utterance consumer: dispatches utterances
README.md - Voice application → Playback generation gate: checks chunks
README.md - Voice application → Host playback sink: coordinates flush
README.md - Offline CLI → Synthetic fixtures: creates fixtures
src/turncraft/cli.py - Offline CLI → WAV and event replay: runs workflows
src/turncraft/cli.py - WAV and event replay → PCM framer and WAV I/O: reads WAV
src/turncraft/session.py - WAV and event replay → Voice pipeline: processes frames
src/turncraft/session.py - WAV and event replay → Activity detectors: selects detector
src/turncraft/session.py - WAV and event replay → Session reports and bundles: builds report data
src/turncraft/session.py - WAV and event replay → Playback generation gate: replays playback events
src/turncraft/session.py - Offline CLI → Session reports and bundles: writes output bundle
src/turncraft/cli.py - Session reports and bundles → PCM framer and WAV I/O: writes utterance WAVs
src/turncraft/reports.py - Session reports and bundles → Turn state machine: renders utterances
src/turncraft/reports.py