Running SAPI on separate thread

Hi guys I am working on a POC for a VR retail store and AI assistant. It is my first time programming for Rift with UE4 and I am having difficulties working out how to run the actor that speaks through SAPI at the begging of the program in a separate thread. Basically what is happening is when the actor loads, SAPI says a few words but it basically freezes the thread, so there is a white screen whilst the speaking happens, and then it loads the rest of the program once the speaking stops. Code can be found below and also a video of it happening.

Would be really cool if someone can point me to docs / examples on how to resolve this or can offer any advice, thanks in advance guys.

https://github.com/iotJumpway/Oculus-Examples/blob/master/Rift/vrAIretail/Source/vrAIretail/TOA.h https://github.com/iotJumpway/Oculus-Examples/blob/master/Rift/vrAIretail/Source/vrAIretail/TOA.cpp

I solved the blocking issue very easily in the end :smiley: I wrapped the SAPI code in a function and used the following one liner (Where welcome is the custom SAPI function), now there is an issue where the speech is only coming out of the laptop and not the headset, will update this post once I solve that.

// Called when the game starts or when spawned
void ATOA::BeginPlay()
{
    Super::BeginPlay();
    TFuture<void> A = Async<void>(EAsyncExecution::Thread, welcome);
}

Generating a thread for each play is excessive. You can simply use the native SPF_ASYNC.

hr = pVoice->Speak(L"Hello, welcome to the VR AI Retail Store", SPF_ASYNC, NULL);