Repository navigation
feat: built-in sounddevice stream player - #4
Merged
Merged
Conversation
ffplay reading stdin discards ~0.4 s and resyncs when a chunk lands as its buffer empties, drops the first ~0.1 s of a stream and clips the end. PcmPlayer owns the buffer instead: an underrun plays silence and nothing written is skipped, and the device's reported latency replaces the 0.1 s guess in the chunk scheduler. - stream_player: auto (default) | sounddevice | ffplay. auto uses the built-in player when sounddevice and an output device exist. - The built-in player needs no silence pad; ffplay keeps its 0.2 s pad. - VisemeStreamCallbacks splits into VisemeScheduler plus one callbacks class per player. - New optional extra: ovos-tts-plugin-audio8[player]. Closes #2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
The ffplay fallback cases built real OPM callbacks, which raise when no player is on PATH (CI runners have no ffmpeg). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2.
Why
ffplay reading stdin discards about 0.4 s and resyncs when a chunk arrives as its buffer empties. This is the clip heard in the demos (measured played vs. sent). It also drops the first ~0.1 s of a stream and clips the end, which is why streams carried a 0.2 s silence pad.
What
player.py:PcmPlayer, a sounddeviceRawOutputStreamwith its own buffer. On underrun it plays silence and continues. Nothing that was written is skipped. It counts underruns as events, not callbacks, and reports the device latency (about 30 ms on MacBook Pro speakers).stream_players.py:SoundDeviceStreamCallbacks(no pad, real latency).FfplayStreamCallbacks(previous behavior, kept as the fallback).make_stream_callbackspicks a player from the newstream_playerkey (auto/sounddevice/ffplay).autouses the built-in player when sounddevice and an output device exist, and falls back to ffplay with a log line.stream_player_argsstill forces a subprocess player.visemes.py:VisemeStreamCallbacksis now a player-independentVisemeScheduler.tts.py:stream_ttstakes its pad and playback latency from the active player, so the chunk scheduler uses the real device latency.[player](sounddevice>=0.4). README updated.Verification
SoundDeviceStreamCallbacks. Two live utterances played with no fallback, no underrun, and no synth errors inaudio.log.Not in this PR: reducing
STARTUP_CHUNK_FRAMESfor lower time-to-first-audio. That needs its own measurements.🤖 Generated with Claude Code
https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7