////////////////////////////////////////////////////////////////////////// // // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // /////////////////////////////////////////////////////////////////////////// // // Public API wakeword component for PryonLite // /////////////////////////////////////////////////////////////////////////// #ifndef PRYON_LITE_WW_H #define PRYON_LITE_WW_H #include #include "pryon_lite_error.h" #include "pryon_lite_metadata.h" #ifdef __cplusplus extern "C" { #endif #if defined(PRYONLITE_EXPORTS) #define DLLDECL __declspec(dllexport) #elif defined(PRYONLITE_IMPORTS) #define DLLDECL __declspec(dllimport) #else #define DLLDECL #endif /// @brief Pryon lite API version #define PRYON_LITE_API_VERSION "2.16" /// /// @brief Handle to a wakeword instance /// typedef void* PryonLiteWakewordHandle; /// /// @brief Detection Result /// typedef struct PryonLiteWakewordResult { long long beginSampleIndex; ///< Identifies the sample index in the client's source of audio at which the /// speech for the enumResult begins. long long endSampleIndex; ///< Identifies the sample index in the client's source of audio at which the /// wakeword ends. The number of samples in the audio for the /// wakeword is given by endSampleIndex - beginSampleIndex. const char* keyword; ///< The keyword that was detected int confidence; ///< The confidence of the detection, from 0 (lowest) to 1000 (highest) PryonLiteMetadataBlob metadataBlob; ///< Auxiliary information void* reserved; ///< reserved for future use void* userData; ///< userData passed in via PryonLiteWakewordConfig during wakeword initialization } PryonLiteWakewordResult; /// /// @brief Configuration parameters to be passed in during initialization /// typedef struct PryonLiteWakewordConfig { int detectThreshold; ///< integer from 1-1000. Default is 500. ///< 1 = lowest threshold, most detections. ///< 1000 = highest threshold, fewest detections. int lowLatency; ///< Only valid for type 'U' models. Results in ~200ms lower detection ///< latency, at the cost of less accurate ww end indexes reported in ///< the detection callback const void* model; ///< Wakeword model data (loaded from disk or statically compiled in) ///< *** Note this memory must persist while the library is in use *** ///< *** Note this model must be 4 byte aligned *** size_t sizeofModel; ///< The total size of model binary (in bytes). struct PryonLiteDnnAccelConfig* dnnAccel; ///< Pointer to configuration structure for external DNN acceleration void* reserved; ///< reserved, set to NULL const char* apiVersion; ///< For header / library version consistency verification. /// Must pass in PRYON_LITE_API_VERSION as defined in this file. void* userData; ///< User-specified data pointer, to be returned when invoking detection callback } PryonLiteWakewordConfig; /// /// @brief Default Configuration to be used to initialize PryonLiteWakewordConfig struct /// #define PryonLiteWakewordConfig_Default \ { \ 500, /* detectThreshold */ \ 0, /* lowLatency */ \ NULL, /* model */ \ 0, /* sizeofModel */ \ NULL, /* dnnAccel */ \ NULL, /* reserved */ \ PRYON_LITE_API_VERSION, /* apiVersion */ \ NULL, /* userData */ \ } /// @brief Maximum keyword name length in PryonLiteWakewordConfigAttributes #define PRL_WW_KEYWORD_NAME_MAX_LEN (32) /// /// @brief Wakeword specific attributes /// typedef struct PryonLiteWakewordConfigAttributes { const char *wwApiVersion; ///< PryonLite wakeword API version const char *wwConfigVersion; ///< PryonLite wakeword config version int numKeywords; ///< Number of keywords supported const char (*keywords)[PRL_WW_KEYWORD_NAME_MAX_LEN]; ///< List of keywords supported } PryonLiteWakewordConfigAttributes; #define PRYON_LITE_WAKEWORD_DETECT_THRESHOLD_MIN (1) ///< Most permissive detection threshold #define PRYON_LITE_WAKEWORD_DETECT_THRESHOLD_MAX (1000) ///< Least permissive detection threshold /// /// @brief Sets the detection threshold parameter /// /// @param handle [in] Handle to wakeword instance /// @param keyword [in] Keyword for which to set the detection threshold; ex. "ALEXA". Pass a NULL pointer to set for all keywords. /// @param detectThreshold [in] Integer in range [1, 1000] with 1 being most permissive, and 1000 being least permissive. /// /// @return a PryonLiteStatus structure, nominally { PRYON_LITE_ERROR_OK, 0 } /// /// @note The keyword string must be in upper case. /// DLLDECL PryonLiteStatus PryonLiteWakeword_SetDetectionThreshold(PryonLiteWakewordHandle handle, const char* keyword, int detectThreshold); /// /// @brief Enable or disable one or all keywords /// /// @param handle [in] Handle to wakeword instance /// @param keyword [in] Keyword to enable or disable; ex. "ALEXA". Pass a NULL pointer to enable or disable all keywords. /// @param enable [in] Integer 0: disable keyword, 1 enable keyword. /// /// @return a PryonLiteStatus structure, nominally { PRYON_LITE_ERROR_OK, 0 } /// /// @note The keyword string must be in upper case. /// @note All supported keywords are enabled during initialization. /// DLLDECL PryonLiteStatus PryonLiteWakeword_EnableKeyword(PryonLiteWakewordHandle handle, const char* keyword, int enable); #ifdef __cplusplus } // extern "C" #endif #endif //PRYON_LITE_WW_H