static void VoicePrintIdentify()
{
	int i;
	int temp_num = 0;
	double temp = 0;
	double percent = my_voiceprint.voice_mdl.percent / 100.0;
	HWND hwndPrint = NULL;
	TCHAR * res; // 识别结果字符串

	hwndPrint = GetDlgItem(my_voiceprint.hwnd, IDC_TEXTOUT);
	EditPrintf(hwndPrint, TEXT("声纹识别结果:\r\n"));
	for (i = 0; i < IDENTIFY_NUM; ++i)
	{
		temp = (1 + percent) * my_voiceprint.voice_mdl.value[i][0];
		EditPrintf(hwndPrint, TEXT("第%d个%d帧:  最大识别值: %lf\r\n识别值: %lf\r\n"), 
			i+1, my_voiceprint.rec_frame[i], temp, my_voiceprint.voice_mdl.value[i][1]);
		temp >= my_voiceprint.voice_mdl.value[i][1] ? ++temp_num : temp_num;
	}
	res = temp_num>(IDENTIFY_NUM-2)?TEXT("身份验证成功!"):TEXT("身份验证失败!");
	EditPrintf(hwndPrint, TEXT("识别次数: %d, %s\r\n\r\n"), temp_num, res);
}
示例#2
0
void ProcessParsedString (HANDLE hPipe, CStdString *pstr, int nArg)
{
	static CStdString wavName("");
	static char streamFile[MAX_PATH];
	static InterfaceType itype(UNSPECIFIED);
	static CACEplayerDlg *hMainWndDlg;
	static ACESEQ seq; 

	CStdString outStr;
	double dummy;
	char buf[MAX_PATH];
	DWORD dw;
	int i, res;

	if (itype==UNSPECIFIED)
	{
		hMainWndDlg = (CACEplayerDlg *) (LONG_PTR)GetWindowLong (hMainDlg, GWL_USERDATA);
		itype = (InterfaceType)hMainWndDlg->hACEobj[0].param->dwReserved;
		if (itype==SPRINT)	LoadString (hInst, IDS_STREAM_FNAME, buf, sizeof(buf));
		else if (itype==L34_CIC3 || itype==L34_CIC4)	LoadString (hInst, IDS_STREAM_FNAME2, buf, sizeof(buf));
		else MessageBox(hMainDlg, "Check itype", "", MB_OK);
		FulfillFile(streamFile, hMainWndDlg->AppPath, buf);
	}

	if (pstr[0]=="IDENTIFY") 
	{
		outStr = "SUCCESS ACE_PLAYER";
	}
	else if (pstr[0]=="PREPARE")
	{
		//As of Oct-28-2010, level input from the controller is no longer used in the presenter.
		for (wavName="", i=2; i<nArg; i++) wavName += pstr[i]; // check file names containing blank character

		res=hMainWndDlg->Prepare(&seq, wavName.c_str(), dummy, outStr);
	}
	else if (pstr[0]=="PRESENT") 
	{
		res = hMainWndDlg->Present(&seq, outStr);
	}
	else if (pstr[0]=="SET") 
	{
		if (!(res = hMainWndDlg->Set(pstr, nArg, outStr))) { MessageBox (hMainDlg, outStr, "", MB_OK); return ; }
	}
	else
	{
		MessageBox (hMainDlg, "Unknown command", "", MB_OK);
	}
	WriteFile (hPipe, outStr.c_str(), outStr.GetLength()+1, &dw, NULL);
	SendMessage (GetDlgItem(hMainDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM)outStr.c_str());
	EditPrintf (GetDlgItem(hPipeLog, IDC_MSG), "(outgoing) %s\r\n", outStr.c_str());
}
示例#3
0
void pipeThread (PVOID nsr)
{
	CStdString parsedMsg[MAX_WORDS_PIPEMSG];
	char *pipeNameStr = (char *)nsr;
	DWORD dw, ecode;
	HANDLE hPipe;
	int res, nArg;
	char PipeName[256], buffer[MAX_PATH], errstr[MAX_PATH], inBuf[MAX_PATH*4], inBuf2[MAX_PATH*4];
	HWND hDlg = hMainDlg;

	wsprintf(PipeName, "\\\\.\\pipe\\%s", pipeNameStr);

	if ((hPipe=InitPipe(hDlg, PipeName, errstr))==NULL)
	{ MessageBox (hDlg, errstr, "pipeThread", MB_OK);		_endthread();		return;	}

	_beginthread (pipeThread, 0, (void*)ACEPLAYER_CONSOLE_PIPENAME);

	while (1)
	{
		if (!ConnectNamedPipe (hPipe, NULL))
		{
			if (GetLastError() != ERROR_PIPE_CONNECTED)
			{	GetLastErrorStr(errstr);
				MessageBox (hDlg, "ERROR in ConnectNamedPipe()", errstr, MB_OK);
				_endthread();				return;			}
		}
		res = ReadFile (hPipe, inBuf, sizeof(inBuf), &dw, NULL);	inBuf[dw]='\0';
		if (!res)
		{
			 
			if ((ecode=GetLastError())==234)  /*More data is available.*/
			{
				ReadFile (hPipe, inBuf2, sizeof(inBuf), &dw, NULL);
				strcat(inBuf, inBuf2);
			}
			else
			{
				sprintf(buffer, "Erorr code=%d", ecode);
				MessageBox (hDlg, "ReadFile fails for pipe communication", buffer, MB_OK);
				break;
			}
		}
		nArg = str2array (parsedMsg, MAX_WORDS_PIPEMSG, inBuf, " ");
		SendMessage (GetDlgItem(hMainDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM)inBuf);
		EditPrintf (GetDlgItem(hPipeLog, IDC_MSG), "(incoming) %s\r\n", inBuf);
		ProcessParsedString (hPipe, parsedMsg, nArg);
		DisconnectNamedPipe(hPipe); // For Stateless named pipe connection, turn this line on.
		FlushFileBuffers(hPipe);
	}
}