OSDN Git Service

読み上げ機能実装
authorqwerty2501 <riot313@gmail.com>
Mon, 20 Feb 2012 15:41:36 +0000 (00:41 +0900)
committerqwerty2501 <riot313@gmail.com>
Mon, 20 Feb 2012 15:41:36 +0000 (00:41 +0900)
nlib/nlib.h
nlib_driver/nlib_driver.cpp
nlite.suo
nlite/nlite.cpp
nlite/nlite.vcxproj
nlite/nlite_mainframe.cpp
nlite/stdafx.h
speaker/open_jtalk_core.cpp
speaker/open_jtalk_core.h

index 649d973..d84b4eb 100644 (file)
@@ -495,7 +495,6 @@ extern "C" {
 #pragma comment(lib, "shell32.lib" )
 #pragma comment(lib,"expat.lib")
 #pragma comment(lib,"sqlite3.lib")
-#pragma comment(lib,"sqliteManager.lib")
 #pragma comment(lib,"shareCookie.lib")
 #pragma comment(lib,"winmm.lib")
 #pragma comment(lib,"JSONParser.lib")
index 32ce29f..1a9c72b 100644 (file)
@@ -20,7 +20,6 @@
 #pragma comment(lib, "shell32.lib" )
 #pragma comment(lib,"expat.lib")
 #pragma comment(lib,"sqlite3.lib")
-#pragma comment(lib,"sqliteManager.lib")
 #pragma comment(lib,"shareCookie.lib")
 #pragma comment(lib,"nlib.lib")
 #pragma comment(lib,"winmm.lib")
index 9aaf808..9769462 100644 (file)
Binary files a/nlite.suo and b/nlite.suo differ
index 6935dcf..8f33502 100644 (file)
@@ -43,7 +43,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
                        throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
                }
 
-               g_speaker.SynthesisAsync(TEXT("\83e\83X\83g\83R\83\81\83\93\83g"));
+               
 
                
                //\83\81\83b\83Z\81[\83W\83\8b\81[\83v\93o\98^
index 21d5f1f..439d4fa 100644 (file)
@@ -90,7 +90,8 @@
       </Command>
     </PreBuildEvent>
     <PostBuildEvent>
-      <Command>xcopy "$(ProjectDir)output" "$(targetdir)" /e /y</Command>
+      <Command>mkdir "$(targetdir)libs" /y
+xcopy "$(ProjectDir)libs" "$(targetdir)libs" /e /y</Command>
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-window|Win32'">
index bb774e8..443c7e5 100644 (file)
@@ -688,7 +688,7 @@ VOID CNliteMainFrame::CLiveUserData::OnChatReceveStart(CNicoLiveStream &stream,N
 VOID CNliteMainFrame::CLiveUserData::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
 
        self.commentView.OnChatReceve(chat,count);
-
+       g_speaker.SynthesisAsync((const speaker::TChar_P)chat->chatBuf);
 }
 
 VOID CNliteMainFrame::CLiveUserData::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
index 4139959..89ed844 100644 (file)
@@ -11,7 +11,7 @@
 #define WIN32_LEAN_AND_MEAN                                    // Windows \83w\83b\83_\81[\82©\82ç\8eg\97p\82³\82ê\82Ä\82¢\82È\82¢\95\94\95ª\82ð\8f\9c\8aO\82µ\82Ü\82·\81B
 #define _CRT_SECURE_NO_WARNINGS 1                      //vc++\82Ì\82¨\82¹\82Á\82©\82¢\82È\8cx\8d\90\82ð\8fÁ\82·
 #define  _CRT_NON_CONFORMING_SWPRINTFS 1       //vc++\82Ì\82¨\82¹\82Á\82©\82¢\82È\8cx\8d\90\82ð\8fÁ\82·
-#define USE_STUB                                                       //\83X\83^\83u\82ð\8eg\97p\82·\82é\8fê\8d\87\82Í\83R\83\81\83\93\83g\83A\83E\83g\82ð\89ð\8f\9c\82·\82é
+//#define USE_STUB                                                     //\83X\83^\83u\82ð\8eg\97p\82·\82é\8fê\8d\87\82Í\83R\83\81\83\93\83g\83A\83E\83g\82ð\89ð\8f\9c\82·\82é
 #define WINDEBUGER_NOPRINTING                          //\83f\83o\83b\83O\8fo\97Í\82ð\83R\83\93\83\\81[\83\8b\82É\95\\8e¦\82µ\82½\82­\82È\82¢\8fê\8d\87\92è\8b`\82·\82é
 #define _WTL_NO_CSTRING
 
