# Voice Chat: CreateVoiceCapture() returning Null

**URL:** <https://forums.unrealengine.com/t/voice-chat-createvoicecapture-returning-null/302960>\
**Category:** C++\
**Tags:** voice-chat, unreal-engine, UE4, question, CPP\
**Created:** [January 4, 2015, 1:18am UTC](https://forums.unrealengine.com/t/voice-chat-createvoicecapture-returning-null/302960 "2015-01-04T01:18:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![haydenjameslee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@haydenjameslee](https://forums.unrealengine.com/u/haydenjameslee)\
**Post date:** [January 4, 2015, 1:18am UTC](https://forums.unrealengine.com/t/voice-chat-createvoicecapture-returning-null/302960/1 "2015-01-04T01:18:31Z")

</div>

I’m trying to implement voice chat on Windows and the following code (copied from TestVoice.cpp) results in VoiceCapture, VoiceEncoder and VoiceDecoder being Null, making the IsValid call return false:

```
#include "OnlineSubsystemUtils.h"
#include "VoiceController.h"
#include "Engine.h"
#include "Voice.h"

...

bool AVoiceController::Init()
{
	UE_LOG(LogTemp, Warning, TEXT("VoiceController Init"));

	VoiceCapture = FVoiceModule::Get().CreateVoiceCapture();
	VoiceEncoder = FVoiceModule::Get().CreateVoiceEncoder();
	VoiceDecoder = FVoiceModule::Get().CreateVoiceDecoder();

	if (VoiceCapture.IsValid())
	{
		UE_LOG(LogTemp, Warning, TEXT("VoiceController Init is valid"));
		VoiceCapture->Start();
	}

	return true;
}

...

```

Does anybody have any ideas why this may be happening?

Edit: I’m calling Init on event begin play.

---

<div class="post-metadata">

**Author:** ![haydenjameslee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@haydenjameslee](https://forums.unrealengine.com/u/haydenjameslee)\
**Post date:** [January 4, 2015, 5:29am UTC](https://forums.unrealengine.com/t/voice-chat-createvoicecapture-returning-null/302960/2 "2015-01-04T05:29:07Z")

</div>

Solved the issue. I had forgotten to add the following config lines as specified in [this post](https://answers.unrealengine.com/questions/49442/trying-to-make-in-game-voice-communication.html).

DefaultEngine.ini

```
[Voice] 
bEnabled=true
 
[OnlineSubsystem] 
bHasVoiceEnabled=true

```

DefaultGame.ini

```
[/Script/Engine.GameSession]
bRequiresPushToTalk=false

```

---

<div class="post-metadata">

**Author:** ![pengchaoJay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pengchaojay/32/702797_2.png) [@pengchaoJay](https://forums.unrealengine.com/u/pengchaoJay)\
**Post date:** [September 23, 2024, 9:51am UTC](https://forums.unrealengine.com/t/voice-chat-createvoicecapture-returning-null/302960/3 "2024-09-23T09:51:16Z")

</div>

you are right
