Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
AdamMiltonBarker's avatar
AdamMiltonBarker
Honored Guest
8 years ago

SAPI TTS playing on windows but not in oculus

Hi guys, 

I have set up an actor which on begin says a sentence just to test how this will work, I have added SAPI using VS but when I preview the app in VR, I hear the sentence come out of the laptop and not through the headphones in VR, other games etc are as expected sound only from the headset and not from the PC, any suggestions on this please, I am guessing that there must be some code to send the output to the device and not the laptop but cannot find any decent documentation anywhere about SAPI and Rift. Thanks in advance for any help, this is for an open source project.

// Fill out your copyright notice in the Description page of Project Settings.

#include "TOA.h"
#include "sapi.h"
#include <sphelper.h>

ATOA::ATOA()
{
PrimaryActorTick.bCanEverTick = true;
TOAMesh = CreateDefaultSubobject<UStaticMeshComponent>("TOAMesh");
PitchValue = 0.f;
YawValue = 0.f;
RollValue = 0.f;
}

void ATOA::BeginPlay()
{

Super::BeginPlay(); 
ISpVoice * pVoice = NULL;

HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if (SUCCEEDED(hr))
{
ISpObjectToken* cpToken(NULL);
SpFindBestToken(SPCAT_VOICES, L"gender=female", L"", &cpToken);
pVoice->SetVoice(cpToken);
cpToken->Release();
hr = pVoice->Speak(L"Hello, welcome to the Intel AI VR Retail Store", 0, NULL);
}

pVoice->Release();
pVoice = NULL;
}

2 Replies

  • I solved the blocking issue very easily in the end :D 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);
    }