You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

113 lines
2.5 KiB

//
#pragma once
//#define SDK_DLL_API __declspec(dllimport)
#include <pthread.h>
//#include "include/macros.h"
//#include "include/parameter.h"
//#include "include/param_decl.h"
//#include "include/service.h"
//#include "include/speech_sds.h"
//#include "include/wav_utils.h"
#include "sds/interface/speech_sds.h"
#include "sds/interface/parameter.h"
#include "sds/interface/param_decl.h"
#include "sds/interface/service.h"
//方便外面引用统一的头文件
#include "online_tts_api.h"
#ifndef LX_DLL_CLASS_EXPORTS
#define CPP_DLL_API __declspec(dllexport)
#else
#define CPP_DLL_API __declspec(dllimport)
#endif
//#define CPP_DLL_API __declspec(dllexport)
//extern "C" CPP_DLL_API int Add(int a, int b);
typedef void(*WriteMessageType)(int number);
typedef void(*ResultCallbackType)(int code, const char * type, const char * info );
namespace mobvoi {
namespace sds {
CPP_DLL_API void SetSdkLogOn(bool on);
CPP_DLL_API void SetSdkConfigPath(std::string path);
class CPP_DLL_API OnlineRecognizerHelper {
public:
OnlineRecognizerHelper();
~OnlineRecognizerHelper();
void setRecognitionParams(int startSilence, int endSilence, bool enablePartial, bool enableVolume);
void setContext(std::string perfectStr, std::string partialStr );
bool startRecognition();
bool startRecognition(void* Function);
bool stopRecognition(bool immediate);
bool InvokeStopService();
bool InvokeCancelService();
void callCSharp(int code, const char * type, const char * info);
//
int Add(int a, int b);
void WriteMessage(int number , void* Function);
class RecognizerCallBack;
private:
bool Run(int argc, char* argv[]);
const std::string& GetType() const;
void SetType(const std::string& type);
bool ParseCmdArgs(int argc, char* argv[]);
bool InitEnv();
bool GetService();
bool InvokeService();
bool ReleaseService();
bool ReleaseEnv();
bool InvokeSetParamService();
bool InvokeStartService();
bool InvokeFeedSpeech();
void ShowUsage(const std::string& exe);
void Notify();
private:
std::string base_dir_;
Service* service_;
std::vector<char> waves_;
std::string service_type_;
bool stop_;
int startSilence_;
int endSilence_;
bool enablePartial_;
bool enableVolume_;
pthread_mutex_t mutex_;
pthread_cond_t cond_;
SpeechSDS* sds_;
std::string mode_;
std::vector<std::string> partial_keywords_;
std::vector<std::string> perfect_keywords_;
RecognizerCallBack * pCallback;
ResultCallbackType cSharpCallback;
};
}
}