mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7555] [MERGED] feat(avatars): live faces and lip sync (director and streaming classifier) #7794
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#7794
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/7555
Author: @SpicyMarinara
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/avatars-director📝 Commits (10+)
92d1ce1feat(avatars): live faces and lip sync for avatars (director and classifier)efc910ctest(avatars): director regression, guide section, and dispose fixes2ecf763Merge remote-tracking branch 'origin/feat/avatars-contract' into feat/avatars-director6838237fix(avatars): Game lines reach a late stage, not while reviewing past turnsffffb4cfix(avatars): a reset classifier load never becomes the model; plainer guide1a601feMerge remote-tracking branch 'origin/staging' into feat/avatars-directora85c132fix(avatars): director review fixes and the opt-in mood reader download8f5655efix(avatars): a text the emotion model does not answer in time stops its worker9bb959afix(avatars): a late Game stage keeps the last face without speaking an old line3510beedocs(avatars): say the mood reader retries a failed download in about 10 minutes📊 Changes
24 files changed (+3577 additions, -102 deletions)
View changed files
📝
docs/agents/avatars.md(+23 -1)📝
packages/client/src/components/chat/SpriteOverlay.tsx(+8 -25)📝
packages/client/src/components/game/GameNarration.tsx(+6 -0)➕
packages/client/src/features/avatars/director/AvatarModelStatus.tsx(+54 -0)📝
packages/client/src/features/avatars/director/avatar-director.ts(+642 -18)➕
packages/client/src/features/avatars/director/game-line-feed.ts(+59 -0)➕
packages/client/src/features/avatars/director/reply-text.ts(+179 -0)➕
packages/client/src/features/avatars/director/speech-clock.ts(+214 -0)📝
packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx(+2 -0)➕
packages/client/src/hooks/use-avatar-emotion-model.ts(+33 -0)📝
packages/client/src/hooks/use-generate.ts(+17 -0)📝
packages/client/src/localization/locales/en.json(+8 -0)📝
packages/server/src/middleware/rate-limit.ts(+14 -0)📝
packages/server/src/routes/avatar-classify.routes.ts(+61 -5)📝
packages/server/src/routes/generate/expression-agent-utils.ts(+2 -40)➕
packages/server/src/services/avatars/classifier/emotion-model.worker.ts(+46 -0)➕
packages/server/src/services/avatars/classifier/local-emotion-model.ts(+190 -0)📝
packages/server/src/services/avatars/emotion-classifier.ts(+322 -12)📝
packages/server/src/services/local-embedder.ts(+1 -1)📝
packages/shared/src/index.ts(+1 -0)...and 4 more files
📄 Description
Linked issue
Refs #7537 (lane: Director). Guide translation follow-up: #7540.
Depends on https://github.com/Pasta-Devs/Marinara-Engine/pull/7539, "feat(avatars): shared contract for the 2D and 3D avatar agents" (Refs #7537). It has now merged into
staging, and this branch mergedstagingat1a601fe43, so the diff shows only this lane. The TTS lane (#7547) and the avatar docs (#7551) are also onstagingand in that merge. After the 2D lane (#7549) landed, the branch mergedstagingagain ate481304aa. The only conflict wasen.json, resolved by keeping both key blocks in sorted order.Merge note for whichever of #7555 and #7556 merges second. The mood reader's status panel (
AvatarModelStatus) is mounted by this PR since5a467451c. The setup page stubfeatures/avatars/setup/AvatarAgentSetup.tsxrenders<AvatarModelStatus />, andavatar-director.regression.tsfails if the setup page stops importing or rendering it. That stub belongs to the base lane (#7556), so the second PR gets one conflict in that file. Resolve it by keeping #7556's page and addingimport { AvatarModelStatus } from "../director/AvatarModelStatus";plus<AvatarModelStatus />as the first child of<div className="space-y-4" data-avatar-setup={agentId}>. That resolution was checked locally (see Validation). Earlier, the mount was only requested on #7556 (https://github.com/Pasta-Devs/Marinara-Engine/pull/7556#issuecomment-6154694561), and the integration check found that no merged page showed the panel.Why this change
emotion-classifier.ts): the emotion model downloads only when an avatar agent is enabled, never on install or on the first classify request. The agent's page shows the progress and any error, and Lite and Termux keep skipping it.ffffb4c22found several problems. A reply's last moods were lost while the typewriter caught up, and in group chats the wrong avatar spoke. A late Expression Engine pick froze the next reply's face. The model loaded and ran on the server's main thread during streaming. It could not load offline, and it left partial downloads behind.What changed
"Get out," Bob growls.) therefore never makes two avatars say the line.[Name]:lines, speaker tags), at about 14 characters a second. They speed up to 1.5x and then skip ahead when the text outruns speech, and close 150 ms after the last word. Japanese kana pick the mouth shape by vowel row, and other scripts move rhythmically. While text-to-speech plays, the voice level moves the mouth instead.POST /api/avatar-classify/model. The server accepts that only for a Roleplay chat with an installed avatar agent turned on, and answers 409 otherwise. Installing an agent never downloads it, a classify request never downloads or loads it, and Game mode never asks for it.GET /api/avatar-classify/modelreports the state for the agents' pages: not downloaded, downloading, loading, downloaded, failed, or kept on the word list. The newAvatarModelStatusshows it in plain, localized copy with a progress bar.docs/agents/avatars.mdcovers the download rule, the progress on the agent page, offline use, memory, the Game thought rule and group chats.Contract and shared-file changes (called out)
packages/shared/src/index.ts: one added export line for the newutils/expression-keywords.ts. This is additive, andtypes/avatars.tsis untouched.packages/shared/src/types/agent.ts:AgentResultgains an optionalmessageId. It is additive, and existing results without it behave as before.createAvatarDirector(options, hooks?): an optional second parameter that only regressions use (stubbed classify and prepare calls). The stage's one-argument call is unchanged.SpriteOverlay.tsx,expression-agent-utils.ts);middleware/rate-limit.ts);exporton the existing ONNX binding check (local-embedder.ts);GameNarration.tsx;hooks/use-generate.ts: a swipe in an Individual group names its member as the streaming character, and both agent-result paths keep the result's message id;hooks/use-avatar-emotion-model.tsfor the status query;features/avatars/setup/AvatarAgentSetup.tsx: it renders<AvatarModelStatus />, so the panel is on both avatar agents' pages whichever PR merges first (see the merge note above).en.json: new flat keys underavatars.director.model.*only, placed afterapp.documentTitle. The base lane'savatars.setup.*block sorts after them.Model choice (classifier research, 2026-10-13)
This model ranked first in the research. Its licence is permissive (Apache-2.0, on the MIT-licensed base mmBERT-small), and its ONNX q8 build runs unchanged in the Engine's installed
@huggingface/transformers4.3.0. It is multilingual: BRIGHTER 10-language top-1 is 0.69, against about 0.39 for the English-only models. It is on par with SamLowe on English GoEmotions. Its weakness is narrated roleplay prose, which the keyword blend covers.Per Mari's decision, the commit is pinned and the files come from Horizon directly, with no mirror. On 42 roleplay lines written in 9 languages, the model alone got 20/42, keywords alone 28/42, and the blend 34/42. That set is small and self-written, so it is only a rough signal.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent are listed below as results, not ticked boxes. They ran on a machine shared with other lanes, with a load average of 20–35. Final head:
5a467451c.Integration fix on
5a467451c(the mood reader panel had no mount on the merged tree):pnpm check: exit 0, with the same pre-existing lint warning inHomeProfessorMariChat.tsx. Main entry: 313 kB.avatar-(10/10, now including the 2D lane's),agent-activation(2/2),spatial-context,open-issues,game-narration(2/2),roleplay-streaming,expression-(2/2),group-(7/7) androleplay-vn-tts.avatar-director.regression.tsfails on the old null stub and on #7556's page at2b417feaa. It passes with the mount.2b417feaa) into this branch, discarded afterwards:AvatarAgentSetup.tsxwas the only conflicting file, resolved as in the merge note. On that tree,avatar-regressions passed 12/12. Playwright on private ports passed #7556'se2e/avatar-setup.e2e.tsand a temporary spec on desktop Chromium and mobile Chromium (6/6). The temporary spec has since been deleted. It showed the panel on the 2D and 3D Avatars pages with "Downloading the mood reader: 41%." and its progress bar, inside the phone's width, and confirmed that opening the page never starts the download.coderabbit review --agent --committed --base-commit e481304aa): 0 findings, 2 files reviewed.pnpm checkon3510bee81: exit 0. It covers format, localization, impeccable, lint, type checks and the production build. The one lint warning is pre-existing, inHomeProfessorMariChat.tsx. Main entry: 313 kB. It also passed ona85c132fc.node scripts/run-regressions.mjs --filter <name>, run per filter, all passed:3510bee81:avatar-(8/8, includingavatar-classifier,avatar-director, theavatar-contractguard andavatar-tts-lipsync),open-issues,game-narration(2/2),roleplay-streamingandexpression-(2/2);a85c132fc:agent-activation(2/2),spatial-context,roleplay-vn-ttsandgroup-(7/7).pnpm localization:checkon3510bee81: exit 0.Proof that the new director checks catch the reported bugs. I copied
avatar-director.regression.tswith every assertion turned into a logged check (a temporary copy, since deleted) and ran it against the old director files fromffffb4c22. Every new check failed there:["t","o","h","e",…]reached the classifier after message-ready;"Alic","Alice smi", … sent to the classifier;{"alice":2992,"bob":0});The real pinned model, run outside CI through the worker, with
DATA_DIRset to a temporary folder under the worktree that was deleted afterwards:fetchstubbed to throw, the model loaded from disk with no network request.A timed-out text, checked by hand. With the classify timeout lowered to 1 ms (by hand, then restored to 10 s), a 6-text request with the real model fell back to keywords in 43 ms in total. The model was dropped, and the next request answered from keywords at once.
pnpm smoke:uion private ports, ona85c132fc: 7/7 passed, including Roleplay reasoning, stopped generations and Game narration.Local CodeRabbit (
coderabbit review --agent --committed --base-commit 797877c54, base = currentstaging):a85c132fc: 0 findings, reviewing 23 files;8f5655ee9: 1 finding. A Game stage that mounted after narration still spoke the last dialogue line. Fixed in9bb959a7f, with a regression;9bb959a7f: 2 findings. The retry copy said "a few minutes" while the code waits 10. Fixed in3510bee81. The other asked for a[docs-i18n]follow-up fordocs/agents/avatars.md, and was not changed: #7540 already covers that file and is linked above.3510bee81, which only changes copy.2ecf763e5, one run found 3 issues, all fixed in68382373c.GitHub review threads. All 8 are resolved; 5 were fixed or answered earlier.
a85c132fc, answered and resolved.file-path rule belongs to the merged contract and the 2D lane's data. It was answered and handed to #7549 (https://github.com/Pasta-Devs/Marinara-Engine/pull/7549#issuecomment-6154710680), then resolved here, because this PR no longer touches those files.a85c132fc: a timed-out text left later texts waiting behind a busy worker. Fixed in8f5655ee9, answered and resolved. That review used the last of the hourly included GitHub reviews, so the GitHub review of3510bee81may come late.Not fixed here, follow-ups. With streaming off in an Individual group, only the last member's reply moves an avatar: the server sends one
assistant_message_readyafter the group loop, and text-to-speech autoplay reads only that message too. Impersonation still streams into the character's live row, which the Roleplay surface itself renders as the character, so the character's avatar mouths it. Both need a server event or chat-store signal outside this lane.Manual verification needed
The director has no UI of its own beyond the mood reader panel. The rest shows once the base lane's stage and a renderer are on
staging.[thought]lines leave the mouth still;…," Bob growls.: only Bob's mouth says it;staging). Check each of these:DATA_DIR/models/avatar-emotion/1bc9627f…holds about 289 MB;*.downloadleftover existed, and the next download replaces it;[avatar-classify] … tier …lines with moods and timings, never chat text.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs note:
docs/agents/avatars.mdgets the updated section "How faces and mouths follow the reply". Its translation is covered by the existing follow-up #7540.UI evidence (if applicable)
staging. The local merged-tree run above checked it on desktop and phone widths. No screenshot is attached.🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.