Fix web voice mode; share VAD/segmenting
This commit is contained in:
@@ -129,11 +129,11 @@ export function VoiceProvider({ children }: VoiceProviderProps) {
|
||||
|
||||
// Update voice detection flags whenever they change
|
||||
useEffect(() => {
|
||||
const session = realtimeSessionRef.current;
|
||||
if (session?.client) {
|
||||
// Note: voice detection updates need backend support before sending.
|
||||
}
|
||||
}, [realtimeAudio.isDetecting, realtimeAudio.isSpeaking]);
|
||||
activeSession?.methods?.setVoiceDetectionFlags(
|
||||
realtimeAudio.isDetecting,
|
||||
realtimeAudio.isSpeaking
|
||||
);
|
||||
}, [activeSession?.methods, realtimeAudio.isDetecting, realtimeAudio.isSpeaking]);
|
||||
|
||||
useEffect(() => {
|
||||
realtimeSessionRef.current = activeSession;
|
||||
@@ -163,6 +163,7 @@ export function VoiceProvider({ children }: VoiceProviderProps) {
|
||||
try {
|
||||
realtimeSessionRef.current = session;
|
||||
setActiveServerId(serverId);
|
||||
await session.audioPlayer?.warmup?.();
|
||||
await realtimeAudio.start();
|
||||
setIsVoiceMode(true);
|
||||
console.log("[Voice] Mode enabled");
|
||||
@@ -195,6 +196,7 @@ export function VoiceProvider({ children }: VoiceProviderProps) {
|
||||
const session = realtimeSessionRef.current;
|
||||
session?.audioPlayer?.stop();
|
||||
await realtimeAudio.stop();
|
||||
session?.methods?.setVoiceDetectionFlags(false, false);
|
||||
setIsVoiceMode(false);
|
||||
setActiveServerId(null);
|
||||
console.log("[Voice] Mode disabled");
|
||||
|
||||
Reference in New Issue
Block a user