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, 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:

list(APPEND CMAKE_MODULE_PATH "~/Sensory/TrulyNaturalSDK/7.6.1")
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

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_AUDIO permission to the application's AndroidManifest.xml file:

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

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url = "${SNSR_REPOSITORY}" }
            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
    SNSR_REPOSITORY=~/Sensory/TrulyNaturalSDK/7.6.1/m2repository
    SNSR_LIB_TYPE=tnl
    SNSR_LIB_VERSION=7.6.1
    

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, ~/Sensory/TrulyNaturalSDK/7.6.1

iOS examples.