[RavenclawDev 297] [1882] Agents/MultiDecoder/Sphinx_Engine: Modified Sphinx_Engine to compile under MSVS 2005.

tk@edam.speech.cs.cmu.edu tk at edam.speech.cs.cmu.edu
Wed Aug 8 17:31:07 EDT 2007


An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/ravenclaw-developers/attachments/20070808/15d9f8ce/attachment-0001.html
-------------- next part --------------

Property changes on: Agents/MultiDecoder/Sphinx_Engine
___________________________________________________________________
Name: svn:ignore
   + Debug
Release


Modified: Agents/MultiDecoder/Sphinx_Engine/Sphinx_Engine.vcproj
===================================================================
--- Agents/MultiDecoder/Sphinx_Engine/Sphinx_Engine.vcproj	2007-08-08 21:30:25 UTC (rev 1881)
+++ Agents/MultiDecoder/Sphinx_Engine/Sphinx_Engine.vcproj	2007-08-08 21:31:07 UTC (rev 1882)
@@ -1,127 +1,188 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="7.10"
+	Version="8.00"
 	Name="Sphinx_Engine"
 	ProjectGUID="{6A7673C4-08F4-4490-93A5-5F7211B406CF}"
-	SccProjectName="SAK"
-	SccAuxPath="SAK"
-	SccLocalPath="SAK"
-	SccProvider="SAK"
-	Keyword="Win32Proj">
+	RootNamespace="Sphinx_Engine"
+	Keyword="Win32Proj"
+	>
 	<Platforms>
 		<Platform
-			Name="Win32"/>
+			Name="Win32"
+		/>
 	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
 			OutputDirectory="Debug"
 			IntermediateDirectory="Debug"
 			ConfigurationType="1"
-			CharacterSet="2">
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
 			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="..\..\..\Libraries\sphinx2\include;..\..\..\Libraries\sphinx2\src\libsphinx2\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_MBCS;USE_NEW_SPHINX"
-				MinimalRebuild="TRUE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_MBCS;USE_NEW_SPHINX;_CRT_SECURE_NO_DEPRECATE"
+				MinimalRebuild="true"
 				BasicRuntimeChecks="0"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
-				Detect64BitPortabilityProblems="TRUE"
-				DebugInformationFormat="4"/>
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
 			<Tool
-				Name="VCCustomBuildTool"/>
+				Name="VCManagedResourceCompilerTool"
+			/>
 			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="../../../Libraries/sphinx2/lib/Debug/libsphinx2.lib ../../../Libraries/sphinx2/lib/Debug/libsphinx2ad.lib ../../../Libraries/sphinx2/lib/Debug/libsphinx2fe.lib wsock32.lib winmm.lib"
 				OutputFile="$(OutDir)/Sphinx_Engine.exe"
 				LinkIncremental="2"
-				SuppressStartupBanner="TRUE"
-				IgnoreAllDefaultLibraries="FALSE"
+				SuppressStartupBanner="true"
+				IgnoreAllDefaultLibraries="false"
 				IgnoreDefaultLibraryNames=""
-				GenerateDebugInformation="TRUE"
+				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/Sphinx_Engine.pdb"
 				SubSystem="1"
 				HeapReserveSize="2000000"
-				TargetMachine="0"/>
+				TargetMachine="0"
+			/>
 			<Tool
-				Name="VCMIDLTool"/>
+				Name="VCALinkTool"
+			/>
 			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="copy $(TargetPath) ..\..\..\bin\x86-nt\$(TargetName)-DEBUG.exe"/>
+				Name="VCManifestTool"
+			/>
 			<Tool
-				Name="VCPreBuildEventTool"/>
+				Name="VCXDCMakeTool"
+			/>
 			<Tool
-				Name="VCPreLinkEventTool"/>
+				Name="VCBscMakeTool"
+			/>
 			<Tool
-				Name="VCResourceCompilerTool"/>
+				Name="VCFxCopTool"
+			/>
 			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
