接口文件

/*++

(do not edit the above line)

********************************************************************************

**

**  “INTEL CONFIDENTIAL

**  Copyright 2013 - 2018 Intel Corporation All Rights Reserved.

**

********************************************************************************

**

**  The source code contained or described herein and all documents related to

**  the source code ("Material") are owned by Intel Corporation or its suppliers

**  or licensors. Title to the Material remains with Intel Corporation or its

**  suppliers and licensors. The Material may contain trade secrets and

**  proprietary and confidential information of Intel Corporation and its

**  suppliers and licensors, and is protected by worldwide copyright and trade

**  secret laws and treaty provisions. No part of the Material may be used,

**  copied, reproduced, modified, published, uploaded, posted, transmitted,

**  distributed, or disclosed in any way without Intel’s prior express written

**  permission.

**

**  No license under any patent, copyright, trade secret or other intellectual

**  property right is granted to or conferred upon you by disclosure or delivery

**  of the Materials, either expressly, by implication, inducement, estoppel or

**  otherwise. Any license under such intellectual property rights must be

**  express and approved by Intel in writing.

**

**  THE MATERIAL IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF

**  ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT,

**  OR FITNESS FOR A PARTICULAR PURPOSE. INTEL WILL NOT PROVIDE ANY SUPPORT,

**  ASSISTANCE, INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE

**  ANY UPDATES, ENHANCEMENTS OR EXTENSIONS.  Intel does not warrant or assume

**  responsibility for the accuracy or completeness of any information, text,

**  graphics, links or other items contained within the material.

**

**  LIMITATION OF LIABILITY.  IN NO EVENT SHALL INTEL OR ITS SUPPLIERS BE LIABLE

**  FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, LOST PROFITS,

**  BUSINESS INTERRUPTION, OR LOST INFORMATION) ARISING OUT OF THE USE OF OR

**  INABILITY TO USE THE MATERIAL, EVEN IF INTEL HAS BEEN ADVISED OF THE

**  POSSIBILITY OF SUCH DAMAGES.

**

**  *Third-party brands and names are the property of their respective owners.

**

**  Unless otherwise agreed by Intel in writing, you may not remove or alter

**  this notice or any other notice embedded in Materials by Intel

**  or Intel’s suppliers or licensors in any way.?**

********************************************************************************

--*/

#ifndef _ROCKHOPPER_H_

#define _ROCKHOPPER_H_

#ifdef ROCKHOPPER_LIBRARY_STATIC

#   define ROCKHOPPER_API_EXPORT

#else

#   ifdef _WIN32

#       if defined(ROCKHOPPER_EXPORT) /* Visual Studio */

#           define ROCKHOPPER_API_EXPORT __declspec(dllexport)

#       elif defined(__CYGWIN__) /* Disable this on Cygwin, it doesn't work */

#           define ROCKHOPPER_API_EXPORT

#       else

#           define ROCKHOPPER_API_EXPORT __declspec(dllimport)

#       endif

#   else

#       if defined(ROCKHOPPER_EXPORT)

#           define ROCKHOPPER_API_EXPORT __attribute__((visibility("default")))

#       else

#           define ROCKHOPPER_API_EXPORT

#       endif

#   endif

#endif

#ifdef __cplusplus

