Is it possible to add face detection system?

is it possible to change that pressing T functionality into a Face detection system. I have a python script which will detects face and write a .json file with boolean Value

can i integrate that .json file into unreal engine? when face detected is true i want engine to access my microphone so i can give voice input
is it possible? how can i do that?

Hello @I_Hub_Animations,

Welcome to the Convai Developer Forum!

Yes, this is possible. In the sample setup, the T key triggers the talk state. You can replace that input event with your own event driven by the face-detected flag from your Python script.

  • When the value is true, call Start Talking. When it becomes false, call Stop Talking.

Is this correct node setup? I’m new to unreal engine. Can you help me?

Convai section, yes.

but when i press play its not detecting my voice input… i cant figure out what is the problem.

Please make sure you are calling Start Talking every frame while you want the microphone active. If it’s not being called continuously, the voice input will not be detected.

Since this type of customization falls outside our direct support scope, the exact implementation is up to you, but we recommend reviewing your update loop or event logic to ensure Start Talking is triggered as intended.

Hey @I_Hub_Animations, Try this solution, it might work.

What’s wrong

  1. Path + flag mismatch
    You’re passing an absolute path to Load Json from File while “Is Relative to Content Dir” is checked. That combo makes the load fail.

  2. Gate logic not enforced
    Pressed goes straight to Start Talking even if no face is detected. The Enable Push to Talk bool isn’t actually gating the input.

  3. Polling structure is brittle
    The timer is fine, but the JSON read → bool extract → set variable path should live in a single function/event with a clean validity check.

  4. Return value handling
    Make sure the Return Value from Load Json from File is valid before calling Get Bool Field, or you’ll read stale/defaults.

Minimal, robust fix

  1. File load

    • If you want an absolute path: uncheck “Is Relative to Content Dir”.

    • If you want a project-relative path: check the box and pass something like
      Data/json/face.json (and make sure the file is inside your Content folder or packaged appropriately).

  2. Create a polling event

    • Make a Custom Event (or Function) called PollFaceJSON.

    • Inside it:

      • Load Json from FileIs Valid (on the returned VaRestJsonObject).

      • If valid: Get Bool Field with field name face_detectedSet Enable Push to Talk.

      • If not valid: Set Enable Push to Talk = false (and optionally Print String “JSON load failed”).

    • On BeginPlay (or where you currently do it), set a looping timer: Set Timer by Function Name
      Object: self, Function Name: "PollFaceJSON", Time: 0.5–1.0, Looping: true.

  3. Gate the input

    • From T PressedBranch with Enable Push to Talk as the Condition.

      • True: Start Talking

      • False: optional Print String “Face not detected”.

    • From T ReleasedStop Talking.

    • Remove the direct wires from Pressed/Released to Start/Stop Talking that bypass the branch.

  4. Keep the variable single-source

    • Only the polling event should Set Enable Push to Talk.

    • The input path should only Read it.

  5. Debug quickly

    • After Get Bool Field, add Print String to show face_detected: true/false for a few cycles to confirm the read.

Optional hardening

  • If your JSON sometimes stores "face_detected": "true" (string), add a small parse step (get string and compare to "true"). Ideally, make it a real boolean in the file.

  • Consider switching to Set Timer by Event (bind to the PollFaceJSON event) to avoid typos in function names.

With those tweaks, “T” will only start voice when the JSON says a face is present, and the file will actually load.

Is it possible for you to share the Fae Detection code for the python script to test out?

Good Luck!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.