-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(voice): animate the mascot's mouth during realtime voice calls #5546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
YellowSnnowmann
merged 6 commits into
tinyhumansai:main
from
YellowSnnowmann:feat/5545-realtime-voice-lipsync
Aug 14, 2026
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49984c9
feat(voice): animate the mascot's mouth during realtime voice calls
YellowSnnowmann 02b4d67
fix(voice): reset the lip-sync level on an invalid analyser reading
YellowSnnowmann eb0496e
fix(voice): gate the lip-sync frame loop on the agent's speaking edge
YellowSnnowmann 6974b9f
fix(voice): guard audioRef.current and cover the publication path
YellowSnnowmann ca25bca
test(voice): cover the active→idle audioRef cleanup while mounted
YellowSnnowmann a970d51
test(voice): cover the isSpeaking edge while the session stays active
YellowSnnowmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { amplitudeToVisemeCode, smoothAmplitude } from './amplitudeLipsync'; | ||
|
|
||
| describe('amplitudeToVisemeCode', () => { | ||
| it('rests the mouth on silence and room tone', () => { | ||
| expect(amplitudeToVisemeCode(0)).toBe('sil'); | ||
| // Below the floor: the tail of a word, not speech. Holding the mouth open | ||
| // through these gaps is what makes naive amplitude lip-sync look slack. | ||
| expect(amplitudeToVisemeCode(0.03)).toBe('sil'); | ||
| }); | ||
|
|
||
| it('opens the mouth further as the signal gets louder', () => { | ||
| const codes = [0.08, 0.2, 0.6].map(amplitudeToVisemeCode); | ||
| expect(codes).toEqual(['I', 'E', 'aa']); | ||
| }); | ||
|
|
||
| // A garbage reading (analyser torn down mid-frame) must not map to a wide-open | ||
| // mouth that then sticks for the rest of the call. Infinity rests for the same | ||
| // reason NaN does: it is a broken sample, not a loud one. | ||
| it('rests on a non-finite reading', () => { | ||
| expect(amplitudeToVisemeCode(Number.NaN)).toBe('sil'); | ||
| expect(amplitudeToVisemeCode(Number.POSITIVE_INFINITY)).toBe('sil'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('smoothAmplitude', () => { | ||
| it('moves toward the new sample', () => { | ||
| expect(smoothAmplitude(0, 1)).toBeGreaterThan(0); | ||
| expect(smoothAmplitude(1, 0)).toBeLessThan(1); | ||
| }); | ||
|
|
||
| // Asymmetric on purpose: consonant onsets must land on time, but the mouth | ||
| // must not snap shut inside a word. | ||
| it('opens faster than it closes', () => { | ||
| const opening = smoothAmplitude(0, 1) - 0; | ||
| const closing = 1 - smoothAmplitude(1, 0); | ||
| expect(opening).toBeGreaterThan(closing); | ||
| }); | ||
|
|
||
| it('converges on a held level rather than oscillating', () => { | ||
| let level = 0; | ||
| for (let i = 0; i < 40; i += 1) level = smoothAmplitude(level, 0.5); | ||
| expect(level).toBeCloseTo(0.5, 2); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.