Microphone Not Working When Running Unity Vision Pro App Normally

}

// Start listening to the microphone public void StartListening() { if (!isListening) { #if UNITY_IOS || UNITY_TVOS microphoneInput = Microphone.Start(null, true, 10, 44100); #else try { microphoneInput = Microphone.Start(null, true, 10, 16000); // Use 16,000 Hz instead of 44,100

        if (microphoneInput == null)
        {
            microphoneInput = Microphone.Start(null, true, 10, AudioSettings.outputSampleRate);
        }

#endif isListening = true; Debug.Log(Microphone.devices.Length + " Started listening..."); debugText.text = Microphone.devices.Length + "- Started listening...";
} catch (System.Exception e) { Debug.LogError($"Starting microphone failed: {e.Message}"); debugText.text = $"Starting microphone failed: {e.Message}"; } }
}

void Update() { if (isListening && microphoneInput != null) { // Analyze the audio for voice activity float volume = GetAverageVolume();

    if (volume > detectionThreshold)
    {
        Debug.Log("User is speaking!");
        lastVoiceTime = Time.time;
        SoundDetected = true;               

        if (Time.time - lastVoiceTime > silenceDuration)
        {
            Debug.Log("User is silent.");
            debugText.text = volume.ToString() + " - User is silent.";
        }

        slider.value = volume;
    }
}

}

private float GetAverageVolume() { float[] samples = new float[128]; microphoneInput.GetData(samples, Microphone.GetPosition(null));

float sum = 0f;
foreach (float sample in samples)
{
    sum += Mathf.Abs(sample);
}
return sum / samples.Length;

} Problem: When I build and run the app from Xcode, the microphone works fine, and I receive input. However, when running the app normally (outside of Xcode), I can’t seem to access the microphone. The debug logs indicate no microphone is detected. Question: Is there any additional configuration I need to do for the microphone to work in a normal (non-Xcode) run on Vision Pro? Or any common issues that could be causing the microphone access to fail in this scenario? Thanks in advance for any insights! Best, Siddharth

Answered by DTS Engineer in 823723022

It appears as though you're using the Unity game engine.

To get help for Unity on visionOS you'll need to work with the Unity support community.

We're unable to provide direct support for 3rd-party game engines on the Apple Developer Forums.

Accepted Answer

It appears as though you're using the Unity game engine.

To get help for Unity on visionOS you'll need to work with the Unity support community.

We're unable to provide direct support for 3rd-party game engines on the Apple Developer Forums.

understand that Apple Developer Forums don't provide direct support for third-party engines like Unity. I'll check the Unity support community for assistance. Thanks!

Microphone Not Working When Running Unity Vision Pro App Normally
 
 
Q