Skip to content

Integrate with your build

This describes how to add the TrulyNatural SDK to your own application's build system. We support CMake (recommended), Make, Java, Gradle on Android, and Xcode iOS.

The paths below assume the default online documentation install location, $HOME/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9. If you installed the SDK elsewhere, replace that prefix with your SDK installation directory. Offline SDK documentation uses the actual installed path.

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:

list(APPEND CMAKE_MODULE_PATH "$ENV{HOME}/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9")
include(SnsrLibrary)

and to each of your executable targets:

target_link_libraries(your-target SnsrLibrary)

If you do not want to include any OSS components (and therefore no STT support) use SnsrLibraryOmitOSS instead:

target_link_libraries(your-target SnsrLibraryOmitOSS)

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

SNSR_ROOT ?= $(HOME)/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9
CFLAGS  += -I$(SNSR_ROOT)/include
LDFLAGS += -L$(SNSR_ROOT)/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

SNSR_ROOT ?= $(HOME)/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9
CFLAGS  += -I$(SNSR_ROOT)/include
LDFLAGS += -L$(SNSR_ROOT)/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.

SNSR_ROOT ?= $(HOME)/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9
CFLAGS  += -I$(SNSR_ROOT)/include
LDFLAGS += -L$(SNSR_ROOT)/lib/x86_64-windows-msvc
LDLIBS  += snsr.lib winmm.lib user32.lib

Java

The Java binding uses JNI to load the native library. Use the Sensory JAR from the SDK Maven repository at $HOME/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9/m2repository plus a native library search path (java.library.path) pointing at \(HOME/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9/lib/<platform>_ (for example _\)HOME/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9/lib/macos on macOS).

Maven coordinates (desktop JAR, not the Android @aar):

implementation "com.sensory.speech.snsr:tnl:7.8.0-pre.0"

On Linux, set <platform> to the output of gcc -dumpmachine. On macOS use macos. On Windows use the MSVC library directory under $HOME/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9/lib (for example x86_64-windows-msvc).

For Gradle, derive the SDK root from the Maven repository directory (its parent is the SDK install directory) and pass the native library directory to the run task (see Your first program).

Java examples.

Android

  • If using live audio recording, add the RECORD_AUDIO permission to the application's AndroidManifest.xml file:

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    
  • Add to settings.gradle:

    def snsrRepository = providers.gradleProperty("SNSR_REPOSITORY").get()
    def snsrRepositoryFile = file(snsrRepository)
    if (!snsrRepositoryFile.isAbsolute()) {
        snsrRepositoryFile = file("${System.getProperty('user.home')}/${snsrRepository}")
    }
    
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url = snsrRepositoryFile.toURI() }
            mavenLocal()
        }
    }
    
  • 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:

    # Sensory TrulyNatural configuration
    # Relative to the user's home directory; use an absolute path for custom installs.
    SNSR_REPOSITORY=Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9/m2repository
    SNSR_LIB_TYPE=tnl
    SNSR_LIB_VERSION=7.8.0-pre.0
    

Android examples.

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 NSMicrophoneUsageDescription string.
    • In "Build Settings",
      • Add ${SNSR_ROOT}/include to the "Header Search Paths".
      • Add ${SNSR_ROOT}/lib/ios to the "Library Search Paths".
      • Add -lsnsr to "Other Linker Flags".
    • In "General" > "Frameworks, Libraries, and Embedded Content",
      • Add Accelerate.framework
      • Add AudioToolbox.framework
  • 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, $(HOME)/Sensory/TrulyNaturalSDK/7.8.0-pre.0+682.g276c2541e9

iOS examples.