Files
ai-passport/docs/face-clock.md
T
hex2077 6a7f4e010b chore: 新增大量静态资源、测试桩文件与配置文件,清理旧无用资源
本次提交新增了多种字体、UI图片、音频剪辑等静态资源,添加了测试桩文件与项目配置文件,同时清理了部分已废弃的旧图片与测试桩代码文件。
2026-09-22 00:42:26 +08:00

9.8 KiB

简体中文 · English

XiaoZhi expressions and shared clock

Version 2.6.17 offers four switchable styles: a cute character, a male portrait with a rounded bald head, soft reflection and small glint and a female portrait with a rounded bob, hair clips and earrings, and King of the Road. Both portraits use a balanced facial grid, small nose and rounded cheeks. The cute character is rounded with short ears, a curled tuft, cheeks and small paws. It supports all 21 XiaoZhi emotion tags, with three curated poses per tag (63 poses per style, 252 total). Original SVG sources are in assets/images/xiaozhi-face/. Run python tools/generate_face_assets.py with Pillow to regenerate the checked-in A8 masks. The offline converter deliberately accepts only the SVG elements used by these assets. Firmware builds use the generated arrays and do not require an SVG/GIF decoder.

The cropped, deduplicated, losslessly compressed alpha masks occupy 136,196 bytes before image descriptors: three silhouettes, bald highlights, portrait nose/ear details, female hair and accessories, and 26 shared portrait eye shapes (21 emotions, a blink and four extra eye styles), 24 mouth shapes (21 emotions plus three PCM-driven speaking shapes), and eight shared decorations. SVG sources can be recreated with python tools/draw_face_sources.py; run python tools/draw_abstract_sources.py for the cartoon portrait, then regenerate the arrays. Alpha masks use the badge accent/text/background colors, selecting contrasting facial ink. A changed emotion refreshes the character area once; ordinary mouth/blink changes invalidate only their small rectangles; no full-screen animation buffer or frame queue is added. The UI's existing timer performs updates and is stopped with LVGL on screen sleep; it is deleted before page teardown.

Cloud llm.emotion selects a dedicated three-pose pool for each of these tags: neutral, happy, laughing, funny, sad, angry, crying, loving, embarrassed, surprised, shocked, thinking, winking, cool, relaxed, delicious, kissy, confident, sleepy, silly, confused. Glasses, tears, hearts, blush, a thinking hand and small symbols distinguish the character poses. Listening/thinking/error states take precedence. Unsupported emotions fall back to neutral. Speaking mouth size follows the latest successfully written PCM envelope, not caption progress or receipt of a server speaking message. Its monotonic deadline is 100 ms after a successful write, allowing for the existing six 240-sample DMA buffers at 16 kHz. The UI returns stale speaking mouths to the current emotion's static mouth on its next tick even if the server still reports speaking. Pausing, interruption and state changes also end the speaking motion. Static laughter or surprise may have an open mouth by design. Automatic blinking does not overwrite glasses or a deliberate wink. This is an amplitude visualization, not phoneme-accurate lip synchronization; final physical timing still needs a speaker/display measurement.

The voice worker owns a RAM-only shuffle bag for each emotion. All three poses are used before refilling the bag; the last pose is excluded from the first draw of the next bag. Repeated copies of the same tag within a reply hold the current pose and do not consume the bag. A new conversation turn or an explicit change to a different emotion allows another choice. Leaving the session or rebooting resets this history. Missing emotion fields are ignored; unknown nonempty tags fall back to neutral. Rendering never draws a random choice on every timer tick. The eye/mouth offsets and shared hearts, tears, stars and hand positions belong to the selected pose; after PCM expires the same pose's static mouth is restored.

The common header displays only HH:mm in 24-hour China standard time (UTC+8), without a date. After Wi-Fi obtains an IP address, asynchronous SNTP synchronizes UTC through ntp.aliyun.com; reconnection restarts synchronization. A clock that has not yet been set displays --:--. No Chinese clock placeholder is drawn. Once synchronized, the system clock continues while temporarily offline; a cold boot without network cannot recover wall-clock time. No global timezone or saved profiles are changed. Existing once-per-second status processing updates the text only when it changes and skips screen-off rendering.

Host tests cover clock rollover, unset time, emotion fallback, silence/interruption, stale audio and 32-bit monotonic wraparound. Tests also cover a unique mapping for every tag, restoration of each static mouth after expiry and unknown-tag fallback. Rendering checks must include the longest header (100% battery, badge count, Wi-Fi), both clock states, mouth expiry without a new network message and repeated page lifecycles. Builds and host tests do not establish real speaker/animation synchronization or cloud recognition quality.

