mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7855] [MERGED] fix(avatars): animate with the voice when replies are spoken #7971
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7971
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7855
Author: @SpicyMarinara
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/avatars-stream-audio-sync📝 Commits (4)
52c6eaffix(avatars): animate with the voice when replies are spoken431eb27Merge remote-tracking branch 'origin/staging' into fix/avatars-stream-audio-synce15e599fix(avatars): match the end of a reading by its own id7c39a71fix(avatars): do not count an earlier reading's voice as the new one📊 Changes
12 files changed (+1116 additions, -88 deletions)
View changed files
📝
docs/agents/avatars.md(+12 -1)➕
e2e/avatar-voice-sync.e2e.ts(+454 -0)📝
packages/client/src/components/chat/ChatArea.tsx(+86 -70)📝
packages/client/src/features/avatars/audio/avatar-audio.ts(+10 -2)📝
packages/client/src/features/avatars/contract.ts(+7 -1)📝
packages/client/src/features/avatars/director/avatar-director.ts(+219 -9)📝
packages/client/src/features/avatars/stage/AvatarStage.tsx(+7 -0)📝
packages/client/src/lib/tts-autoplay.ts(+15 -0)📝
packages/client/src/lib/tts-service.ts(+10 -1)📝
scripts/regressions/avatar-director.regression.ts(+246 -2)📝
scripts/regressions/avatar-tts-lipsync.regression.ts(+10 -1)📝
scripts/regressions/fixtures/avatar-3d-fixtures.ts(+40 -1)📄 Description
Linked issue
None. This comes from @SpicyMarinara's request on 2026-10-19: make 2D and 3D avatars work with streaming and with audio, where the audio usually arrives after the reply finished streaming. No issue was opened; open one first if you want this tracked.
Why this change
With text-to-speech Auto-play on in Roleplay, the avatar talked twice and showed its moods at the wrong time. I measured this in the real app: a fake model streamed a reply for about 3.8 s, with paragraphs that read happy, sad and angry, and a fake voice answered a few seconds later.
Before (staging
be73c3122, voice starting about 7 s after the reply):After (this branch, recorded by the new e2e test, times in seconds after Send):
What changed
lib/tts-autoplay.ts,ChatArea.tsx: auto-play announces a reading (marinara:tts-autoplay-voice,{chatId, messageId, readingId, pending}):readingIdis new for every reading, so the end of a replaced reading (a regenerated swipe keeps its message id) never ends the wait for the new one.pending: trueis sent before the speaker extractor or the voice loads.pending: falseis sent in afinallyhowever the reading ends: played, failed, no lines to read, stopped, superseded or chat changed.speakTTSAutoplayMessageonly moved inside thetry(use "Hide whitespace" in the diff).AvatarStage.tsx: tells the director whether Roleplay auto-play is on. It uses the same check ChatArea makes (enabled && autoplayRP, shareduseTTSConfigcache).avatar-director.ts: when a reply will be read aloud, the director waits for the voice:tts-service.ts,avatar-audio.ts,contract.ts:TTSPlaybackcarries the clip's text.line(): the text, and how far the voice is through the decoded clip (0..1).setVoiceAutoplay.avatar-director.regression.ts. I checked that it fails against the old director, both for the double talking and for the snap in a pause between clips.line()checks inavatar-tts-lipsync.regression.ts.e2e/avatar-voice-sync.e2e.ts: a real Roleplay chat with a fake streaming model and a fake delayed or failing voice, for a 2D and a 3D avatar. It records the stage's director frames and what the renderer drew (PNGTuber picture colours, VRM expression weights).expressiveVrm()). No new binary is committed.docs/agents/avatars.mdgains "When the reply is read aloud", plus one line each in the Expression Engine and lip sync sections. No existing wording changed.Decisions made while you were asleep
These are the conservative choices; each is easy to change.
voiceStartGraceMs2 s: how long to wait for a reading to begin after the reply ends.voiceReplayWithinMs5 s: a failure within this time replays the text animation; later ones only show the last mood.voiceWaitMaxMs30 s: the longest the avatar waits without hearing a voice.AVATAR_DIRECTOR_TIMING.Validation
pnpm checkpasses locallyCONTRIBUTING.mdRun by the agent (results, not ticks):
pnpm check: passed on the branch after merging currentstaging(0ebf2efaa). Its one lint warning is from staging, inHomeProfessorMariChat.tsx.avatar-*,tts-*,game-tts-*,roleplay-vn-ttsandnpc-avatar-lanregressions passed. So did the four that readChatArea.tsx(open-issues,roleplay-streaming,character-identity,frozen-server-client-timeouts).desktop-chromium, one worker,--mute-audioand--disable-audio-output): 47 passed. That covers the newavatar-voice-sync(2D and 3D, with the voice off, late and failing) plusavatar-2d,avatar-vrm,avatar-placement,avatar-preview,avatar-setup,avatar-vrm-tripo-removed,avatar-generation,tts-pcm-settings,tts-request-timeout,scene-tts-preferencesandtts-mobile-playback. Mobile and WebKit projects were not run./Users/marysia/Desktop/Maukie-VRoid/Maukie.vrm, which is not committed:e15e599f7per-reading id,7c39a7134earlier voice): all 19avatar-*and 7tts-*regressions passed, and the changed files passtsc, ESLint and Prettier. Both new director cases fail against the director from before each fix. On7c39a7134,avatar-voice-syncandavatar-2de2e passed again (20 tests,desktop-chromium, one worker, muted). The other e2e files above were not run again.Manual verification notes
To verify in the morning (Roleplay chat, 2D Avatars and 3D Avatars):
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)docs/agents/avatars.mdis updated in English. As instructed for this task, no[docs-i18n]issue was opened, so the translated packs still need the same update. There are no UI strings, so noen.jsonchanges, and no version or changelog changes.UI evidence (if applicable)
There is no new UI. The e2e test saves a screenshot and the full timeline (
timeline.json) for each run in its output folder.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.