+				Name="VCAppVerifierTool"
+			/>
 			<Tool
-				Name="VCXMLDataGeneratorTool"/>
+				Name="VCWebDeploymentTool"
+			/>
 			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(TargetPath) ..\..\..\bin\x86-nt\$(TargetName)-DEBUG.exe"
+			/>
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
 			OutputDirectory="Release"
 			IntermediateDirectory="Release"
 			ConfigurationType="1"
-			CharacterSet="2">
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
 			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="2"
 				InlineFunctionExpansion="1"
-				OmitFramePointers="TRUE"
+				OmitFramePointers="true"
 				AdditionalIncludeDirectories="..\..\..\Libraries\sphinx2\include;..\..\..\Libraries\sphinx2\src\libsphinx2\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_MBCS"
-				StringPooling="TRUE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_MBCS;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS"
+				StringPooling="true"
 				RuntimeLibrary="2"
-				EnableFunctionLevelLinking="TRUE"
+				EnableFunctionLevelLinking="true"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
-				Detect64BitPortabilityProblems="TRUE"
-				DebugInformationFormat="3"/>
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
 			<Tool
-				Name="VCCustomBuildTool"/>
+				Name="VCManagedResourceCompilerTool"
+			/>
 			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="../../../Libraries/sphinx2/lib/Release/libsphinx2.lib ../../../Libraries/sphinx2/lib/Release/libsphinx2ad.lib ../../../Libraries/sphinx2/lib/Release/libsphinx2fe.lib wsock32.lib winmm.lib"
+				AdditionalDependencies="wsock32.lib winmm.lib"
 				OutputFile="$(OutDir)/Sphinx_Engine.exe"
 				LinkIncremental="1"
-				GenerateDebugInformation="TRUE"
+				GenerateDebugInformation="true"
 				SubSystem="1"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
-				TargetMachine="1"/>
+				TargetMachine="1"
+			/>
 			<Tool
-				Name="VCMIDLTool"/>
+				Name="VCALinkTool"
+			/>
 			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine="copy $(TargetPath) ..\..\..\Bin\x86-nt"/>
+				Name="VCManifestTool"
+			/>
 			<Tool
-				Name="VCPreBuildEventTool"/>
+				Name="VCXDCMakeTool"
+			/>
 			<Tool
-				Name="VCPreLinkEventTool"/>
+				Name="VCBscMakeTool"
+			/>
 			<Tool
-				Name="VCResourceCompilerTool"/>
+				Name="VCFxCopTool"
+			/>
 			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
+				Name="VCAppVerifierTool"
+			/>
 			<Tool
-				Name="VCXMLDataGeneratorTool"/>
+				Name="VCWebDeploymentTool"
+			/>
 			<Tool
-				Name="VCWebDeploymentTool"/>
-			<Tool
-				Name="VCManagedWrapperGeneratorTool"/>
-			<Tool
-				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(TargetPath) ..\..\..\Bin\x86-nt"
+			/>
 		</Configuration>
 	</Configurations>
 	<References>
@@ -129,24 +190,30 @@
 	<Files>
 		<Filter
 			Name="Source Files"
-			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
+			>
 			<File
-				RelativePath="main.c">
+				RelativePath="main.c"
+				>
 			</File>
 			<File
-				RelativePath="sock.c">
+				RelativePath="sock.c"
+				>
 			</File>
 			<File
-				RelativePath="sock.h">
+				RelativePath="sock.h"
+				>
 			</File>
 		</Filter>
 		<Filter
 			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc">
+			Filter="h;hpp;hxx;hm;inl;inc"
+			>
 		</Filter>
 		<Filter
 			Name="Resource Files"
-			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+			>
 		</Filter>
 	</Files>
 	<Globals>

Modified: Agents/MultiDecoder/Sphinx_Engine/main.c
===================================================================
--- Agents/MultiDecoder/Sphinx_Engine/main.c	2007-08-08 21:30:25 UTC (rev 1881)
+++ Agents/MultiDecoder/Sphinx_Engine/main.c	2007-08-08 21:31:07 UTC (rev 1882)
@@ -1,4 +1,5 @@
 #include <windows.h>