Settings → XiaoZhi AI → Expression style switches between the cute, male, female and King of the Road styles with OK. The choice is persisted in NVS xiaozhi/face_style; existing installations keep the cute style by default. Navigation performs writes outside the LVGL lock; rendering only reads an atomic cache. Missing/invalid values default to cute, and a failed save preserves the previous selection.

Thinking is visually held for at least 900 ms. If reply audio starts sooner, only the thinking eyes are retained: PCM-driven mouth movement, audio and subtitles continue immediately. The latest emotion appears after the deadline. Listening, pause, error and activation cancel the hold immediately. The UI refresh period can add one tick to the visual deadline. Host coverage includes timer wraparound, cancellation, NVS failures and 252 rendered poses; real conversation timing still requires device observation.

Persisted style IDs remain compatible: 0 is cute, 1 is the redesigned male portrait and 2 is the female portrait and 3 is King of the Road. Settings cycle through all four and restore the choice on reboot. Existing cartoon-portrait selections become the redesigned male avatar. Female contour, hair and accessories reuse the portrait facial parts, avoiding a full image per emotion.

Conversation shortcuts: hold Up to cycle and save cute, male, female and King of the Road styles without stopping the audio worker or recreating the conversation UI. Hold Down to open XiaoZhi settings directly, using the existing stop/connection-reuse path. Back or Start conversation from this entry returns to chat, preserving its earlier return destination. Short Up/Down adjusts volume, OK starts/pauses/interrupts and long OK opens the return chooser. Host tests verify glyph coverage and width for the single bottom hint row.

2.6.15 redraws all 21 human mouth shapes and curved eyelids and uses dedicated human three-pose combinations instead of mascot lips. A shorter nose, restrained brows/blush and smaller tear drops avoid feature collisions. Only the third funny pose retains a laughter tear. Bald-head reflection and glint are static theme-aware alpha layers, adding no high-frequency animation timer or audio delay.

2.6.16 adds King of the Road (persisted ID 3), redrawn from the user reference with a broad round face, fluffy short hair, horizontal brows, tiny eyes and restrained lips. The source image scene/text is not included. Skin, hair, features, nose, collar, blush and tears derive from the badge palette with contrasting facial ink, rather than fixed reference colors. Its 21 emotions and three small PCM mouth shapes use the human three-pose recipes. Run python tools/draw_round_sources.py before the shared asset converter. Eye halves are cropped and deduplicated separately to remove transparent space without changing pixels or introducing runtime decompression. Hold Up in conversation to cycle/save four styles, or hold Down to open XiaoZhi settings.

2.6.17 uses row-indexed lossless run-length encoding, retaining raw A8 for small assets that do not shrink. Each draw session decodes only visible rows into one scanline (at most 160 pixel bytes plus LVGL bookkeeping); no full-face cache or grayscale reduction is used. All 252 complete renders match 2.6.16 pixel for pixel. Screen teardown removes the decoder and its header cache entries.

Recognized input has its own two-line area and persists until the next recognition, including automatic re-listening. Long input starts at the beginning and advances two lines every three seconds, holding the final page before looping. The reply below keeps its independent audio clock and typewriter effect; audio and reply text never wait for input reading. Error and activation pages hide the conversation areas.

Road King default expression (2.6.32)

Only Road King remaps neutral/default expressions: variants A and B use angry poses, and C uses a confident pose. The existing three-variant shuffle yields two angry and one confident pose per completed neutral cycle, not a fixed time ratio. Explicit emotions, thinking/error overrides and PCM-driven mouth timing retain their existing meaning. Automatic blinks preserve angry brows. Other portrait styles are unchanged.

2.6.33 gives Road King matching left/right eye geometry and mirrored pixel masks. Winking is represented by a coordinated two-eye blink; anger/confidence mapping is retained. Other avatar assets are unchanged.

Paired eyes and tears (2.6.34)

All four styles use mirrored left/right eye masks. Winks are coordinated two-eye blinks; crying and laughter render two matching tears at the same height, following the eye offset. Sweat drops are also paired. This symmetry is baked offline and adds no runtime mirroring. Source SVG left halves are the authoring reference; the asset generator also normalizes eye highlights and tear masks. Road King retains its angry/confident default mapping. Each of the four styles retains 21 emotions and three distinct poses per emotion.