extern "C" {

#endif

// left for compatibility

#define ROCKHOPPER_SUCCESS                  RH_NO_ERROR

#define ROCKHOPPER_ERROR                    RH_ERROR_GENERIC

#define ROCKHOPPER_UNKNOWN_ERROR            RH_ERROR_GENERIC

#define ROCKHOPPER_INVALID_PARAMETER        RH_ERROR_INVALID_PARAM

#define ROCKHOPPER_INVALID_HANDLE_VALUE     RH_ERROR_INVALID_HANDLE_VALUE

#define ROCKHOPPER_INVALID_PATH             RH_ERROR_INVALID_PATH

// base error codes

#define RH_NO_ERROR                          0

#define RH_ERROR_GENERIC                    -1

#define RH_ERROR_OUT_OF_MEMORY              -2

#define RH_ERROR_FILE_IO                    -3

#define RH_ERROR_INVALID_RESOURCE           -4

#define RH_ERROR_INVALID_PARAM              -5

#define RH_ERROR_INVALID_HANDLE_VALUE       -6

#define RH_ERROR_INVALID_PATH               -7

// Threading error codes

#define RH_ERROR_THREAD_ALREADY_STARTED     -10

#define RH_ERROR_THREAD_START_FAILED        -11

#define RH_ERROR_THREAD_STOP_FAILED         -12

#define RH_ERROR_THREAD_NOT_STARTED         -13

// Communication error codes

#define RH_ERROR_OUTPUT_BUFFER_FULL         -20

#define RH_ERROR_MESSAGE_ENQUEUE_FAILED     -21

// Rest error codes

#define RH_ERROR_MODULE_INIT_FAILED         -30

#define RH_ERROR_MODULE_NOT_INITIALIZED     -31

#define RH_ERROR_ENGINE_NOT_STARTED         -32

#define RH_ERROR_ENGINE_WRONG_STATE         -33

#define RH_ERROR_MEMORY_COPY                -34

#define RH_ERROR_TOO_SMALL_BUFFER           -35

#define RH_ERROR_DATA_OVERWRITTEN           -36

#define RH_ERROR_NOT_SUPPORTED              -37

// Events

#define ROCKHOPPER_EVENT_ON_READY_FOR_SPEECH 1

#define ROCKHOPPER_EVENT_ON_SPEECH_BEGIN     2

#define ROCKHOPPER_EVENT_ON_SPEECH_END       3

#define ROCKHOPPER_EVENT_ON_RMS_CHANGED      4

#define ROCKHOPPER_EVENT_ON_ERROR            5

#define ROCKHOPPER_EVENT_ENGINE_STARTED      6

#define ROCKHOPPER_EVENT_ENGINE_STOPPED      7

typedef void* ASR_HANDLE; // speech recognition engine handle type

typedef void* WFST_HANDLE; // Handle for a (dynamic) WFST resource

typedef enum RockhopperDataType

{

ROCKHOPPER_DATA_TYPE_SAMPLE_INT_16,

ROCKHOPPER_DATA_TYPE_FEATURE_INT_16

} RockhopperDataType;

/// C-style interface used intentionally to allow for bindings in

/// runtimes that don't support/understand C++ name mangling or

/// reference types

typedef long(*UtteranceCallback)(

void* p,                    // callback function parameter passed in RockhopperFSSetResultCallback

const short* samples,       // Data buffer with utterance samples. Samples are sent only for final result.

// Utterance longer than source buffer length will be passed without samples(null pointer).

int   nSamples,             // number of samples in buffer

const char* utteranceId,    // wall clock time when utterance begins

const char* utteranceText,  // recognized text

float score,                // recognition score (LM)

int   isFinal               // 0: partial result, 1: final result (end of utterance)

);

typedef void(*EventCallback)(

void* p,                    // callback function parameter passed in RockhopperFSSetEventCallback

int eventCode,              // event code

int value);                 // event value

#pragma pack(push, 4)

typedef struct _AsrEngineStatistics {

union {

struct {

unsigned int speech : 1;

unsigned int frontend : 3;

unsigned int scorer : 3;

unsigned int decoder : 3;

unsigned int reserved : 22;

} fields;

int value;

} state;

int signalvl;

int samples_captured_ms;

int frames_extracted_ms;

int frames_decoded_ms;

float uttRtFactor;

int utt_min_snr;

int utt_max_snr;

int utt_snr;

} AsrEngineStatistics;

#pragma pack(pop)

/**

* Initialize the ASR engine component.

*

* @param configurationFilename - absolute path to configuration file the ASR engine shall

*                                read all its configuration parameters from

* @param resourceDirectory - absolute path to resources listed in config file if relative path used

* @param userResourceDirectory - absolute path to user resources (e.g. dynamic lexicon)

*                                listed in config file if relative path used

* @param [outptr] asrengine - handle to ASR engine

* @return One of:

*         - ROCKHOPPER_SUCCESS (initialization completed successfully),

*         - ROCKHOPPER_INVALID_PATH (cannot access the indicated configurationFilename),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSInitialize(const char* configurationFilename, const char* resourceDirectory,

const char* userResourceDirectory, ASR_HANDLE* asrengine);

/**

* Update dynamic resource from a lexicon and a text acceptor WFST.

*

* @param configurationFilename - absolute path to configuration file the ASR engine shall

*                                read all its configuration parameters from

* @param resourceDirectory - absolute path of resource data folder (e.g. acoustic model)

* @param userResourceDirectory - absolute path to target folder to contain user generated data

*                                (e.g. dynamic lexicon)

* @param tagId - ID of meta tag in CL statistical language model the dictionary is "plugged in"

* @param wfst - Grammar wfst used for vocabulary.

*

* @return One of:

*         - ROCKHOPPER_SUCCESS (dynamic lexicon update completed successfully),

*         - ROCKHOPPER_INVALID_PATH (cannot access the indicated configurationFilename),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSUpdateDynResource(const char* configurationFilename,

const char* resourceDirectory, const char* userResourceDirectory, int tagId,

WFST_HANDLE wfst);

/**

* Set callback for result processing.

*

* @param [in] asrengine    - handle to ASR engine

* @param [in] rescallback  - result callback implementation to be invoked once

*                            utternace or its fragment is recognized

* @param [in] p            - callback parameter

* @return One of:

*         - ROCKHOPPER_SUCCESS (callback set successfully),

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSSetResultCallback(ASR_HANDLE asrengine,

UtteranceCallback callback, const void* p);

/**

* Set callback for events like start / stop engine, ready for speech, speech begin/end, error.

*

* @param [in] asrengine handle to ASR engine

* @param [in] evtcallback - event callback called whenever engine state is changing

* @param [in] p - callback parameter

* @return One of:

*         - ROCKHOPPER_SUCCESS (callback set successfully),

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSSetEventCallback(ASR_HANDLE asrengine,

EventCallback callback, const void* p);

/**

* Start phrase detection process.

* In response to this method the engine is expected to initialize the

* recognition and continue until a call to stop function is received.

*

* @param [in] asrengine - handle to ASR engine

* @return One of:

*         - ROCKHOPPER_SUCCESS (started successfully),

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSStartEngine(ASR_HANDLE asrengine);

/**

* Stop Rockhopper engine - resources are not released.

*

* @param [in] asrengine - handle to ASR engine

* @param [in] waitForEndOfUtteranceProcessing - flag:

*                                               True - requests deffered stop, routine does not return till last

*                                                      samples/frames in all intermediate buffers are processed

*                                               False - stops immediately if not doing batch file processing

* @return One of:

*         - ROCKHOPPER_SUCCESS (stopped successfully),

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle) ,

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

#ifdef __cplusplus

ROCKHOPPER_API_EXPORT int RockhopperFSStopEngine(ASR_HANDLE asrengine, int waitForEndOfUtteranceProcessing = 1);

#else

ROCKHOPPER_API_EXPORT int RockhopperFSStopEngine(ASR_HANDLE asrengine, int waitForEndOfUtteranceProcessing);

#endif

/**

* Release resources of Rockhopper engine.

*

* @param [in] asrengine - handle to ASR engine

* @return One of:

*         - ROCKHOPPER_SUCCESS (released successfully),

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSReleaseEngine(ASR_HANDLE asrengine);

/**

* Read current Rockhopper state & statistics.

*

* @param [in] asrengine - handle to ASR engine

* @param [inout] stats - pointer to statistics buffer

* @return One of:

*         - ROCKHOPPER_SUCCESS (stopped successfully),

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSGetStatistics(ASR_HANDLE asrengine, AsrEngineStatistics* stats);

/**

* Feed stream source with samples from external application.

*

* @param [in] asrengine - handle to ASR engine

* @param [in] samples - samples buffer 16kHz mono 16bit resolution

* @param [in] nSamples - number of samples

* @return number of samples consumed by ASR engine ( >=0 ) or STATUS code ( <0 ):

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSPushSamples(ASR_HANDLE asrengine, short* samples, int nSamples);

/**

* Feed stream source with data from external application.

*

* @param [in] asrengine - handle to ASR engine

* @param [in] data - pointer to buffer with data to push

* @param [in] elementsCount - number of elements of data, in case of:

*                               SAMPLE_INT_16 it is the number of samples

*                               FEATURE_INT_16 it is the number of features

*                               (must be aligned to features per frame set in config file)

* @param [in] type - type of data to push

* @return number of samples consumed by ASR engine ( >=0 ) or STATUS code ( <0 ):

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSPushData(ASR_HANDLE asrengine, void* data,

int elementsCount, RockhopperDataType type);

/**

* Convert grammar specified in JSGF to a WFST

* The WFST is a transducer with input and output labels

*

* @param [in] configurationFilename - absoulute path to configuration file

*        the asr engine shall read all it's configuration parameters from

* @param [in] grammar - string buffer representing grammar in JSGF, null terminated

*                       (http://www.w3.org/TR/2000/NOTE-jsgf-20000605/)

* @param [in] grammarRule - root rule name (if not specified first public rule is selected)

* @param [in] grammarSize - Size of the grammar string buffer including terminating null

* @param [in] grammarRuleSize = Size of the grammarRule buffer including terminating null

* @param [in] firstWordID - Word ID of the first word in the generated WFST.

*                           It is important that word IDs of different resources do not overlap.

* @param [out] wfst - handle to resulting grammar WFST

*

* @return One of:

*         - ROCKHOPPER_SUCCESS (grammar converted successfully),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSConvertJSGFToFST(const char *configurationFilename,

const char* grammar,

const char* grammarRule,

int grammarSize,

int grammarRuleSize,

int firstWordID,

WFST_HANDLE* wfst);

/**

* Convert ARPA statistical language model into WFST that can be used with

* RockhopperFSUpdateDynResource() to create dynamic recognition resources

*

* @param [in] configurationFilename - absoulute path to configuration file

*        the asr engine shall read all it's configuration parameters from

* @param [in] arpa - string buffer representing grammar in ARPA format

* @param [in] arpaSize - Size of the arpa string buffer

* @param [in] firstWordID - Word ID of the first word in the generated WFST.

*                           It is important that word IDs of different resources do not overlap.

* @param [out] wfst - handle to resulting grammar WFST

*

* @return One of:

*         - ROCKHOPPER_SUCCESS (grammar converted successfully),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSConvertARPAToFST(const char *configurationFilename,

const char* arpa,

int arpaSize,

int firstWordID,

WFST_HANDLE* wfst);

/**

* Convert list of phrases into a Rockhopper WFST that can be used with

* RockhopperFSUpdateDynResource() to create dynamic recognition resources

*

* @param [in] configurationFilename - absoulute path to configuration file

*        the asr engine shall read all it's configuration parameters from

* @param [in] phrases - string buffer representing grammar in JSGF

*                       The different phrases are separated by the newline character '\n'

* @param [in] phrasesSize - Size of the phrases string buffer

* @param [in] firstWordID - Word ID of the first word in the generated WFST.

*                           It is important that word IDs of different resources do not overlap.

* @param [out] wfst - handle to resulting phrase grammar WFST

*

* @return One of:

*         - ROCKHOPPER_SUCCESS (grammar converted successfully),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSConvertPhrasesToFST(const char* configurationFilename,

const char* phrases,

int phrasesSize,

int firstWordID,

WFST_HANDLE* wfst);

/**

* Convert AT&T (OpenFST) ASCII text representation of a WFST into

* a Rockhopper WFST.

*

* @param [in] configurationFilename - absoulute path to configuration file

*        the asr engine shall read all it's configuration parameters from

* @param [in] wfst_text - ASCII representation of the WFST

* @param [in] text_size - Length of wfst_text in bytes

* @param [in] firstWordID - Word ID of the first word in the generated WFST.

*                           It is important that word IDs of different resources do not overlap.

* @param [out] wfst - Handle to the Rockhopper WFST

*

* @return One of:

*         - ROCKHOPPER_SUCCESS (grammar converted successfully),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSConvertFST(const char *configurationFilename,

const char *wfst_text,

int text_size,

int firstWordID,

WFST_HANDLE* wfst);

/**

* Release (dynamic) WFST resource.

*

* @param [in] wfst - handle to a WFST resource

* @return One of:

*         - ROCKHOPPER_SUCCESS (stopped successfully),

*         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperFSReleaseFST(WFST_HANDLE wfst);

/**

* Get the Rockhopper version string.

*

* @param [out] versionString - pointer to char string with the version ID

* @return One of:

*         - ROCKHOPPER_SUCCESS (stopped successfully),

*         - ROCKHOPPER_UNKNOWN_ERROR (error)

*/

ROCKHOPPER_API_EXPORT int RockhopperGetVersionString(const char **versionString);

#ifdef __cplusplus

}

