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.
109 lines
3.9 KiB
109 lines
3.9 KiB
|
|
#pragma once
|
|
|
|
#define LX_DLL_CLASS_EXPORTS 1
|
|
#include "RecognitionCppDll.h"
|
|
#include "WWSerialPortApi.h"
|
|
#include <iostream>
|
|
|
|
|
|
using namespace System;
|
|
using namespace System::Runtime::InteropServices;
|
|
using namespace System::Collections::Generic;
|
|
using namespace System::Collections;
|
|
using namespace std;
|
|
using namespace System::Threading;
|
|
|
|
using namespace mobvoi::sds;
|
|
|
|
#pragma comment(lib, "RecognitionCppDll.lib")
|
|
#pragma managed
|
|
|
|
|
|
namespace RecognitionCLRDll {
|
|
|
|
public ref class RecognizerCLR
|
|
{
|
|
|
|
public:
|
|
|
|
RecognizerCLR();
|
|
~RecognizerCLR();
|
|
|
|
|
|
//1. 设置识别参数的接口,startRecognition前调用
|
|
//目前只支持一个参数enablePartial,是否返回识别的中间结果?
|
|
//enablePartial为true时返回,即会有MOBVOI_SDS_CB_PARTIAL_TRANSCRIPT类型的回调。
|
|
//为false时,只返回最终识别结果,即只有MOBVOI_SDS_CB_FINAL_TRANSCRIPT类型的回调。
|
|
void setRecognitionParams(bool enablePartial);
|
|
|
|
//2. 启动识别的接口
|
|
//callback参数是回调接口。
|
|
//code是0代表成功,其他值是失败
|
|
//type为MOBVOI_SDS_CB_FINAL_TRANSCRIPT是语音识别结果,MOBVOI_SDS_CB_RESULT是语义理解和搜索的结果
|
|
//type和info的值
|
|
//SDK_INIT_ERROR info是初始化失败的信息
|
|
//MOBVOI_SDS_CB_ERROR info是识别出错的信息
|
|
//MOBVOI_SDS_CB_FINAL_TRANSCRIPT info是最终识别结果
|
|
//MOBVOI_SDS_CB_PARTIAL_TRANSCRIPT info是中间识别结果
|
|
//MOBVOI_SDS_CB_RESULT info是json数据
|
|
|
|
//出错时,info中会有错误码,含义如下:
|
|
//MOBVOI_SDS_SUCCESS 成功
|
|
//MOBVOI_SDS_ERR_INVALID_PARAM 参数有误,可能是必选参数不存在,或者存在不支持的可选参数
|
|
//MOBVOI_SDS_ERR_UNKNOWN_INTENT 不支持的 intent
|
|
//MOBVOI_SDS_ERR_INTERNAL_ERROR SDS 内部错误
|
|
//MOBVOI_SDS_ERR_BAD_STATE 非预期的SDS状态,比如用户未初始化便使用某个service
|
|
//MOBVOI_SDS_ERR_NETWORK_ERROR 网络错误
|
|
//MOBVOI_SDS_ERR_SERVER_ERROR 服务器内部错误
|
|
//MOBVOI_SDS_ERR_NO_SPEECH 没有检测到语音,可能用户没有说话
|
|
//MOBVOI_SDS_ERR_GARBAGE 无法识别当前语音内容
|
|
//MOBVOI_SDS_ERR_BAD_HOTWORD 无效的热词
|
|
//MOBVOI_SDS_ERR_BUF_FULL SDS 内部某缓冲区已满
|
|
//MOBVOI_SDS_ERR_LICENSE_DENIED SDS 服务被拒绝。对应的 Service 未授权,或者 license 已过期,或已超过当日允许的最大使用次数
|
|
//
|
|
delegate void ResultDelegate(int code, System::String ^ type, System::String ^ info);
|
|
bool startRecognition(ResultDelegate ^ callback);
|
|
//bool startRecognition();
|
|
|
|
//3. 识别效果增强接口
|
|
//设置说话人与麦克风的角度(麦克风和摄像头放的比较近,可用人与摄像头的角度来近似替代),以激活dsp算法,进行降噪处理。
|
|
//可以不调用,默认增强0度方向
|
|
static void setBeamDir(System::String^ serialPortname, int dir);
|
|
|
|
|
|
//4. 语音合成接口
|
|
//在语义理解和搜索完成之后调用
|
|
//ttsContent是要合成语音的文本内容,设置为""时播报默认内容
|
|
|
|
//language
|
|
//"Mandarin"; 中文
|
|
//"English"; 英文
|
|
//"Cantonese"; 粤语
|
|
|
|
//speaker
|
|
//cissy 中文女声(成熟)
|
|
//billy 中文男声
|
|
//lucy 中文童声
|
|
//tina 台湾女声
|
|
//dora 粤语女声
|
|
//angela 英文女声
|
|
|
|
//speed: "1.0"、 "1.2" 、"1.4"等字符串, "1.0"是正常语速,数字越大速度越快
|
|
bool playTts(System::String^ ttsContent, System::String^ language, System::String^ speaker, System::String^ speed);
|
|
//不设置参数时,默认合成MOBVOI_SDS_CB_RESULT返回的json中的displayText的文本,使用默认参数
|
|
bool playTts();
|
|
|
|
//9 测试接口
|
|
int AddCli(int a, int b);
|
|
delegate void MessageDelegate(int number);
|
|
void testDelegate(int number, MessageDelegate^ messageDelegate);
|
|
|
|
private:
|
|
bool mEnablePartial;
|
|
//OnlineRecognizerDemo * m_pRecognizer;
|
|
//OnlineRecognizerDemo::RecognizerCallBack * m_pCallback;
|
|
|
|
};
|
|
|
|
}
|