SAPI in UE4 with VS2017

How to use Microsoft Speech API (SAPI) in Unreal Engine 4 (UE4), with Visual Studio 2017 Community Edition. Because I’m always forgetting it.

There are 4 things to do:

1. Add MFC/ATL support in Visual studio installer.

2. Include SAPI headers:

#include "AllowWindowsPlatformTypes.h"
#pragma warning(push)
#pragma warning(disable: 4191)
#pragma warning(disable: 4996)
#ifndef DeleteFile
#define DeleteFile DeleteFileW
#endif
#ifndef MoveFile
#define MoveFile MoveFileW
#endif
#ifndef LoadString
#define LoadString LoadStringW
#endif
#ifndef InterlockedDecrement
#define InterlockedDecrement _InterlockedDecrement
#endif
#ifndef InterlockedIncrement
#define InterlockedIncrement _InterlockedIncrement
#endif
#ifndef GetMessage
#define GetMessage GetMessageW
#endif

#include "sapi.h"
#include "sphelper.h"

#undef DeleteFile
#undef MoveFile
#undef LoadString
#undef InterlockedDecrement
#undef InterlockedIncrement
#undef GetMessage
#pragma warning(pop)
#include "HideWindowsPlatformTypes.h"

3. Additional include folders:

Projects Properties::VC++ Directories::Include directories add the folder where atlbase.h is located, like:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\include

4. Add atl libs to Build.cs (I copied the atls.lib file into my project folder):

PublicAdditionalLibraries.Add(@"D:/Users/Stan/Documents/UnrealProjects/MyProject/Plugins/SAPI_Plugin/Binaries/Win64/atls.lib");

If you know better way let me know.

2 thoughts on “SAPI in UE4 with VS2017

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s