#endif

#endif

C++ cli  头文件

#pragmaonce

#include"pch.h"

#include"../SDK/rockhopper.h"

//using namespace System;

#pragmacomment (lib, "../SDK/rockhopper.lib")

namespace IntelSDK {

publicenumclassSDKRockhopperDataType

{

ROCKHOPPER_DATA_TYPE_SAMPLE_INT_16,

ROCKHOPPER_DATA_TYPE_FEATURE_INT_16

};

//[Serializable]

publicrefstructSDKAsrEngineStatistics

{

public:

void setValue(intval)

{

value = val;

}

int getValue()

{

return value;

}

void setSignalvl(intval)

{

signalvl = val;

}

int getSigalvl()

{

return signalvl;

}

void setSamples_captured_ms(intval)

{

samples_captured_ms = val;

}

int gettSamples_captured_ms()

{

return samples_captured_ms;

}

void setFrames_extracted_ms(intval)

{

frames_extracted_ms = val;

}

int getFrames_extracted_ms()

{

return frames_extracted_ms;

}

void setFrames_decoded_ms(intval)

{

frames_decoded_ms = val;

}

int getFrames_decoded_ms()

{

return frames_decoded_ms;

}

void setUttRtFactor(floatval)

{

uttRtFactor = val;

}

float getUttRtFactor()

{

return uttRtFactor;

}

void setUtt_min_snr(intval)

{

utt_min_snr = val;

}

int getUtt_min_snr()

{

return utt_min_snr;

}

void setUtt_max_snr(intval)

{

utt_max_snr = val;

}

int getUtt_max_snr()

{

return utt_max_snr;

}

void setUtt_snr(intval)

{

utt_snr = val;

}

int getUtt_snr()

{

return utt_snr;

}

private:

int value;

int signalvl;

int samples_captured_ms;

int frames_extracted_ms;

int frames_decoded_ms;

float uttRtFactor;

int utt_min_snr;

int utt_max_snr;

int utt_snr;

};

publicdelegatevoiddelegateEventCallback(int eventCode, int value);

publicdelegateintdelegateUtteranceCallback(System::String^ UtteranceText);

publicdelegatelong  Delegate_SDKUtteranceCallback(void* p, constshort* samples, int nSamples, constchar* UtteranceId, constchar* UtteranceText, float score, int isFinal);

publicdelegatevoid  Delegate_SDKFSSetEventCallback(void* p, int eventCode, int value);

publicrefclassOffLineSDK

{

private:

ASR_HANDLE asrengine = 0;

WFST_HANDLE wfst = 0;

public:

System::String^ getTest(System::String^ name);

OffLineSDK();

~OffLineSDK();

int SDKRockhopperFSStartEngine();

int SDKRockhopperFSStopEngine();

int SDKRockhopperFSInitialize(System::String^ configurationFilename, System::String^ resourceDirectory, System::String^ userResourceDirectory);

int SDKRockhopperFSUpdateDynResource(System::String^ configurationFilename, System::String^ resourceDirectory, System::String^ userResourceDirectory, inttagId);

int SDKRockhopperFSSetResultCallback();

int  SDKRockhopperFSReleaseEngine();

int  SDKRockhopperFSGetStatistics(SDKAsrEngineStatistics^ stats);

int  SDKRockhopperFSPushSamples(array< int>^ samples, intnSamples);

int  SDKRockhopperFSConvertJSGFToFST(System::String^ configurationFilename, System::String^ grammar, System::String^ grammarRule, intgrammarSize, intgrammarRuleSize, intfirstWordID);

int  SDKRockhopperFSConvertARPAToFST(System::String^ configurationFilename, array<short>^ arpa, intarpaSize, intfirstWordID);

int  SDKRockhopperFSPushData(array<short>^ wfst_text, intelementCount, SDKRockhopperDataTypetype);

int  SDKRockhopperFSReleaseFST();

int     SDKRockhopperFSSetEventCallback();

private:

staticlong  SDKUtteranceCallback(void* p, constshort* samples, intnSamples, constchar* UtteranceId, constchar* UtteranceText, floatscore, intisFinal);

staticvoid  SDKFSSetEventCallback(void* p, inteventCode, intvalue);

public:

staticeventdelegateEventCallback^ FSSetEventCallback;

staticeventdelegateUtteranceCallback^ EventUtteranceCallback;

};

}