+#include <crtdbg.h>
 #include <time.h>
 #include <sys/timeb.h>
 #include <stdlib.h>
@@ -14,6 +15,8 @@
 
 #include "fbs.h"	/* Fast beam search (FBS) defines */
 #include "search.h"
+#include "lm.h"
+#include "kb.h"
 
 #ifdef __cplusplus
 }
@@ -64,6 +67,9 @@
 
 static int iNBest = 0;		/* the number of n-best hypotheses to generate */
 
+// [2006-07-14] (tk): moved argfn to global space to support re_init
+static char *argfn;
+
 // [2005-10-19] (dbohus): define the THypStruct type which encodes 
 //                        internally information about a hypothesis
 typedef struct {
@@ -238,7 +244,7 @@
 		*p++ = *(*string)++;
 
 	*p = '\0';
-	return strlen(word);
+	return (int)strlen(word);
 }
 
 
@@ -268,7 +274,7 @@
 	finishwid = kb_get_word_id ("</s>");
 	startwid = kb_get_word_id ("<s>");
 	if ((finishwid < 0) || (startwid < 0))
-		return -1;
+		return NULL;
 
 	w1 = finishwid;
 	w2 = startwid;
@@ -276,7 +282,7 @@
 	k = 1;
 	for (h = hyp; h; h = h->next) {
 		if (k > 4095)
-			return -1;
+			return NULL;
 		lm_tg_score (w1, w2, h->wid);
 		type[k++] = lm3g_access_type();
 		w1 = w2;
@@ -304,13 +310,13 @@
 	// confidence to 0.7
 	search_hyp_t *h;
 	int32 w1, w2, finishwid, startwid, type[4096];
-	int32 i, k, t;
+	int32 i, k;
 	float* conf;
 
 	finishwid = kb_get_word_id ("</s>");
 	startwid = kb_get_word_id ("<s>");
 	if ((finishwid < 0) || (startwid < 0))
-		return -1;
+		return NULL;
 
 	w1 = finishwid;
 	w2 = startwid;
@@ -318,7 +324,7 @@
 	k = 1;
 	for (h = hyp; h; h = h->next) {
 		if (k > 4095)
-			return -1;
+			return NULL;
 //		lm_tg_score (w1, w2, h->wid);
 //		type[k++] = lm3g_access_type();
 		k++;
@@ -337,7 +343,7 @@
 	for (i = 1, h = hyp; i < k-2; i++, h = h->next) {
 //		t = type[i-1] + type[i] + ((type[i+1] + type[i+2])<<1);
 //		h->conf = (float)((double)(t-6)/12.0);
-		conf[i-1] = 0.7;
+		conf[i-1] = 0.7F;
 	}
 
 	return conf;
@@ -399,7 +405,6 @@
 	char tmp[16384];
 	search_hyp_t *h;
 	float *lm_conf = NULL;
-	char *ptmp;
 
 	// Fill in confidence values for words in result and build filtered hypothesis 
 	if (slm) 
@@ -434,6 +439,9 @@
 
 	has_oov = 0;
 
+	// [2006-05-28] (tk): hyp_conf_slm could return NULL, but don't know what to do
+	_ASSERT(lm_conf);
+
 	for (h = hypseg; h; h = h->next) {
 		
 		// (antoine) Update Sphinx word confidence statistics
@@ -461,7 +469,7 @@
 			if ((ch_len + 1 + strlen(h->word) < HYPSTR_SIZE) &&
 				(h->word[0] != '+')) {
 				strcpy (phs->confhypstr + ch_len, h->word);
-				ch_len += strlen(h->word);
+				ch_len += (int)strlen(h->word);
 				phs->confhypstr[ch_len++] = ' ';
 			}
 
@@ -469,7 +477,7 @@
 			if ((h_len + 1 + strlen(h->word) < HYPSTR_SIZE) &&
 				(h->word[0] != '+')) {
 				strcpy (phs->hypstr + h_len, h->word);
-				h_len += strlen(h->word);
+				h_len += (int)strlen(h->word);
 				phs->hypstr[h_len++] = ' ';
 			}
 
@@ -487,7 +495,7 @@
 				strcpy (phs->confhypstr + ch_len, ".?");
 				ch_len += 2;
 				strcpy (phs->confhypstr + ch_len, h->word);
-				ch_len += strlen(h->word);
+				ch_len += (int)strlen(h->word);
 				strcpy (phs->confhypstr + ch_len, "?.");
 				ch_len += 2;
 				phs->confhypstr[ch_len++] = ' ';
@@ -497,7 +505,7 @@
 			if ((h_len + 1 + strlen(h->word) < HYPSTR_SIZE) &&
 				(h->word[0] != '+')) {
 				strcpy (phs->hypstr + h_len, h->word);
-				h_len += strlen(h->word);
+				h_len += (int)strlen(h->word);
 				phs->hypstr[h_len++] = ' ';
 			} 
 		}
@@ -514,9 +522,9 @@
 				strcat(phs->startframes_list, " ");
 				strcat(phs->endframes_list, " ");
 			}
-			itoa(h->sf, tmp, 10);
+			_itoa(h->sf, tmp, 10);
 			strcat(phs->startframes_list, tmp);
-			itoa(h->ef, tmp, 10);
+			_itoa(h->ef, tmp, 10);
 			strcat(phs->endframes_list, tmp);
 		}
 
