[Julius-cvs 473] CVS update: julius4/msvc/SampleApp

Back to archive index

sumom****@users***** sumom****@users*****
2009年 10月 22日 (木) 20:02:41 JST


Index: julius4/msvc/SampleApp/Julius.cpp
diff -u julius4/msvc/SampleApp/Julius.cpp:1.1 julius4/msvc/SampleApp/Julius.cpp:1.2
--- julius4/msvc/SampleApp/Julius.cpp:1.1	Thu Oct 22 01:47:20 2009
+++ julius4/msvc/SampleApp/Julius.cpp	Thu Oct 22 20:02:41 2009
@@ -1,25 +1,24 @@
 #include	<julius/juliuslib.h>
 #include	"Julius.h"
 
-///// ƒR[ƒ‹ƒoƒbƒNŠÖ”
-#define JCALLBACK(A, B) \
-static void A ( Recog *recog, void *data) \
-{\
-	cJulius *j = (cJulius *) data;\
-	SendMessage(j->getWindow(), WM_JULIUS, B, 0L);\
-}
-
-JCALLBACK(callback_engine_active,	JEVENT_ENGINE_ACTIVE);
-JCALLBACK(callback_engine_inactive,	JEVENT_ENGINE_INACTIVE);
-JCALLBACK(callback_audio_ready,		JEVENT_AUDIO_READY);
-JCALLBACK(callback_audio_begin,		JEVENT_AUDIO_BEGIN);
-JCALLBACK(callback_audio_end,		JEVENT_AUDIO_END);
-JCALLBACK(callback_recog_begin,		JEVENT_RECOG_BEGIN);
-JCALLBACK(callback_recog_end,		JEVENT_RECOG_END);
-JCALLBACK(callback_recog_frame,		JEVENT_RECOG_FRAME);
-JCALLBACK(callback_engine_pause,	JEVENT_ENGINE_PAUSE);
-JCALLBACK(callback_engine_resume,	JEVENT_ENGINE_RESUME);
+// -----------------------------------------------------------------------------
+// JuliusLib callback functions
+//
+
+#define JCALLBACK(A, B) static void A (Recog *recog, void *data) { cJulius *j = (cJulius *) data; SendMessage(j->getWindow(), WM_JULIUS, B, 0L);}
+
+JCALLBACK(callback_engine_active,	JEVENT_ENGINE_ACTIVE)
+JCALLBACK(callback_engine_inactive,	JEVENT_ENGINE_INACTIVE)
+JCALLBACK(callback_audio_ready,		JEVENT_AUDIO_READY)
+JCALLBACK(callback_audio_begin,		JEVENT_AUDIO_BEGIN)
+JCALLBACK(callback_audio_end,		JEVENT_AUDIO_END)
+JCALLBACK(callback_recog_begin,		JEVENT_RECOG_BEGIN)
+JCALLBACK(callback_recog_end,		JEVENT_RECOG_END)
+JCALLBACK(callback_recog_frame,		JEVENT_RECOG_FRAME)
+JCALLBACK(callback_engine_pause,	JEVENT_ENGINE_PAUSE)
+JCALLBACK(callback_engine_resume,	JEVENT_ENGINE_RESUME)
 
+// callback to get result
 static void callback_result_final(Recog *recog, void *data)
 {
 	cJulius *j = (cJulius *)data;
@@ -68,36 +67,34 @@
 	str[0] = '\0';
 	for(i=0;i<seqnum;i++) strcat(str, winfo->woutput[seq[i]]);
 
+	// convert to wide char
 	mbstowcs_s( &size, wstr, str, strlen(str)+1);
 
+	// set status parameter
 	wparam = (r->result.status << 16) + JEVENT_RESULT_FINAL;
 
+	// send message
 	SendMessage(j->getWindow(), WM_JULIUS, wparam, (LPARAM)wstr);
 }
 
-// ƒ|[ƒY—p’âŽ~ŠÖ”
-
+// callbackk for pause
 static void callback_wait_for_resume(Recog *recog, void *data)
 {
 	cJulius *j = (cJulius *)data;
-	// ‚±‚̃XƒŒƒbƒhi”FŽ¯ƒXƒŒƒbƒhj‚ÌŽÀs‚ð’†’f
+	// Stop running the engine thread
 	SuspendThread( j->getThreadHandle() );
-	// •ÊƒXƒŒƒbƒh‚©‚çResumeThread()‚ªŒÄ‚΂ê‚é‚Ü‚Å‘Ò‹@
+	// the engine thread will wait until the main thread calls ResumeThread() for it
 }
 