C++ cli 源文件

#include"pch.h"

#include"IntelSDK.h"

#include<string>

#include<iostream>

#include<fstream>

#include<cvt/wstring>

#include<codecvt>

usingnamespace IntelSDK;

#include<msclr\marshal_cppstd.h>

usingnamespace System::Runtime::InteropServices;

constchar* ToCppString(System::String^ s)

{

msclr::interop::marshal_context context;

constchar* result = context.marshal_as<constchar*>(s);

return result;

}

bool To_CharStar(System::String^ source, char*& target)

{

pin_ptr<constwchar_t> wch = PtrToStringChars(source);

int len = ((source->Length + 1) * 2);

target = newchar[len];

return wcstombs(target, wch, len) != -1;

}

bool To_string(System::String^ source, std::string& target)

{

pin_ptr<constwchar_t> wch = PtrToStringChars(source);

int len = ((source->Length + 1) * 2);

char* ch = newchar[len];

bool result = wcstombs(ch, wch, len) != -1;

target= ch;

delete ch;

return result;

}

std::string StringToAscIIChars(System::String^ text)

{

//System::IntPtr ptr=Marshal::SecureStringToGlobalAllocAnsi(text);

std::string converted = msclr::interop::marshal_as<std::string>(text->ToString());

//std::string converted = msclr::interop::marshal_as< std::string >(text);

return converted;

}

std::string StringUtf8ToAscIIChars(System::String^ text) {

std::string converted = msclr::interop::marshal_as< std::string >(text);

return converted;

}

System::String^ UTF8_To_Managed_Str(constchar* chars/*const std::string& str*/)

{

if (chars == nullptr/*|| chars == "" || chars == " " || strnlen_s(chars, INT_MAX) <= 1*/) { // todo what is  0x20

return"";

}

std::string str = std::string(chars);

int nwLen = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);

wchar_t* pwBuf = newwchar_t[nwLen + 1];

memset(pwBuf, 0, nwLen * 2 + 2);

MultiByteToWideChar(CP_UTF8, 0, str.c_str(), (int)str.length(), pwBuf, nwLen);

System::String^ pStr = gcnew System::String(pwBuf);

delete[] pwBuf;

pwBuf = NULL;

return pStr;

}

System::String^ OffLineSDK::getTest(System::String^ name)

{

//ASR_HANDLE handle = 0;

returnname;

}

OffLineSDK::OffLineSDK()

{

//throw gcnew System::NotImplementedException();

}

OffLineSDK::~OffLineSDK()

{

//throw gcnew System::NotImplementedException();

SDKRockhopperFSReleaseEngine();

SDKRockhopperFSReleaseFST();

}

intOffLineSDK::SDKRockhopperFSStartEngine()

{

/*GCHandle handle = GCHandle::Alloc(objEngine);

System::IntPtr pointer = GCHandle::ToIntPtr(handle);

void* ptr = pointer.ToPointer();*/

//auto ret = RockhopperFSStartEngine(this->ptr);

pin_ptr<ASR_HANDLE> pin = &asrengine;

auto ret = RockhopperFSStartEngine(*pin);

//handle.Free();

return ret;

}

intOffLineSDK::SDKRockhopperFSStopEngine()