@@ -532,7 +540,7 @@
 		// for the hypstr
 		if (h_len + 1 + strlen("++OOV++ ") < HYPSTR_SIZE) {
 			strcpy (phs->hypstr + h_len, "++OOV++ ");
-			h_len += strlen("++OOV++ ");
+			h_len += (int)strlen("++OOV++ ");
 			strcpy(phs->startframes_list, "N/A");
 			strcpy(phs->endframes_list, "N/A");
 		} 
@@ -540,7 +548,7 @@
 		// for the confhypstr
 		if (ch_len + 1 + strlen("++OOV++ ") < HYPSTR_SIZE) {
 			strcpy (phs->confhypstr + ch_len, "++OOV++ ");
-			ch_len += strlen("++OOV++ ");
+			ch_len += (int)strlen("++OOV++ ");
 		} 
 	}
 
@@ -619,8 +627,8 @@
 
 void engine_proc_result()
 {
-	int n_frm, len;
-	search_hyp_t *hypseg, *h;
+	int n_frm;
+	search_hyp_t *hypseg;
 	char confhypstr[HYPSTR_SIZE];
 	char *hypstr;
 	char to_audio[SOCK_BUF_SIZE];
@@ -646,7 +654,7 @@
 
 		// [2005-10-19] (dbohus): added support for generating NBest Lists
 	    if(iNBest > 0) {
-			search_hyp_t *h, **alt;
+			search_hyp_t **alt;
 			int32 startwid, ef;
 	
 			startwid = kb_get_word_id("<s>");
@@ -689,7 +697,7 @@
 	strcat(to_audio, " ) }");
 
 	Log("Sending final hypotheses frame:\n%s\n", to_audio);
-	sock_send_block(Client, to_audio, strlen(to_audio));
+	sock_send_block(Client, to_audio, (int32)strlen(to_audio));
 
 }
 
@@ -873,7 +881,7 @@
 							hyp_str, utt_id, client_name, 
 							iUttStartTimestamp, iEndTimestamp, n_frame);
 					Log("Sending:\n %s", to_audio);
-					sock_send_noblock(Client, to_audio, strlen(to_audio));
+					sock_send_noblock(Client, to_audio, (int32)strlen(to_audio));
 					Log("Sent\n");
 					pr_rpt_frame = n_frame;
 				}