-//-----------------------------------------------------------------------------------------
-
 #ifdef APP_ADIN
 static int callback_adin_fetch_input(SP16 *sampleBuffer, int reqlen)
 {
-	// ‹¤—Lƒoƒbƒtƒ@‚ɐV‚½‚ȏ‘‚«ž‚Ý‚ª‚ ‚é‚©A‚ ‚é‚¢‚Í‘O‰ñ‚ÌŽc‚肪‚ ‚é‚©ƒ`ƒFƒbƒN
-	// ‚ ‚ê‚΂»‚ê‚ðÅ‘å reqlen ‚¾‚¯ sampleBuffer ‚ɏ‘‚«ž‚Þ
+	// If shared audio buffer has some new data, or some data remains from the last call,
+	// get the samples into sampleBuffer at most reqlen length.
 }
 #endif
 
-//-----------------------------------------------------------------------------------------
-
-// ”FŽ¯ƒXƒŒƒbƒh‚̃ƒCƒ“ŠÖ”
+// main function for the engine thread
 DWORD WINAPI recogThreadMain(LPVOID vdParam)
 {
 	int ret;
@@ -108,12 +105,12 @@
 }
 
 //-----------------------------------------------------------------------------------------
+// Julius class definition
 //-----------------------------------------------------------------------------------------
 
-
-//================
-// ƒRƒ“ƒXƒgƒ‰ƒNƒ^
-//================
+//=============
+// Constructor
+//=============
 cJulius::cJulius( void ) : m_jconf( NULL ), m_recog( NULL ), m_opened( false ), m_threadHandle( NULL ), m_fpLogFile( NULL )
 {
 #ifdef APP_ADIN
@@ -122,9 +119,9 @@
 	setLogFile( "juliuslog.txt" );
 }
 
-//==============
-// ƒfƒXƒgƒ‰ƒNƒ^
-//==============
+//============
+// Destructor
+//============
 cJulius::~cJulius( void )
 {
 	release();
@@ -134,9 +131,9 @@
 	}
 }
 
-//=========
-// ‰Šú‰»1
-//=========
+//=================================
+// Initialize, with argument array
+//=================================
 bool cJulius::initialize( int argnum, char *argarray[])
 {
 	bool ret;
@@ -154,9 +151,9 @@
 	return ret;
 }
 
-//=========
-// ‰Šú‰»2
-//=========
+//===============================
+// Initialize, with a Jconf file
+//===============================
 bool cJulius::initialize( char *filename )
 {
 	bool ret;
@@ -170,9 +167,9 @@
 	return ret;
 }
 
