Integrate with your build¶
This describes how to add the TrulyNatural SDK to your own application's build system. We support CMake (recommended), Make, Gradle on Android and Xcode iOS.
If you're using a different build system, take a look at the compiler and linker flags you'll need listed for Make.
CMake¶
recommended
Add this to your CMakeLists.txt files:
and to each of your executable targets:
If you do not want to include any OSS components (and therefore no STT support) use SnsrLibraryOmitOSS instead:
CMakeLists.txt in the C examples section.
Make¶
Set the compiler and linker flags to allow your toolchain to find the <snsr.h> header and the platform-specific libsnsr.a.
Makefile in the C examples section.
Linux¶
CFLAGS += -I~/Sensory/TrulyNaturalSDK/7.6.1/include
LDFLAGS += -L~/Sensory/TrulyNaturalSDK/7.6.1/lib/<platform>
LDLIBS += -lsnsr -lasound -lpthread -lm -ldl -lstdc++
Where <platform> should be the output of gcc -dumpmachine
stt -lstdc++ is needed for the TrulyNatural STT SDK only.
macOS¶
CFLAGS += -I~/Sensory/TrulyNaturalSDK/7.6.1/include
LDFLAGS += -L~/Sensory/TrulyNaturalSDK/7.6.1/lib/macos
LDLIBS += -lsnsr -framework AudioToolbox -framework Accelerate \
-framework CoreFoundation -framework Foundation -lm -lstdc++
stt -lstdc++ is needed for the TrulyNatural STT SDK only.
Windows¶
Use Visual Studio 2022 or later.
CFLAGS += -I~/Sensory/TrulyNaturalSDK/7.6.1/include
LDFLAGS += -L~/Sensory/TrulyNaturalSDK/7.6.1/lib/x86_64-windows-msvc
LDLIBS += snsr.lib winmm.lib user32.lib
Android¶
-
If using live audio recording, add the
RECORD_AUDIOpermission to the application's AndroidManifest.xml file: -
Add to settings.gradle:
-
Add to app/build.gradle:
/// snsr model utilities apply from: '../gradle/model-utils.gradle' configurations { snsr_model } dependencies { // TrulyNatural code library implementation "com.sensory.speech.snsr:${SNSR_LIB_TYPE}:${SNSR_LIB_VERSION}@aar" // Any `snsr` task models needed by your app in Maven GAV format, for example snsr_model "com.sensory.speech.snsr.model:udt-universal:3.66.1.9@snsr" } -
Copy util/model-utils.gradle from the TrulyNatural installation directory to gradle/model-utils.gradle in your application.
-
Add configuration settings to gradle.properties:
iOS¶
- Add a Bridging header, ProjectName-Bridging-Header.h, that includes
#import <snsr.h> - Select the application target.
- In "Capabilities", add "Inter-App Audio Capability".
- In "Info" > "Custom iOS Target Properties", add an
NSMicrophoneUsageDescriptionstring. - In "Build Settings",
- Add
${SNSR_ROOT}/includeto the "Header Search Paths". - Add
${SNSR_ROOT}/lib/iosto the "Library Search Paths". - Add
-lsnsrto "Other Linker Flags".
- Add
- In "General" > "Frameworks, Libraries, and Embedded Content",
- Add
Accelerate.framework - Add
AudioToolbox.framework
- Add
- Select the project.
- Select the "Editor > Add Build Setting > Add User-Defined Setting" menu entry.
- Add
SNSR_ROOT. Set this variable to the TrulyNatural SDK installation directory, ~/Sensory/TrulyNaturalSDK/7.6.1