index cbe756f..81dd2ff 100644 (file)
@@ -9,7 +9,7 @@ namespace openJtalk{
 COpenJtalkCore::COpenJtalkCore():
 manageFlag(false){
 
-       this->synthesisThreadHandle = (HANDLE)_beginthreadex(NULL,0,COpenJtalkCore::SynthesisThreadFunction,this,0,NULL);
+       _beginthread(COpenJtalkCore::SynthesisThreadFunction,0,this);
        this->synthesisEventObject = ::CreateEvent(NULL,false,false,NULL);
        this->endEventObject = ::CreateEvent(NULL,true,false,NULL);
 
@@ -19,18 +19,11 @@ manageFlag(false){
 COpenJtalkCore::~COpenJtalkCore(){
        if(this->manageFlag == true)this->Clear();
 
-       ::SetEvent(this->endEventObject);
+       
        int errcount = 0;
-       while(::WaitForSingleObject(this->synthesisThreadHandle,3000) == WAIT_TIMEOUT){
-               errcount++;
-               if(errcount > 3){
-
-                       _exit(-1);
-               }
+       ::SetEvent(this->endEventObject);
 
-       }
 
-       ::CloseHandle(this->synthesisThreadHandle);
        ::CloseHandle(this->synthesisEventObject);
        ::CloseHandle(this->endEventObject);
 
@@ -129,12 +122,13 @@ void COpenJtalkCore::SynthesisAsync(const TChar_P txt){
 
        this->synthesisQueueCS.Lock();
 
-       if(this->synthesisQueue.size() > 3)this->synthesisQueue.pop();
+       if(this->synthesisQueue.size() > 3)this->synthesisQueue.pop_back();
 
-       this->synthesisQueue.push(txt);
+       this->synthesisQueue.push_front(txt);
 
        this->synthesisQueueCS.Unlock();
 
+       ::SetEvent(this->synthesisEventObject);
 }
 
 void COpenJtalkCore::Clear(){
@@ -142,7 +136,7 @@ void COpenJtalkCore::Clear(){
        this->manageFlag = false;
 }
 
-unsigned WINAPI COpenJtalkCore::SynthesisThreadFunction(void *userData){
+void  COpenJtalkCore::SynthesisThreadFunction(void *userData){
 
        auto &self = *(COpenJtalkCore*)userData;
 
@@ -154,24 +148,31 @@ unsigned WINAPI COpenJtalkCore::SynthesisThreadFunction(void *userData){
                dwRslt = ::WaitForMultipleObjects(sizeof(eventList) / sizeof(eventList[0]),eventList,false,INFINITE);
 
                if(dwRslt-  WAIT_OBJECT_0 == 1)break;
+               else if(dwRslt-  WAIT_OBJECT_0 == 0){
+                       CString synthesisString;
+                       SynthesisQueue synthesisQueueCopy;
+                       self.synthesisQueueCS.Lock();
 
-               CString synthesisString;
-
-               self.synthesisQueueCS.Lock();
+                       synthesisQueueCopy = self.synthesisQueue;
+                       self.synthesisQueue.clear();
+                       
 
-               synthesisString = self.synthesisQueue.back();
-               self.synthesisQueue.pop();
+                       self.synthesisQueueCS.Unlock();
 
-               self.synthesisQueueCS.Unlock();
+                       auto rbegin = synthesisQueueCopy.rbegin();
+                       auto rend = synthesisQueueCopy.rend();
 
-               self.Synthesis((const TChar_P)(const wchar_t*)synthesisString);
+                       for(;rbegin != rend;++rbegin){
+                               self.Synthesis((const TChar_P)(const wchar_t*)*rbegin);
+                       }
+               }
 
 
        } while(true);
        
-       _endthreadex(0);
+       _endthread();
 
-       return 0;
+       return ;
 }
 
 }
index 09366ac..15f0478 100644 (file)
@@ -11,11 +11,11 @@ namespace openJtalk{
        class COpenJtalkCore:public ISpeaker{
 
        private:
+               typedef std::deque<CString> SynthesisQueue;
                OpenJTalk openJtalk_internal;           //\93à\95\94\83I\83u\83W\83F\83N\83g
                bool manageFlag;                                        //\8aÇ\97\9d\83t\83\89\83O
                CComAutoCriticalSection synthesisQueueCS;
-               std::queue<CString> synthesisQueue;
-               HANDLE synthesisThreadHandle;           //\93Ç\82Ý\8fã\82°\83X\83\8c\83b\83h\83n\83\93\83h\83\8b
+               SynthesisQueue synthesisQueue;
                HANDLE synthesisEventObject;
                HANDLE endEventObject;
        protected:
@@ -80,7 +80,7 @@ namespace openJtalk{
                ///
                ///\94ñ\93¯\8aú\93Ç\82Ý\8fã\82°\97p\82Ì\83X\83\8c\83b\83h\8aÖ\90\94
                ///
-               static unsigned WINAPI SynthesisThreadFunction(void *userData);
+               static void  SynthesisThreadFunction(void *userData);
        };