{

auto ret = RockhopperFSStopEngine(asrengine);

return ret;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSInitialize(System::String^ configurationFilename, System::String^ resourceDirectory, System::String^ userResourceDirectory)

{

std::string fileName = configurationFilename ? StringToAscIIChars(configurationFilename) : "";

std::string directory = resourceDirectory ? StringToAscIIChars(resourceDirectory) : "";

std::string userDirectory = userResourceDirectory ? StringUtf8ToAscIIChars(userResourceDirectory) : "";

pin_ptr<ASR_HANDLE> pin = &asrengine;

std::cout <<"get some info."<< std::endl;

std::cout << fileName << std::endl;

std::cout << directory << std::endl;

std::cout << userDirectory << std::endl;

// Convert Object^ to void*

/*GCHandle handle = GCHandle::Alloc(objEngine);

System::IntPtr pointer = GCHandle::ToIntPtr(handle);

void* ptr = pointer.ToPointer();

this->ptr = ptr;

ASR_HANDLE asrengine2 = 0;*/

//auto ret = RockhopperFSInitialize("./OffLineConfigFile/rh_params.txt", "./OffLineConfigFile/", "E:\\Code", pin);

//std::string fileName1 = "./OffLineConfigFile/rh_params.txt";

//std::string directory1 = "./OffLineConfigFile/";

//std::string userDirectory1 = "E:\\code";

//

//auto ret = RockhopperFSInitialize(fileName1.c_str(), directory1.c_str(), userDirectory1.c_str(), pin);

auto ret = RockhopperFSInitialize(fileName.c_str(), directory.c_str(), userDirectory.c_str(), pin);

return ret;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSUpdateDynResource(System::String^ configurationFilename, System::String^ resourceDirectory, System::String^ userResourceDirectory, inttagId)

{

std::string fileName = configurationFilename ? StringToAscIIChars(configurationFilename) : "";

std::string rDirectory = resourceDirectory ? StringUtf8ToAscIIChars(resourceDirectory) : "";

std::string userDirectory = userResourceDirectory ? StringUtf8ToAscIIChars(userResourceDirectory) : "";

pin_ptr<WFST_HANDLE> pin = &wfst;

auto ret = RockhopperFSUpdateDynResource(fileName.c_str(), rDirectory.c_str(), userDirectory.c_str(), tagId, pin);

return ret;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSSetResultCallback()

{

Delegate_SDKUtteranceCallback^ fp = gcnewDelegate_SDKUtteranceCallback(SDKUtteranceCallback);

GCHandle gch = GCHandle::Alloc(fp);

System::IntPtr ip = Marshal::GetFunctionPointerForDelegate(fp);

UtteranceCallback cb = static_cast<UtteranceCallback>(ip.ToPointer());

pin_ptr<ASR_HANDLE> pin = &asrengine;

auto ret = RockhopperFSSetResultCallback(*pin, cb, NULL);

return ret;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSReleaseEngine()

{

int res = -1;

pin_ptr<ASR_HANDLE> pin = &asrengine;

if (pin)

{

res = RockhopperFSReleaseEngine(*pin);

}

return res;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSGetStatistics(SDKAsrEngineStatistics^ stats)

{

return 0;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSPushSamples(array<int>^ samples, intnSamples)

{

return 0;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSConvertJSGFToFST(System::String^ configurationFilename, System::String^ grammar, System::String^ grammarRule, intgrammarSize, intgrammarRuleSize, intfirstWordID)

{

return 0;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSConvertARPAToFST(System::String^ configurationFilename, array<short>^ arpa, intarpaSize, intfirstWordID)

{

return 0;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSPushData(array<short>^ wfst_text, intelementCount, SDKRockhopperDataTypetype)

{

if (wfst_text == nullptr)

{

return  -3;

}

constint MAX_BUF_SIZE = 20480;

short* sample;

short buff[MAX_BUF_SIZE] = { 0 };

/* if (elementCount > MAX_BUF_SIZE) {

sample = new char[elementCount];

}

else {

sample = buff;

}*/

sample = buff;

for (int i = 0; i < (int)elementCount; i++)

{

sample[i] = wfst_text[i];

}

//RockhopperDataType type= ROCKHOPPER_DATA_TYPE_SAMPLE_INT_16;

/*if (offlinetype == SDKRockhopperDataType::ROCKHOPPER_DATA_TYPE_SAMPLE_INT_16)

{

type = ROCKHOPPER_DATA_TYPE_SAMPLE_INT_16;

}

else

{

type = ROCKHOPPER_DATA_TYPE_FEATURE_INT_16;

}*/

auto ret = RockhopperFSPushData(asrengine, sample, elementCount, ROCKHOPPER_DATA_TYPE_SAMPLE_INT_16);

return ret;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSReleaseFST()

{

auto ret = -1;

if (wfst)

{

ret = RockhopperFSReleaseFST(wfst);

}

return ret;

}

int IntelSDK::OffLineSDK::SDKRockhopperFSSetEventCallback()

{

Delegate_SDKFSSetEventCallback^ fp = gcnewDelegate_SDKFSSetEventCallback(SDKFSSetEventCallback);

GCHandle gch = GCHandle::Alloc(fp);

System::IntPtr ip = Marshal::GetFunctionPointerForDelegate(fp);

EventCallback callBack = static_cast<EventCallback>(ip.ToPointer());

pin_ptr<ASR_HANDLE> pin = &asrengine;

auto res = RockhopperFSSetEventCallback(*pin, callBack, NULL);

return res;

}

long IntelSDK::OffLineSDK::SDKUtteranceCallback(void* p, constshort* samples, intnSamples, constchar* UtteranceId, constchar* UtteranceText, floatscore, intisFinal)

{

auto ret = EventUtteranceCallback(UTF8_To_Managed_Str(UtteranceText));

//return 0;

return ret;

}

void IntelSDK::OffLineSDK::SDKFSSetEventCallback(void* p, inteventCode, intvalue)

{

FSSetEventCallback(eventCode, value);

}

/*++(do not edit the above line)************************************************************************************  “INTEL CONFIDENTIAL**  Copyright 2013 - 2018 Intel Corporation All Rights Reserved.**************************************************************************************  The source code contained or described herein and all documents related to**  the source code ("Material") are owned by Intel Corporation or its suppliers**  or licensors. Title to the Material remains with Intel Corporation or its**  suppliers and licensors. The Material may contain trade secrets and**  proprietary and confidential information of Intel Corporation and its**  suppliers and licensors, and is protected by worldwide copyright and trade**  secret laws and treaty provisions. No part of the Material may be used,**  copied, reproduced, modified, published, uploaded, posted, transmitted,**  distributed, or disclosed in any way without Intel’s prior express written**  permission.****  No license under any patent, copyright, trade secret or other intellectual**  property right is granted to or conferred upon you by disclosure or delivery**  of the Materials, either expressly, by implication, inducement, estoppel or**  otherwise. Any license under such intellectual property rights must be**  express and approved by Intel in writing.****  THE MATERIAL IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF**  ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT,**  OR FITNESS FOR A PARTICULAR PURPOSE. INTEL WILL NOT PROVIDE ANY SUPPORT,**  ASSISTANCE, INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE**  ANY UPDATES, ENHANCEMENTS OR EXTENSIONS.  Intel does not warrant or assume**  responsibility for the accuracy or completeness of any information, text,**  graphics, links or other items contained within the material.****  LIMITATION OF LIABILITY.  IN NO EVENT SHALL INTEL OR ITS SUPPLIERS BE LIABLE**  FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, LOST PROFITS,**  BUSINESS INTERRUPTION, OR LOST INFORMATION) ARISING OUT OF THE USE OF OR**  INABILITY TO USE THE MATERIAL, EVEN IF INTEL HAS BEEN ADVISED OF THE**  POSSIBILITY OF SUCH DAMAGES.****  *Third-party brands and names are the property of their respective owners.****  Unless otherwise agreed by Intel in writing, you may not remove or alter**  this notice or any other notice embedded in Materials by Intel**  or Intel’s suppliers or licensors in any way.?**********************************************************************************--*/
#ifndef _ROCKHOPPER_H_#define _ROCKHOPPER_H_
#ifdef ROCKHOPPER_LIBRARY_STATIC#   define ROCKHOPPER_API_EXPORT#else#   ifdef _WIN32#       if defined(ROCKHOPPER_EXPORT) /* Visual Studio */#           define ROCKHOPPER_API_EXPORT __declspec(dllexport)#       elif defined(__CYGWIN__) /* Disable this on Cygwin, it doesn't work */#           define ROCKHOPPER_API_EXPORT#       else#           define ROCKHOPPER_API_EXPORT __declspec(dllimport)#       endif#   else#       if defined(ROCKHOPPER_EXPORT)#           define ROCKHOPPER_API_EXPORT __attribute__((visibility("default")))#       else#           define ROCKHOPPER_API_EXPORT#       endif#   endif#endif
#ifdef __cplusplusextern "C" {#endif
    // left for compatibility    #define ROCKHOPPER_SUCCESS                  RH_NO_ERROR    #define ROCKHOPPER_ERROR                    RH_ERROR_GENERIC    #define ROCKHOPPER_UNKNOWN_ERROR            RH_ERROR_GENERIC    #define ROCKHOPPER_INVALID_PARAMETER        RH_ERROR_INVALID_PARAM    #define ROCKHOPPER_INVALID_HANDLE_VALUE     RH_ERROR_INVALID_HANDLE_VALUE    #define ROCKHOPPER_INVALID_PATH             RH_ERROR_INVALID_PATH
    // base error codes    #define RH_NO_ERROR                          0    #define RH_ERROR_GENERIC                    -1    #define RH_ERROR_OUT_OF_MEMORY              -2    #define RH_ERROR_FILE_IO                    -3    #define RH_ERROR_INVALID_RESOURCE           -4    #define RH_ERROR_INVALID_PARAM              -5    #define RH_ERROR_INVALID_HANDLE_VALUE       -6    #define RH_ERROR_INVALID_PATH               -7
    // Threading error codes    #define RH_ERROR_THREAD_ALREADY_STARTED     -10    #define RH_ERROR_THREAD_START_FAILED        -11    #define RH_ERROR_THREAD_STOP_FAILED         -12    #define RH_ERROR_THREAD_NOT_STARTED         -13
    // Communication error codes    #define RH_ERROR_OUTPUT_BUFFER_FULL         -20    #define RH_ERROR_MESSAGE_ENQUEUE_FAILED     -21
    // Rest error codes    #define RH_ERROR_MODULE_INIT_FAILED         -30    #define RH_ERROR_MODULE_NOT_INITIALIZED     -31    #define RH_ERROR_ENGINE_NOT_STARTED         -32    #define RH_ERROR_ENGINE_WRONG_STATE         -33    #define RH_ERROR_MEMORY_COPY                -34    #define RH_ERROR_TOO_SMALL_BUFFER           -35    #define RH_ERROR_DATA_OVERWRITTEN           -36    #define RH_ERROR_NOT_SUPPORTED              -37
    // Events    #define ROCKHOPPER_EVENT_ON_READY_FOR_SPEECH 1    #define ROCKHOPPER_EVENT_ON_SPEECH_BEGIN     2    #define ROCKHOPPER_EVENT_ON_SPEECH_END       3    #define ROCKHOPPER_EVENT_ON_RMS_CHANGED      4    #define ROCKHOPPER_EVENT_ON_ERROR            5    #define ROCKHOPPER_EVENT_ENGINE_STARTED      6    #define ROCKHOPPER_EVENT_ENGINE_STOPPED      7
    typedef void* ASR_HANDLE; // speech recognition engine handle type    typedef void* WFST_HANDLE; // Handle for a (dynamic) WFST resource
    typedef enum RockhopperDataType    {        ROCKHOPPER_DATA_TYPE_SAMPLE_INT_16,        ROCKHOPPER_DATA_TYPE_FEATURE_INT_16    } RockhopperDataType;
    /// C-style interface used intentionally to allow for bindings in    /// runtimes that don't support/understand C++ name mangling or    /// reference types
    typedef long(*UtteranceCallback)(        void* p,                    // callback function parameter passed in RockhopperFSSetResultCallback        const short* samples,       // Data buffer with utterance samples. Samples are sent only for final result.                                    // Utterance longer than source buffer length will be passed without samples(null pointer).        int   nSamples,             // number of samples in buffer        const char* utteranceId,    // wall clock time when utterance begins        const char* utteranceText,  // recognized text        float score,                // recognition score (LM)        int   isFinal               // 0: partial result, 1: final result (end of utterance)        );
    typedef void(*EventCallback)(        void* p,                    // callback function parameter passed in RockhopperFSSetEventCallback        int eventCode,              // event code        int value);                 // event value
#pragma pack(push, 4)    typedef struct _AsrEngineStatistics {        union {            struct {                unsigned int speech : 1;                unsigned int frontend : 3;                unsigned int scorer : 3;                unsigned int decoder : 3;                unsigned int reserved : 22;            } fields;            int value;        } state;        int signalvl;        int samples_captured_ms;        int frames_extracted_ms;        int frames_decoded_ms;        float uttRtFactor;        int utt_min_snr;        int utt_max_snr;        int utt_snr;    } AsrEngineStatistics;
#pragma pack(pop)    /**     * Initialize the ASR engine component.     *     * @param configurationFilename - absolute path to configuration file the ASR engine shall     *                                read all its configuration parameters from     * @param resourceDirectory - absolute path to resources listed in config file if relative path used     * @param userResourceDirectory - absolute path to user resources (e.g. dynamic lexicon)     *                                listed in config file if relative path used     * @param [outptr] asrengine - handle to ASR engine     * @return One of:     *         - ROCKHOPPER_SUCCESS (initialization completed successfully),     *         - ROCKHOPPER_INVALID_PATH (cannot access the indicated configurationFilename),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSInitialize(const char* configurationFilename, const char* resourceDirectory,        const char* userResourceDirectory, ASR_HANDLE* asrengine);
    /**     * Update dynamic resource from a lexicon and a text acceptor WFST.     *     * @param configurationFilename - absolute path to configuration file the ASR engine shall     *                                read all its configuration parameters from     * @param resourceDirectory - absolute path of resource data folder (e.g. acoustic model)     * @param userResourceDirectory - absolute path to target folder to contain user generated data     *                                (e.g. dynamic lexicon)     * @param tagId - ID of meta tag in CL statistical language model the dictionary is "plugged in"     * @param wfst - Grammar wfst used for vocabulary.     *     * @return One of:     *         - ROCKHOPPER_SUCCESS (dynamic lexicon update completed successfully),     *         - ROCKHOPPER_INVALID_PATH (cannot access the indicated configurationFilename),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSUpdateDynResource(const char* configurationFilename,        const char* resourceDirectory, const char* userResourceDirectory, int tagId,        WFST_HANDLE wfst);
    /**     * Set callback for result processing.     *     * @param [in] asrengine    - handle to ASR engine     * @param [in] rescallback  - result callback implementation to be invoked once     *                            utternace or its fragment is recognized     * @param [in] p            - callback parameter     * @return One of:     *         - ROCKHOPPER_SUCCESS (callback set successfully),     *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSSetResultCallback(ASR_HANDLE asrengine,        UtteranceCallback callback, const void* p);
    /**     * Set callback for events like start / stop engine, ready for speech, speech begin/end, error.     *     * @param [in] asrengine handle to ASR engine     * @param [in] evtcallback - event callback called whenever engine state is changing     * @param [in] p - callback parameter     * @return One of:     *         - ROCKHOPPER_SUCCESS (callback set successfully),     *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSSetEventCallback(ASR_HANDLE asrengine,        EventCallback callback, const void* p);
    /**     * Start phrase detection process.     * In response to this method the engine is expected to initialize the     * recognition and continue until a call to stop function is received.     *     * @param [in] asrengine - handle to ASR engine     * @return One of:     *         - ROCKHOPPER_SUCCESS (started successfully),     *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSStartEngine(ASR_HANDLE asrengine);
    /**     * Stop Rockhopper engine - resources are not released.     *     * @param [in] asrengine - handle to ASR engine     * @param [in] waitForEndOfUtteranceProcessing - flag:     *                                               True - requests deffered stop, routine does not return till last     *                                                      samples/frames in all intermediate buffers are processed     *                                               False - stops immediately if not doing batch file processing     * @return One of:     *         - ROCKHOPPER_SUCCESS (stopped successfully),     *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle) ,     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */#ifdef __cplusplus    ROCKHOPPER_API_EXPORT int RockhopperFSStopEngine(ASR_HANDLE asrengine, int waitForEndOfUtteranceProcessing = 1);#else    ROCKHOPPER_API_EXPORT int RockhopperFSStopEngine(ASR_HANDLE asrengine, int waitForEndOfUtteranceProcessing);#endif
    /**     * Release resources of Rockhopper engine.     *     * @param [in] asrengine - handle to ASR engine     * @return One of:     *         - ROCKHOPPER_SUCCESS (released successfully),     *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSReleaseEngine(ASR_HANDLE asrengine);
    /**     * Read current Rockhopper state & statistics.     *     * @param [in] asrengine - handle to ASR engine     * @param [inout] stats - pointer to statistics buffer     * @return One of:     *         - ROCKHOPPER_SUCCESS (stopped successfully),     *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSGetStatistics(ASR_HANDLE asrengine, AsrEngineStatistics* stats);
    /**    * Feed stream source with samples from external application.    *    * @param [in] asrengine - handle to ASR engine    * @param [in] samples - samples buffer 16kHz mono 16bit resolution    * @param [in] nSamples - number of samples    * @return number of samples consumed by ASR engine ( >=0 ) or STATUS code ( <0 ):    *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),    *         - ROCKHOPPER_UNKNOWN_ERROR (error)    */    ROCKHOPPER_API_EXPORT int RockhopperFSPushSamples(ASR_HANDLE asrengine, short* samples, int nSamples);
    /**    * Feed stream source with data from external application.    *    * @param [in] asrengine - handle to ASR engine    * @param [in] data - pointer to buffer with data to push    * @param [in] elementsCount - number of elements of data, in case of:    *                               SAMPLE_INT_16 it is the number of samples    *                               FEATURE_INT_16 it is the number of features    *                               (must be aligned to features per frame set in config file)    * @param [in] type - type of data to push    * @return number of samples consumed by ASR engine ( >=0 ) or STATUS code ( <0 ):    *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),    *         - ROCKHOPPER_UNKNOWN_ERROR (error)    */    ROCKHOPPER_API_EXPORT int RockhopperFSPushData(ASR_HANDLE asrengine, void* data,        int elementsCount, RockhopperDataType type);
    /**     * Convert grammar specified in JSGF to a WFST     * The WFST is a transducer with input and output labels     *     * @param [in] configurationFilename - absoulute path to configuration file     *        the asr engine shall read all it's configuration parameters from     * @param [in] grammar - string buffer representing grammar in JSGF, null terminated     *                       (http://www.w3.org/TR/2000/NOTE-jsgf-20000605/)     * @param [in] grammarRule - root rule name (if not specified first public rule is selected)     * @param [in] grammarSize - Size of the grammar string buffer including terminating null     * @param [in] grammarRuleSize = Size of the grammarRule buffer including terminating null     * @param [in] firstWordID - Word ID of the first word in the generated WFST.     *                           It is important that word IDs of different resources do not overlap.     * @param [out] wfst - handle to resulting grammar WFST     *     * @return One of:     *         - ROCKHOPPER_SUCCESS (grammar converted successfully),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSConvertJSGFToFST(const char *configurationFilename,                                                           const char* grammar,                                                           const char* grammarRule,                                                           int grammarSize,                                                           int grammarRuleSize,                                                           int firstWordID,                                                           WFST_HANDLE* wfst);
    /**     * Convert ARPA statistical language model into WFST that can be used with     * RockhopperFSUpdateDynResource() to create dynamic recognition resources     *     * @param [in] configurationFilename - absoulute path to configuration file     *        the asr engine shall read all it's configuration parameters from     * @param [in] arpa - string buffer representing grammar in ARPA format     * @param [in] arpaSize - Size of the arpa string buffer     * @param [in] firstWordID - Word ID of the first word in the generated WFST.     *                           It is important that word IDs of different resources do not overlap.     * @param [out] wfst - handle to resulting grammar WFST     *     * @return One of:     *         - ROCKHOPPER_SUCCESS (grammar converted successfully),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSConvertARPAToFST(const char *configurationFilename,                                                           const char* arpa,                                                           int arpaSize,                                                           int firstWordID,                                                           WFST_HANDLE* wfst);
    /**     * Convert list of phrases into a Rockhopper WFST that can be used with     * RockhopperFSUpdateDynResource() to create dynamic recognition resources     *     * @param [in] configurationFilename - absoulute path to configuration file     *        the asr engine shall read all it's configuration parameters from     * @param [in] phrases - string buffer representing grammar in JSGF     *                       The different phrases are separated by the newline character '\n'     * @param [in] phrasesSize - Size of the phrases string buffer     * @param [in] firstWordID - Word ID of the first word in the generated WFST.     *                           It is important that word IDs of different resources do not overlap.     * @param [out] wfst - handle to resulting phrase grammar WFST     *     * @return One of:     *         - ROCKHOPPER_SUCCESS (grammar converted successfully),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSConvertPhrasesToFST(const char* configurationFilename,                                                              const char* phrases,                                                              int phrasesSize,                                                              int firstWordID,                                                              WFST_HANDLE* wfst);
    /**     * Convert AT&T (OpenFST) ASCII text representation of a WFST into     * a Rockhopper WFST.     *     * @param [in] configurationFilename - absoulute path to configuration file     *        the asr engine shall read all it's configuration parameters from     * @param [in] wfst_text - ASCII representation of the WFST     * @param [in] text_size - Length of wfst_text in bytes     * @param [in] firstWordID - Word ID of the first word in the generated WFST.     *                           It is important that word IDs of different resources do not overlap.     * @param [out] wfst - Handle to the Rockhopper WFST     *     * @return One of:     *         - ROCKHOPPER_SUCCESS (grammar converted successfully),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSConvertFST(const char *configurationFilename,                                                     const char *wfst_text,                                                     int text_size,                                                     int firstWordID,                                                     WFST_HANDLE* wfst);
    /**     * Release (dynamic) WFST resource.     *     * @param [in] wfst - handle to a WFST resource     * @return One of:     *         - ROCKHOPPER_SUCCESS (stopped successfully),     *         - ROCKHOPPER_INVALID_HANDLE_VALUE (invalid handle),     *         - ROCKHOPPER_UNKNOWN_ERROR (error)     */    ROCKHOPPER_API_EXPORT int RockhopperFSReleaseFST(WFST_HANDLE wfst);
    /**    * Get the Rockhopper version string.    *    * @param [out] versionString - pointer to char string with the version ID    * @return One of:    *         - ROCKHOPPER_SUCCESS (stopped successfully),    *         - ROCKHOPPER_UNKNOWN_ERROR (error)    */    ROCKHOPPER_API_EXPORT int RockhopperGetVersionString(const char **versionString);
#ifdef __cplusplus}#endif#endif

最新文章

  1. VS调试时下不到断点的处理方式。
  2. C++虚函数示例
  3. iOS第三方类库JSPatch(热更新)
  4. bind,call,apply区别
  5. Python之路day4
  6. 【翻译】我钟爱的Visual Studio前端开发工具/扩展
  7. ubuntu16.04安装flash player与谷歌浏览器(chrome)
  8. VB.NET版机房收费系统---组合查询
  9. python之jieba库
  10. leetcode每日刷题计划-简单篇day9
  11. 一个AI产品经理怎么看AI的发展
  12. 【转】Windows Server 2008 R2下安装 .net framework3.5
  13. 【python】python2.x中的除法
  14. Python文件操作---合并文本文件内容
  15. Spark官方文档翻译(一)~Overview
  16. 使用VAE、CNN encoder+孤立森林检测ssl加密异常流的初探——真是一个忧伤的故事!!!
  17. spyder在编辑过程中被自己弄乱了,想要恢复成安装时默认的格式或者重置页面格式的解决办法
  18. c#double类型保留百分号后两位,且禁止四舍五入的方法
  19. Android面试之HashMap的实现原理
  20. Lua中的控制结构

热门文章

  1. C语言:总结
  2. C语言:char总结
  3. python 最大公约数 最小公倍数
  4. 2018年一名合格的web前端程序员应该会哪些技术
  5. 大疆M3508、M2006必备CAN总线知识与配置方法
  6. 整理最近用的Mongo查询语句
  7. 深入GraphQL 的使用语法
  8. PAT乙级:1084 外观数列 (20分)
  9. 第一篇 -- 下载并安装IDEA
  10. LintCode 550 &#183; Top K Frequent Words II