sumom****@users*****
sumom****@users*****
2009年 10月 27日 (火) 23:48:21 JST
Index: julius4/msvc/SampleApp/Julius.cpp diff -u julius4/msvc/SampleApp/Julius.cpp:1.3 julius4/msvc/SampleApp/Julius.cpp:1.4 --- julius4/msvc/SampleApp/Julius.cpp:1.3 Fri Oct 23 09:29:00 2009 +++ julius4/msvc/SampleApp/Julius.cpp Tue Oct 27 23:48:21 2009 @@ -1,3 +1,13 @@ +/** + * + * cJulius: JuliusLib wrapper class for C++ + * + * Copyright (c) 2009 Julius project team, Nagoya Institute of Technology + * All rights reserved + * + * This is a part of the Julius software. + */ + #include <julius/juliuslib.h> #include "Julius.h" @@ -33,6 +43,7 @@ static wchar_t wstr[2048]; size_t size = 0; WPARAM wparam = 0; + _locale_t locale; r = j->getRecog()->process_list; if (! r->live) return; @@ -68,7 +79,11 @@ for(i=0;i<seqnum;i++) strcat(str, winfo->woutput[seq[i]]); // convert to wide char - mbstowcs_s( &size, wstr, str, strlen(str)+1); + //mbstowcs_s( &size, wstr, str, strlen(str)+1); + locale = j->getModelLocale(); + if (locale) _mbstowcs_s_l( &size, wstr, str, strlen(str)+1, locale); + else mbstowcs_s( &size, wstr, str, strlen(str)+1); + // set status parameter wparam = (r->result.status << 16) + JEVENT_RESULT_FINAL; @@ -111,7 +126,7 @@ //============= // Constructor //============= -cJulius::cJulius( void ) : m_jconf( NULL ), m_recog( NULL ), m_opened( false ), m_threadHandle( NULL ), m_fpLogFile( NULL ) +cJulius::cJulius( void ) : m_jconf( NULL ), m_recog( NULL ), m_opened( false ), m_threadHandle( NULL ), m_fpLogFile( NULL ), m_modelLocale( NULL ) { #ifdef APP_ADIN m_appsource = 0; @@ -199,6 +214,22 @@ } } +//====================== +// set locale of the LM +//====================== +void cJulius::setModelLocale( const char *locale ) +{ + m_modelLocale = _create_locale( LC_CTYPE, locale); +} + +//======================================== +// return current model locale for output +//======================================== +_locale_t cJulius::getModelLocale( void ) +{ + return( m_modelLocale ); +} + //======================== // Create engine instance //======================== @@ -302,11 +333,11 @@ if ( ! m_recog ) return false; - // bZ[WMæðÛ¶ + // store window hanlder to send event message m_hWnd = hWnd; if (m_opened == false) { - // foCXðJ + // open device switch(j_open_stream(m_recog, NULL)) { case 0: /* succeeded */ break; @@ -317,7 +348,7 @@ //fprintf(stderr, "failed to begin input stream\n"); return false; } - // XbhðJ + // create recognition thread m_threadHandle = CreateThread(NULL, 0, ::recogThreadMain, (LPVOID)m_recog, 0, &m_threadId); if (m_threadHandle == NULL) { j_close_stream(m_recog); Index: julius4/msvc/SampleApp/Julius.h diff -u julius4/msvc/SampleApp/Julius.h:1.2 julius4/msvc/SampleApp/Julius.h:1.3 --- julius4/msvc/SampleApp/Julius.h:1.2 Thu Oct 22 20:02:41 2009 +++ julius4/msvc/SampleApp/Julius.h Tue Oct 27 23:48:21 2009 @@ -1,7 +1,18 @@ +/** + * + * cJulius: JuliusLib wrapper class for C++ + * + * Copyright (c) 2009 Julius project team, Nagoya Institute of Technology + * All rights reserved + * + * This is a part of the Julius software. + */ + #ifndef _JULIUSCLASS_H_ #define _JULIUSCLASS_H_ #include "julius/juliuslib.h" +#include "locale.h" // for development codes: do not define this #undef APP_ADIN @@ -38,6 +49,7 @@ HANDLE m_threadHandle; DWORD m_threadId; HWND m_hWnd; + _locale_t m_modelLocale; #ifdef APP_ADIN int m_appsource #endif