[PR #6] TTS lip sync: wait for playback to start; keep the expression while talking #6

Open
opened 2026-11-07 17:48:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/SillyTavern/Extension-VRM/pull/6
Author: @nelsonblaha
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: fix-tts-lip-sync


📝 Commits (2)

  • 94cde01 TTS lip sync: wait for playback to start before checking for its end
  • 6fd9139 TTS lip sync: keep the character's expression while talking, restore it after

📊 Changes

1 file changed (+29 additions, -3 deletions)

View changed files

📝 vrm.js (+29 -3)

📄 Description

SillyTavern's TTS extension calls vrmLipSync() before it sets the audio element's source and plays it (public/scripts/extensions/tts/index.js, the same in release and staging). So the first onAudioProcess() sees audio.paused, ends the job, and endTalk() throws on every reply:

InvalidStateError: Failed to execute 'stop' on 'AudioScheduledSourceNode': cannot call stop without calling start first.

The mouth still moved, but only because that exception skipped the disconnect() calls, so the script processor kept running until playback began. Each reply also left an AudioContext open.

Commit 1: wait for the audio element's play before treating "paused" as the end of the job, only stop() a source that was started, and close the job's AudioContext when it ends.

Commit 2: while talking, every expression was capped at 0.25 and never restored (the TODO: restaure expression weight ?), so a character who had just turned happy or sad stayed at a quarter of it after speaking. Emotion presets are now capped at 0.5 while talking and restored afterwards, unless a newer reply's lip sync has taken over.

Tested with SillyTavern 1.19.0, OpenAI Compatible TTS (Kokoro, not streaming), the local classifier, VRM1_Constraint_Twist_Sample.vrm, and headless Chrome sampling the expression values every 100 ms during playback:

  • Before: an InvalidStateError on every reply. The mouth moved anyway, and "happy" stayed at 0.25 after the reply.
  • After: no page errors over five replies, and the mouth was open in 21 of 37 samples while the audio played. "Happy" went from 1.0 to 0.5 while talking and back to 1.0 afterwards.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/SillyTavern/Extension-VRM/pull/6 **Author:** [@nelsonblaha](https://github.com/nelsonblaha) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-tts-lip-sync` --- ### 📝 Commits (2) - [`94cde01`](https://github.com/SillyTavern/Extension-VRM/commit/94cde018c7f3165b4068660fa31fd850ea81182f) TTS lip sync: wait for playback to start before checking for its end - [`6fd9139`](https://github.com/SillyTavern/Extension-VRM/commit/6fd9139e32d9864f2016684aa7e699c07c1b0029) TTS lip sync: keep the character's expression while talking, restore it after ### 📊 Changes **1 file changed** (+29 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `vrm.js` (+29 -3) </details> ### 📄 Description SillyTavern's TTS extension calls `vrmLipSync()` before it sets the audio element's source and plays it (`public/scripts/extensions/tts/index.js`, the same in `release` and `staging`). So the first `onAudioProcess()` sees `audio.paused`, ends the job, and `endTalk()` throws on every reply: ``` InvalidStateError: Failed to execute 'stop' on 'AudioScheduledSourceNode': cannot call stop without calling start first. ``` The mouth still moved, but only because that exception skipped the `disconnect()` calls, so the script processor kept running until playback began. Each reply also left an `AudioContext` open. **Commit 1:** wait for the audio element's `play` before treating "paused" as the end of the job, only `stop()` a source that was started, and close the job's `AudioContext` when it ends. **Commit 2:** while talking, every expression was capped at 0.25 and never restored (the `TODO: restaure expression weight ?`), so a character who had just turned happy or sad stayed at a quarter of it after speaking. Emotion presets are now capped at 0.5 while talking and restored afterwards, unless a newer reply's lip sync has taken over. **Tested** with SillyTavern 1.19.0, OpenAI Compatible TTS (Kokoro, not streaming), the local classifier, `VRM1_Constraint_Twist_Sample.vrm`, and headless Chrome sampling the expression values every 100 ms during playback: - **Before:** an `InvalidStateError` on every reply. The mouth moved anyway, and "happy" stayed at 0.25 after the reply. - **After:** no page errors over five replies, and the mouth was open in 21 of 37 samples while the audio played. "Happy" went from 1.0 to 0.5 while talking and back to 1.0 afterwards. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SillyTavern/Extension-VRM#6
No description provided.