-//=========
-// ‰Šú‰»2
-//=========
+//===================
+// Load a Jconf file
+//===================
 bool cJulius::loadJconf( char *filename )
 {
 	if (m_jconf) {
@@ -188,9 +185,9 @@
 	return true;
 }
 
-//==================
-// ƒƒOƒtƒ@ƒCƒ‹o—Í
-//==================
+//==============================================
+// Set a log file to save Julius engine outputs
+//==============================================
 void cJulius::setLogFile( const char *filename )
 {
 	if (m_fpLogFile) {
@@ -202,9 +199,9 @@
 	}
 }
 
-//================
-// ƒGƒ“ƒWƒ“‰Šú‰»
-//================
+//========================
+// Create engine instance
+//========================
 bool cJulius::createEngine( void )
 {
 #ifdef APP_ADIN
@@ -216,7 +213,6 @@
 
 #ifdef APP_ADIN
 	if (m_appsource != 0) {
-		// ƒAƒvƒŠŽ©g‚Ì“ü—Í‚Ì‚½‚ß‚ÉjconfÝ’è‚ð•ÏX
 		switch(m_appsource) {
 			case 1: // buffer input, batch
 				m_recog->jconf->input.type = INPUT_WAVEFORM;
@@ -232,13 +228,13 @@
 	}
 #endif
 
-	// ƒGƒ“ƒWƒ“‚ð‹N“®
+	// Create engine instance
 	m_recog = j_create_instance_from_jconf(m_jconf);
 	if (m_recog == NULL) {
 		return false;
 	}
 
-	// ƒR[ƒ‹ƒoƒbƒN‚ð“o˜^
+	// Register callbacks
 	callback_add(m_recog, CALLBACK_EVENT_PROCESS_ONLINE,		::callback_engine_active, this);
 	callback_add(m_recog, CALLBACK_EVENT_PROCESS_OFFLINE,		::callback_engine_inactive, this);
 	callback_add(m_recog, CALLBACK_EVENT_SPEECH_READY,			::callback_audio_ready, this);
@@ -253,9 +249,8 @@
 	callback_add(m_recog, CALLBACK_PAUSE_FUNCTION,				::callback_wait_for_resume, this);
 
 #ifdef APP_ADIN
-	// ‰¹º“ü—̓fƒoƒCƒX‚ð‰Šú‰»
+	// Initialize application side audio input
 	if (m_appsource != 0) {
-		// ƒAƒvƒŠ“ü—Í—p‚ÉŽ©‘O‚ŏ‰Šú‰»
 		a = m_recog->adin;
 		switch(m_appsource) {
 			case 1: // buffer input, batch
@@ -289,7 +284,7 @@
 		if (adin_setup_param(a, m_recog->jconf) == FALSE) return false;
 		a->input_side_segment = FALSE;
 	} else {
-		// JuliusLib ‚ɏ‰Šú‰»‚ð”C‚¹‚é
+		// Let JuliusLib get audio input
 		if (! j_adin_init( m_recog ) ) return false;
 	}
 #else
@@ -299,9 +294,9 @@
 	return true;
 }
 
-//====================
-// ˆ—‚ðŠJŽn‚·‚é
-//====================
+//==============================================
+// Open stream and start the recognition thread
+//==============================================
 bool cJulius::startProcess( HWND hWnd )
 {
 
@@ -336,42 +331,43 @@
 	return true;
 }
 
-//================
-// ˆ—‚ðI—¹‚·‚é
-//================
+//==================================================
+// Close audio stream and detach recognition thread
+//==================================================
 void cJulius::stopProcess( void )
 {
 	if (m_opened) {
-		// ƒXƒgƒŠ[ƒ€‚ð•Â‚¶‚éiƒXƒŒƒbƒh‚͏I—¹‚·‚é‚Í‚¸j
+		// recognition thread will exit when audio input is closed
 		j_close_stream(m_recog);
 		m_opened = false;
 	}
 }
 
-//==========
-// ˆêŽž’âŽ~
-//==========
+//===================
+// Pause recognition
+//===================
 void cJulius::pause( void )
 {
-	// ’âŽ~‚ð—v‹
-	// Ž~‚Ü‚Á‚½‚çA”FŽ¯ƒXƒŒƒbƒh‚Í pause ƒCƒxƒ“ƒg”­ŒøŒã PAUSE_FUNCTION ƒR[ƒ‹ƒoƒbƒN‚ðŽÀs
+	// request library to pause
+	// After pause, the recognition thread will issue pause event
+	// and then enter callback_wait_for_resume(), where thread will pause.
 	j_request_terminate(m_recog);
 }
 
-//==========
-// “®ìÄŠJ
-//==========
+//====================
+// Resume recognition
+//====================
 void cJulius::resume( void )
 {
-	// ÄŠJ—v‹‚ðæ‚ɃZƒbƒg
+	// request library to resume
 	j_request_resume(m_recog);
-	// ”FŽ¯ƒXƒŒƒbƒh‚Ì“®ì‚ðÄŠJB”FŽ¯ƒXƒŒƒbƒh‚Í resume ƒCƒxƒ“ƒg”­ŒøŒã”FŽ¯ˆ—‚ðÄŠJ‚·‚é
+	// resume the recognition thread
 	ResumeThread( m_threadHandle );
 }
 
-//==============
-// •¶–@“ǂݍž‚Ý
-//==============
+//==================
+// Load DFA grammar
+//==================
 bool cJulius::loadGrammar( WORD_INFO *winfo, DFA_INFO *dfa, char *dictfile, char *dfafile, RecogProcess *r )
 {
 	boolean ret;
@@ -403,9 +399,9 @@
 	return true;
 }
 
-//==============
-// •¶–@’ljÁ
-//==============
+//=================
+// Add DFA grammar
+//=================
 bool cJulius::addGrammar( char *name, char *dictfile, char *dfafile, bool deleteAll )
 {
 	WORD_INFO *winfo;
@@ -452,16 +448,16 @@
 }
 
 //==============
-// •¶–@“ü‚ê‘Ö‚¦
+// Swap grammar
 //==============
 bool cJulius::changeGrammar( char *name, char *dictfile, char *dfafile )
 {
 	return addGrammar(name, dictfile, dfafile, true);
 }
 
-//==============
-// •¶–@íœ
-//==============
+//============================
+// Delete grammar by its name
+//============================
 bool cJulius::deleteGrammar( char *name )
 {
 	RecogProcess *r = m_recog->process_list;
@@ -482,9 +478,9 @@
 	return true;
 }
 
-//==============
-// •¶–@ˆêŽž–³Œø
-//==============
+//================================
+// Deactivate grammar by its name
+//================================
 bool cJulius::deactivateGrammar( char *name )
 {
 	RecogProcess *r = m_recog->process_list;
@@ -508,9 +504,10 @@
 
 	return true;
 }
-//====================
-// •¶–@ˆêŽž–³Œø‚ð‰ðœ
-//====================
+
+//=================================
+// Re-activate grammar by its name
+//=================================
 bool cJulius::activateGrammar( char *name )
 {
 	RecogProcess *r = m_recog->process_list;
@@ -535,9 +532,9 @@
 	return true;
 }
 
-//=========
-// ‰ð•ú
-//=========
+//=====================================
+// Stop processes and release all data
+//=====================================
 void cJulius::release( void )
 {
 	stopProcess();
Index: julius4/msvc/SampleApp/Julius.h
diff -u julius4/msvc/SampleApp/Julius.h:1.1 julius4/msvc/SampleApp/Julius.h:1.2
--- julius4/msvc/SampleApp/Julius.h:1.1	Thu Oct 22 01:47:20 2009
+++ julius4/msvc/SampleApp/Julius.h	Thu Oct 22 20:02:41 2009
@@ -1,25 +1,15 @@
-//
-// EJulius ‰Šú‰»Fƒ[ƒh‚µ‚Ĉȉº‚̊֐”‚ðƒR[ƒ‹ƒoƒbƒN‚ÉŽdž‚Þ
-// @”FŽ¯ŠJŽn
-// @ƒgƒŠƒKŒŸ’m
-//@@Œ‹‰ÊŽæ“¾
-//    ŠeŠÖ”‚͑Ήž‚·‚郁ƒbƒZ[ƒW‚ðƒEƒBƒ“ƒhƒEƒYƒCƒxƒ“ƒg‚Ö issue ‚·‚é
-// E‰¹º”FŽ¯ŠJŽn
-// E‰¹º”FŽ¯’†’fEÄŠJ
-// E‰¹º”FŽ¯I—¹
-
 #ifndef		_JULIUSCLASS_H_
 #define		_JULIUSCLASS_H_
 
 #include	"julius/juliuslib.h"
 
-// ŠJ”­—p’è‹`
+// for development codes: do not define this
 #undef APP_ADIN
 
-// ƒ†[ƒU’è‹`ƒCƒxƒ“ƒg
+// Julius event identifier
 #define WM_JULIUS			(WM_USER + 1)
 
-// ƒCƒxƒ“ƒgID
+// Event ID
 enum {
 	JEVENT_ENGINE_ACTIVE,
 	JEVENT_ENGINE_INACTIVE,
Index: julius4/msvc/SampleApp/SampleApp.rc
diff -u julius4/msvc/SampleApp/SampleApp.rc:1.1 julius4/msvc/SampleApp/SampleApp.rc:1.2
--- julius4/msvc/SampleApp/SampleApp.rc:1.1	Thu Oct 22 01:47:20 2009
+++ julius4/msvc/SampleApp/SampleApp.rc	Thu Oct 22 20:02:41 2009
@@ -1,11 +1,11 @@
-//Microsoft Visual C++ ‚Ő¶¬‚³‚ꂽƒŠƒ\[ƒX ƒXƒNƒŠƒvƒg‚Å‚·B
+//This is a resource script generated by Microsoft Visual C++
 //
 #include "resource.h"
 
 #define APSTUDIO_READONLY_SYMBOLS
 /////////////////////////////////////////////////////////////////////////////
 //
-// TEXTINCLUDE 2 ƒŠƒ\[ƒX‚©‚琶¬‚³‚ê‚Ü‚µ‚½B
+// Generated from TEXTINCLUDE 2 resources
 //
 #ifndef APSTUDIO_INVOKED
 #include "targetver.h"
@@ -22,41 +22,41 @@
 
 /////////////////////////////////////////////////////////////////////////////
 //
-// ƒAƒCƒRƒ“
+// Icons
 //
 
-// ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̃AƒCƒRƒ“‚ð‚·‚×‚Ä‚ÌƒVƒXƒeƒ€ã‚ňێ‚·‚邽‚߂ɁAÅ‚à¬‚³‚¢
-// ID ’l‚̃AƒCƒRƒ“‚ªÅ‰‚É”z’u‚³‚ê‚Ü‚·B
+// In order to allocate an application icon in all systems, the icon 
+// with the smallest ID value will be placed first.
 
-IDI_SAMPLEAPP       ICON         "SampleApp.ico"
-IDI_SMALL               ICON         "small.ico"
+// IDI_SAMPLEAPP       ICON         "SampleApp.ico"
+// IDI_SMALL               ICON         "small.ico"
 
 /////////////////////////////////////////////////////////////////////////////
 //
-// ƒƒjƒ…[
+// Menu
 //
 
 IDC_SAMPLEAPP MENU
 BEGIN
-    POPUP "ƒtƒ@ƒCƒ‹(&F)"
+    POPUP "File (&F)"
     BEGIN
-        MENUITEM "ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̏I—¹(&X)",                IDM_EXIT
+        MENUITEM "Quit (&X)",                IDM_EXIT
     END
-    POPUP "‘€ì(&M)"
+    POPUP "Command (&M)"
     BEGIN
-        MENUITEM "”FŽ¯’†’f",                IDM_PAUSE
-        MENUITEM "”FŽ¯ÄŠJ",                IDM_RESUME
+        MENUITEM "Pause recognition",                IDM_PAUSE
+        MENUITEM "Resume recognition",               IDM_RESUME
     END
-    POPUP "ƒwƒ‹ƒv(&H)"
+    POPUP "Help (&H)"
     BEGIN
-        MENUITEM "ƒo[ƒWƒ‡ƒ“î•ñ(&A)...",           IDM_ABOUT
+        MENUITEM "About (&A)...",           IDM_ABOUT
     END
 END
 
 
 /////////////////////////////////////////////////////////////////////////////
 //
-// ƒAƒNƒZƒ‰ƒŒ[ƒ^
+// Accelerators
 //
 
 IDC_SAMPLEAPP ACCELERATORS
@@ -68,13 +68,13 @@
 
 /////////////////////////////////////////////////////////////////////////////
 //
-// ƒ_ƒCƒAƒƒO
+// Dialog
 //
 
 IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "ƒo[ƒWƒ‡ƒ“î•ñ SampleApp"
-FONT 9, "MS UI Gothic"
+CAPTION "About SampleApp"
+//FONT 9, "MS UI Gothic"
 BEGIN
     ICON            IDR_MAINFRAME,IDC_STATIC,14,14,21,20
     LTEXT           "SampleApp, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
@@ -131,7 +131,7 @@
 
 /////////////////////////////////////////////////////////////////////////////
 //
-// ƒXƒgƒŠƒ“ƒO ƒe[ƒuƒ‹
+// String table
 //
 
 STRINGTABLE
@@ -148,8 +148,8 @@
 #ifndef APSTUDIO_INVOKED
 /////////////////////////////////////////////////////////////////////////////
 //
-// TEXTINCLUDE 3 ƒŠƒ\[ƒX‚©‚琶¬‚³‚ê‚Ü‚µ‚½B
+// Generated from TEXTINCLUDE 3 resources
 //
 
 /////////////////////////////////////////////////////////////////////////////
-#endif    // APSTUDIO_INVOKED ‚Å‚È‚¢ê‡
+#endif    // not APSTUDIO_INVOKED
Index: julius4/msvc/SampleApp/SampleApp.vcproj
diff -u julius4/msvc/SampleApp/SampleApp.vcproj:1.1 julius4/msvc/SampleApp/SampleApp.vcproj:1.2
--- julius4/msvc/SampleApp/SampleApp.vcproj:1.1	Thu Oct 22 01:47:20 2009
+++ julius4/msvc/SampleApp/SampleApp.vcproj	Thu Oct 22 20:02:41 2009
@@ -246,10 +246,6 @@
 				RelativePath=".\SampleApp.rc"
 				>
 			</File>
-			<File
-				RelativePath=".\small.ico"
-				>
-			</File>
 		</Filter>
 		<File
 			RelativePath=".\ReadMe.txt"



Julius-cvs メーリングリストの案内
Back to archive index