Skip to content

Commit ddc0b19

Browse files
authored
Merge pull request #20 from layercodedev/feature/disable-vad
add enableVAD as an option
2 parents bbfb6cc + 239f054 commit ddc0b19

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface UseLayercodeAgentOptions {
2121

2222
audioInput?: boolean;
2323
audioOutput?: boolean;
24+
enableVAD?: boolean;
2425
onAudioInputChanged?: (audioInput: boolean) => void;
2526
onAudioOutputChanged?: (audioOutput: boolean) => void;
2627
enableAmplitudeMonitoring?: boolean;
@@ -69,6 +70,7 @@ const useLayercodeAgent = (
6970
const websocketUrlOverride = options['_websocketUrl'];
7071
const enableAmplitudeMonitoring = options.enableAmplitudeMonitoring ?? true;
7172
const autoLoadInputDevices = options.autoLoadInputDevices ?? true;
73+
const enableVAD = options.enableVAD ?? true;
7274

7375
const [status, setStatus] = useState('initializing');
7476
const [userAudioAmplitude, setUserAudioAmplitude] = useState(0);
@@ -196,6 +198,7 @@ const useLayercodeAgent = (
196198
metadata,
197199
audioInput,
198200
audioOutput,
201+
enableVAD,
199202
audioInputChanged: (next: boolean) => {
200203
_setAudioInput(next);
201204
onAudioInputChanged?.(next);
@@ -294,6 +297,7 @@ const useLayercodeAgent = (
294297
onAudioOutputChanged,
295298
audioInput,
296299
audioOutput,
300+
enableVAD,
297301
enableAmplitudeMonitoring,
298302
]
299303
);
@@ -329,7 +333,7 @@ const useLayercodeAgent = (
329333
});
330334
}
331335
},
332-
[_setAudioInput, clientRef, audioInput, refreshInputDevices]
336+
[_setAudioInput, clientRef, audioInput, refreshInputDevices, enableVAD]
333337
);
334338

335339
const setAudioOutput = useCallback(
@@ -445,6 +449,7 @@ const useLayercodeAgent = (
445449
conversationId: internalConversationId,
446450
audioInput,
447451
audioOutput,
452+
enableVAD,
448453
availableInputDevices,
449454
activeInputDeviceId,
450455
preferredInputDeviceId,

0 commit comments

Comments
 (0)