Fix voice change bug

This commit is contained in:
Xin Wang
2026-02-09 14:25:59 +08:00
parent 97984014e8
commit c7044c4c77

View File

@@ -1336,6 +1336,9 @@ export const DebugDrawer: React.FC<{
// Start every text debug run as a fresh session transcript.
setMessages([]);
assistantDraftIndexRef.current = null;
// Force a fresh WS session so updated assistant runtime config
// (voice/model/provider/speed) is applied on session.start.
closeWs();
if (textTtsEnabled) await ensureAudioContext();
await ensureWsSession();
setTextSessionStarted(true);
@@ -1608,6 +1611,14 @@ export const DebugDrawer: React.FC<{
});
};
useEffect(() => {
if (!isOpen) return;
if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) return;
// If core TTS-related settings changed while drawer stays open,
// reset the active WS session so the next launch uses new metadata.
closeWs();
}, [isOpen, assistant.id, assistant.voice, assistant.speed]);
useEffect(() => {
if (!textTtsEnabled) {
stopPlaybackImmediately();