Repository navigation
feat: Audio8 TTS plugin with one-shot voice cloning, fast decoders and streaming - #1
Merged
Merged
Conversation
OVOS TTS plugin for Edge0/Audio8-TTS-Realistic-0.6b (pinned, reviewed revision). Voices clone from a reference clip plus its exact transcript; reference codes are encoded once and cached. frame_decoder.py replaces upstream generate() with a static-buffer frame loop (no per-frame host sync, no in-loop tensor creation, semantic-only logits) run as a CUDA graph, via torch.compile, or eagerly. Measured steady RTF: RTX 3090 1.26 -> 0.27, M3 Max MPS 1.28 -> 0.54. CPU is not real time (1.49) and the README says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plugin is now a StreamingTTS. With enable_streaming, ovos-audio plays each sentence while it is still being generated: first audio at 0.43s instead of ~2.7s on an M3 Max (RTF 0.54 -> 0.64). Each chunk re-decodes the sentence from frame 0. The codec is causal but its stacked windowed attention sees the whole utterance, so prefix decode is the only exact chunking (bounded windows still err by 1e-3 at 256 frames of context). Chunk sizes double from 12 frames to bound the cost. Streamed audio equals the non-streamed decode to float noise. Also: - get_tts and stream_tts split utterances into sentences, so long text is no longer cut at max_new_tokens. - init() only builds a stream player when streaming is enabled, so installs without ffplay/paplay/aplay keep working. - The cached streaming WAV gets real header sizes after the stream ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
transformers 5 builds models on the meta device, so Audio8's non-persistent RoPE tables (freqs_cis, fast_freqs_cis) are never filled: one comes out as garbage (~1e30), the other as zeros. Weights and token ids load identically; only these buffers differ. The model then never emits EOS and every sentence runs to max_new_tokens. Recompute both tables after from_pretrained (a no-op on 4.x), allow transformers <6, and lock the project on 5.x so CI tests the major version OVOS installs ship. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OPM's default stream player, `ffplay -autoexit -nodisp -`, probes about 2 s of piped input before it plays anything, which hid most of the streaming gain. Measured on a realistic feed: first sound at 2.33 s by default, 0.22 s with -probesize 32 -analyzeduration 0 -fflags nobuffer, no audio dropped. When streaming is enabled, init() now builds the StreamingTTSCallbacks itself with those flags (stream_player_args overrides; without ffplay OPM still picks paplay/aplay). In live ovos-audio on an M3 Max, the end of each sentence went from 2.7-4 s after its audio length to ~1 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two artifacts Mike heard in live streaming playback, both measured: - Loud burst at the end: the model's last frame before EOS decodes to a ~46 ms swell to -20 dB right after near-silence. It was in all 31 files scanned, streamed and non-streamed. That frame is no longer decoded; streaming holds the newest frame back until another follows. - Cut-off first sound: ffplay drops roughly the first 100-140 ms of a piped stream (and clips the end at -autoexit). Streams now open and close with 200 ms of silence. In an OBS capture of the played audio, the first 50 ms of speech now match what was sent (residual -68 dB). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Audio8 has no phoneme alignment, so mouth movement comes from the audio: 40 ms RMS windows pick a Mycroft viseme code on an openness ladder (closed 4, half 3, round 2, wide 0). Thresholds sit at percentiles of measured Audio8 speech (median window -35.6 dBFS). - Non-streamed: get_tts returns the visemes in the phonemes slot, so ovos-audio sends them at playback and the OVOS cache keeps them. - Streamed: OPM's streaming path sends no visemes, so the stream callbacks compute them per PCM chunk and emit each chunk's enclosure.mouth.viseme_list when that chunk starts to play, tracked by a playhead that survives player stalls. Live check: the last list ends at the same moment as audio_output_end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
Mike heard short pauses mid-speech. Doubling chunk sizes starved the player on long sentences at MPS speed: each chunk waited until it was as long as everything already sent, while re-decoding the whole prefix got more expensive (0.98 s at 208 frames). Measured on a 10 s sentence: 0.90 s of gaps inside speech. chunking.py now plans at every EOS check, using a playback clock shared across the utterance and running estimates of generation and decode cost. It decodes when waiting would let the queue run dry, but never a chunk smaller than one that outlasts its own generation plus prefix re-decode (otherwise emitting more often falls further behind), and the utterance's first chunk is 15 frames so the stream starts with a lead. Same sentence: 0.29 s of gaps in speech, all in the first 3 s; the two-sentence line has none. The viseme callbacks share the same clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
Two causes behind the gaps Mike still heard, both measured on the Mac: - Idle penalty: the first reply after a few idle minutes started 2.07 s late with a 0.91 s gap; an immediate repeat started in 0.87 s with 0.08 s gaps. Prefill and codec costs do not depend on new shapes (measured), and replies are serialized by ovos-audio's playback_lock; the box is deep in swap (16.4 of 17.4 GB) with an 11 GB ovos-audio footprint. On the wake word (also record_begin, mic.listen) the plugin now reads every weight and buffer once on a background thread, during the 1-3 s STT/intent window. Read-only, throttled to once per 20 s, and it never loads an unloaded model. - Long Wikipedia-style sentences (~50 words, ~390 frames) cost more to re-decode per chunk than the chunk's audio on MPS. Streaming now splits sentences over 100 characters at clause breaks (word boundaries in balanced halves only for a single over-long clause). The Elvis answer streams with no gaps inside speech. Non-streamed get_tts keeps whole sentences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
OPM's queue path creates the cache folder before get_tts, but its streaming path opens the WAV directly. With the folder gone, every line failed with ENOENT and ovos-audio fell back to another voice (found when the cache folder was deleted during a demo take; macOS also prunes old $TMPDIR contents on its own). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
Audio8 copies the reference clip's level: two clips 16.3 dB apart gave outputs 16.1 dB apart, so a loud clean clip played ~10 dB hotter and pinned the mouth wide open. Each voice now gets one gain from its reference clip (speech median minus a measured 2.7 dB offset, towards a -29 dB speech median with ~3 dB peak headroom), applied to streamed and non-streamed audio alike. A fixed per-voice gain cannot pump mid-stream. The viseme ladder is now relative to that target level, so mouth movement no longer depends on which clip was used. Measured: the two voices went from 16 dB apart to ~4.5 dB, about the line-to-line spread within one voice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
Mike heard a consistent clip mid-sentence in streamed playback. Played audio (OBS capture) matched the sent bytes until 2.71 s, then ~0.4 s was discarded and playback resumed 40 samples late: ffplay drops audio and resyncs when a chunk lands as its buffer runs dry. The model's own output was clean (six offline renders, none clipped). The empty moment was in the ramp-up, where a 0.70 s first chunk could not cover generating plus re-decoding the third. First chunk is now 31 frames (1.44 s) and the scheduler keeps 0.5 s (was 0.15 s) beyond its cost estimate. On the weather, joke and 10 s Romulan lines: no underrun inside speech. Time to first audio is ~1.0 s (was ~0.56 s). A player that plays silence instead of resyncing is the real fix and is planned separately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7
…y limit 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.
Summary
OVOS TTS plugin for Edge0/Audio8-TTS-Realistic-0.6b. It clones a voice from one short clip and its exact transcript. Proof of concept.
Hardware: NVIDIA GPU or Apple Silicon. Not for a Raspberry Pi.
What's in it
generate()is overhead-bound.frame_decoder.pyruns each frame on fixed buffers, then replays it as a CUDA graph, compiles it, or runs it eagerly. Steady RTF: RTX 3090 1.26 → 0.27, M3 Max MPS 1.28 → 0.54.enable_streaming): playback starts in ~1.0 s instead of waiting ~2.7 s for the first sentence. Each chunk re-decodes the sentence from its first frame; the codec looks back over the whole sentence, so this is the only exact way to decode in chunks. A playback-deadline scheduler sends each chunk beforeffplayruns dry, and never one too small to pay for its own decode.Verification
Known limit and follow-up
ffplaydiscards audio and resyncs when it runs dry. The scheduler margins and a 1.4 s first chunk keep it fed on the measured lines, but the real fix is a built-in player that plays silence instead (tracked in a follow-up issue).Safety
trust_remote_codeis pinned to a reviewed revision.🤖 Generated with Claude Code
https://claude.ai/code/session_012QBrfL1NoPWS1MG92dnWm7