@@ -892,6 +900,28 @@
 			}
 			break;
 		}
+		// [2006-07-14] (tk): handle an engine restart. this was required for changing dicts and lm's on the fly.
+		else if (!strcmp(word, "engine_restart")) {
+			Log("engine restart");
+
+			if (utt_state == UTT_STARTED) {
+				// there is a started utterance: abort it
+				uttproc_abort_utt();
+				Log("Canceled utterance in UTT_STARTED state.");
+			} else if (utt_state == UTT_ENDED) {
+				// the utterance has already ended but we haven't
+				// got the result yet. get them and ignore them.
+				uttproc_result_seg(&n_frm, &hypseg, 1);			
+				Log("Canceled utterance in UTT_ENDED state.");
+			}
+			utt_state = UTT_IDLE;
+
+			if (decoder_init(argfn) < 0) {
+				Log("ERROR: decoder initialization failed");
+				exit(1);
+			}
+			break;
+		}
 		else
 			continue;
 	}
@@ -977,7 +1007,6 @@
 	SOCKET listen_socket, max;
 	fd_set fds;
 	int i;
-	char *argfn;
 
 	client_name = NULL;
 	argfn = NULL;
@@ -1041,7 +1070,7 @@
 				max = Client;
 		}
 		max++;
-		if (select(max, &fds, NULL, NULL, NULL) == SOCKET_ERROR) {
+		if (select((int)max, &fds, NULL, NULL, NULL) == SOCKET_ERROR) {
 			Log("ERROR: select error");
 		}
 		if (Client != INVALID_SOCKET){

Modified: Agents/MultiDecoder/Sphinx_Engine/sock.c
===================================================================
--- Agents/MultiDecoder/Sphinx_Engine/sock.c	2007-08-08 21:30:25 UTC (rev 1881)
+++ Agents/MultiDecoder/Sphinx_Engine/sock.c	2007-08-08 21:31:07 UTC (rev 1882)
@@ -6,7 +6,7 @@
 #include <unistd.h>
 #endif
 #include <stdio.h>
-
+
 /*
  * Initialize sock routines
  */
@@ -171,7 +171,7 @@
     
     return listen_sd;
 }
-
+
 SOCKET sock_new_connection (SOCKET listen_sd)
 {
     fd_set l_fds;
@@ -183,7 +183,7 @@
     FD_ZERO(&l_fds);
     FD_SET(listen_sd, &l_fds);
 
-    if ((n_rdy = select(listen_sd+1, &l_fds, NULL, NULL, &poll)) < 0) {
+    if ((n_rdy = select((int)listen_sd+1, &l_fds, NULL, NULL, &poll)) < 0) {
 	fprintf(stderr,"select error");
     }
     if (n_rdy) {
@@ -193,7 +193,7 @@
 	return INVALID_SOCKET;
     }
 }
-
+
 SOCKET sock_await_connection (SOCKET listen_sd)
 {
     int32 flag;
@@ -233,7 +233,7 @@
     
     return conn_sd;
 }
-
+
 SOCKET sock_connect (const char *hostname, int32 port)
 {
     struct sockaddr_in addr;
@@ -265,7 +265,7 @@
 	}
 	
 	/* Connect to server */
-	memset ((char *) &addr, sizeof(addr), 0);
+	memset ((char *) &addr, 0, sizeof(addr));
 	addr.sin_family = AF_INET;
 	memcpy (&addr.sin_addr, hp->h_addr, hp->h_length);
 	addr.sin_port = htons((u_short) port);
@@ -339,7 +339,7 @@
     
     FD_ZERO (&readfds);
     FD_SET (sd, &readfds);
-    if (select (sd+1, &readfds, NULL, NULL, NULL) == SOCKET_ERROR) {
+    if (select ((int)sd+1, &readfds, NULL, NULL, NULL) == SOCKET_ERROR) {
 	print_errno ("sock_recv_select");
 	return -2;		/* Error */
     }


More information about the Ravenclaw-developers mailing list