From ac498cbc75c4111236fc17098fbfef295fb82d12 Mon Sep 17 00:00:00 2001 From: qwerty2501 Date: Mon, 20 Feb 2012 23:54:52 +0900 Subject: [PATCH] =?utf8?q?=E8=AA=AD=E3=81=BF=E5=8F=96=E3=82=8A=E6=A9=9F?= =?utf8?q?=E8=83=BD=E5=AE=9F=E8=A3=85=E9=80=94=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- nlite.sln | 1 + nlite.suo | Bin 178688 -> 187904 bytes .../libs/Voice/mei_normal/COPYRIGHT.txt | 0 .../{output => }/libs/Voice/mei_normal/README.txt | 0 nlite/{output => }/libs/Voice/mei_normal/dur.pdf | Bin .../{output => }/libs/Voice/mei_normal/gv-lf0.pdf | Bin .../{output => }/libs/Voice/mei_normal/gv-mgc.pdf | Bin .../libs/Voice/mei_normal/gv-switch.inf | 0 nlite/{output => }/libs/Voice/mei_normal/lf0.pdf | Bin nlite/{output => }/libs/Voice/mei_normal/lf0.win1 | 0 nlite/{output => }/libs/Voice/mei_normal/lf0.win2 | 0 nlite/{output => }/libs/Voice/mei_normal/lf0.win3 | 0 nlite/{output => }/libs/Voice/mei_normal/lpf.pdf | Bin nlite/{output => }/libs/Voice/mei_normal/lpf.win1 | 0 nlite/{output => }/libs/Voice/mei_normal/mgc.pdf | Bin nlite/{output => }/libs/Voice/mei_normal/mgc.win1 | 0 nlite/{output => }/libs/Voice/mei_normal/mgc.win2 | 0 nlite/{output => }/libs/Voice/mei_normal/mgc.win3 | 0 .../libs/Voice/mei_normal/tree-dur.inf | 0 .../libs/Voice/mei_normal/tree-gv-lf0.inf | 0 .../libs/Voice/mei_normal/tree-gv-mgc.inf | 0 .../libs/Voice/mei_normal/tree-lf0.inf | 0 .../libs/Voice/mei_normal/tree-lpf.inf | 0 .../libs/Voice/mei_normal/tree-mgc.inf | 0 nlite/libs/open_jtalk_dic/COPYING | 69 ++++ nlite/{output => }/libs/open_jtalk_dic/char.bin | Bin nlite/{output => }/libs/open_jtalk_dic/left-id.def | 0 nlite/{output => }/libs/open_jtalk_dic/matrix.bin | Bin nlite/{output => }/libs/open_jtalk_dic/pos-id.def | 0 nlite/{output => }/libs/open_jtalk_dic/rewrite.def | 0 .../{output => }/libs/open_jtalk_dic/right-id.def | 0 nlite/{output => }/libs/open_jtalk_dic/sys.dic | Bin nlite/{output => }/libs/open_jtalk_dic/unk.dic | Bin nlite/nlite.cpp | 5 +- nlite/nlite.vcxproj | 6 +- nlite/nlite_common.cpp | 2 +- nlite/nlite_common.h | 1 + nlite/nlite_include.h | 1 + nlite/stdafx.h | 4 +- nlite_stub/nlite_stub.vcxproj.filters | 8 +- .../open_jtalk_manager/MMD_AgentDammiy.cpp | 39 ++ .../open_jtalk_manager/MMD_AgentDammiy.h | 10 + open_jtalk_lib/open_jtalk_manager/Open_JTalk.cpp | 425 +++++++++++++++++++++ open_jtalk_lib/open_jtalk_manager/Open_JTalk.h | 131 +++++++ .../open_jtalk_manager/Open_JTalk_Manager.cpp | 356 +++++++++++++++++ .../open_jtalk_manager/Open_JTalk_Manager.h | 116 ++++++ .../open_jtalk_manager/Open_JTalk_Thread.cpp | 398 +++++++++++++++++++ .../open_jtalk_manager/Open_JTalk_Thread.h | 112 ++++++ .../output/libs/Voice/mei_normal/README.txt | 78 ++++ open_jtalk_test/ReadMe.txt | 45 +++ open_jtalk_test/open_jtalk_test.cpp | 14 + open_jtalk_test/open_jtalk_test.vcxproj | 91 +++++ open_jtalk_test/open_jtalk_test.vcxproj.filters | 36 ++ open_jtalk_test/open_jtalk_test.vcxproj.user | 3 + open_jtalk_test/stdafx.cpp | 8 + open_jtalk_test/stdafx.h | 15 + open_jtalk_test/targetver.h | 8 + speaker/mei_normal.cpp | 24 +- speaker/mei_normal.h | 4 +- speaker/open_jtalk_core.cpp | 132 +++++-- speaker/open_jtalk_core.h | 35 +- speaker/speaker.cpp | 15 + speaker/speaker.h | 41 ++ speaker/speaker.vcxproj | 6 +- speaker/speaker.vcxproj.filters | 6 + speaker/speaker_include.h | 3 +- speaker/stdafx.h | 2 + 67 files changed, 2194 insertions(+), 56 deletions(-) rename nlite/{output => }/libs/Voice/mei_normal/COPYRIGHT.txt (100%) rename nlite/{output => }/libs/Voice/mei_normal/README.txt (100%) rename nlite/{output => }/libs/Voice/mei_normal/dur.pdf (100%) rename nlite/{output => }/libs/Voice/mei_normal/gv-lf0.pdf (100%) rename nlite/{output => }/libs/Voice/mei_normal/gv-mgc.pdf (100%) rename nlite/{output => }/libs/Voice/mei_normal/gv-switch.inf (100%) rename nlite/{output => }/libs/Voice/mei_normal/lf0.pdf (100%) rename nlite/{output => }/libs/Voice/mei_normal/lf0.win1 (100%) rename nlite/{output => }/libs/Voice/mei_normal/lf0.win2 (100%) rename nlite/{output => }/libs/Voice/mei_normal/lf0.win3 (100%) rename nlite/{output => }/libs/Voice/mei_normal/lpf.pdf (100%) rename nlite/{output => }/libs/Voice/mei_normal/lpf.win1 (100%) rename nlite/{output => }/libs/Voice/mei_normal/mgc.pdf (100%) rename nlite/{output => }/libs/Voice/mei_normal/mgc.win1 (100%) rename nlite/{output => }/libs/Voice/mei_normal/mgc.win2 (100%) rename nlite/{output => }/libs/Voice/mei_normal/mgc.win3 (100%) rename nlite/{output => }/libs/Voice/mei_normal/tree-dur.inf (100%) rename nlite/{output => }/libs/Voice/mei_normal/tree-gv-lf0.inf (100%) rename nlite/{output => }/libs/Voice/mei_normal/tree-gv-mgc.inf (100%) rename nlite/{output => }/libs/Voice/mei_normal/tree-lf0.inf (100%) rename nlite/{output => }/libs/Voice/mei_normal/tree-lpf.inf (100%) rename nlite/{output => }/libs/Voice/mei_normal/tree-mgc.inf (100%) create mode 100644 nlite/libs/open_jtalk_dic/COPYING rename nlite/{output => }/libs/open_jtalk_dic/char.bin (100%) rename nlite/{output => }/libs/open_jtalk_dic/left-id.def (100%) rename nlite/{output => }/libs/open_jtalk_dic/matrix.bin (100%) rename nlite/{output => }/libs/open_jtalk_dic/pos-id.def (100%) rename nlite/{output => }/libs/open_jtalk_dic/rewrite.def (100%) rename nlite/{output => }/libs/open_jtalk_dic/right-id.def (100%) rename nlite/{output => }/libs/open_jtalk_dic/sys.dic (100%) rename nlite/{output => }/libs/open_jtalk_dic/unk.dic (100%) create mode 100644 open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.cpp create mode 100644 open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.h create mode 100644 open_jtalk_lib/open_jtalk_manager/Open_JTalk.cpp create mode 100644 open_jtalk_lib/open_jtalk_manager/Open_JTalk.h create mode 100644 open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.cpp create mode 100644 open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.h create mode 100644 open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.cpp create mode 100644 open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.h create mode 100644 open_jtalk_lib/output/libs/Voice/mei_normal/README.txt create mode 100644 open_jtalk_test/ReadMe.txt create mode 100644 open_jtalk_test/open_jtalk_test.cpp create mode 100644 open_jtalk_test/open_jtalk_test.vcxproj create mode 100644 open_jtalk_test/open_jtalk_test.vcxproj.filters create mode 100644 open_jtalk_test/open_jtalk_test.vcxproj.user create mode 100644 open_jtalk_test/stdafx.cpp create mode 100644 open_jtalk_test/stdafx.h create mode 100644 open_jtalk_test/targetver.h create mode 100644 speaker/speaker.cpp create mode 100644 speaker/speaker.h diff --git a/nlite.sln b/nlite.sln index 9b86048..966813e 100644 --- a/nlite.sln +++ b/nlite.sln @@ -29,6 +29,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nlite", "nlite\nlite.vcxproj", "{EB0B5264-9BB4-4EE3-B196-A0472DCB32A8}" ProjectSection(ProjectDependencies) = postProject {52AD1F16-FE7F-4915-B97C-38E14BD47D9F} = {52AD1F16-FE7F-4915-B97C-38E14BD47D9F} + {FBE9021E-5717-4EEE-A3AC-E4516C8A29AD} = {FBE9021E-5717-4EEE-A3AC-E4516C8A29AD} {5150C843-E70B-4696-8F08-11B900B7F91F} = {5150C843-E70B-4696-8F08-11B900B7F91F} {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1} = {B651AE6B-6D20-4612-B7C8-5788FC2ADDB1} {7866D782-163E-45F8-A5D0-ABB124B6DAAC} = {7866D782-163E-45F8-A5D0-ABB124B6DAAC} diff --git a/nlite.suo b/nlite.suo index 409e1de02cb6760f98adbd86859d4b4a81767c04..9aaf808ce88bf1ddd337e0b1073a8fc9d53f4e5a 100644 GIT binary patch delta 7749 zcmb7J3tW_C)_>2#%mBkM4g*Yx2s1d|5OEkUkrINEcMXYLEJUs-l3u3Gt(l@YdXS?(Gd+xGco?s?uBF7^Gs{r$d|-}%k^KG*Y{ z^FOx-d%N0x(yu9l1&2tI)RU+ek%=gbXd++4Y6703w{b+{i6#*FH=Dc$0Sw?KMTFLV zZ_k)7zrO@t)REYaFIQYth*$2?M02~pf-h4}=I7M0&F#t*g^!YY#)#gCQWLi*yqj(6 zrxm_16eOuf_vUu(Rh7>pdV+q{8m#bQmB1f_lrrlGzP#r|Uug(U6&!c2*xpmauwp*w zxiL(Sd9Oezcm3U{oJV6G!@ZR-m1n)C6;K02BumQ6!fmY^j0cO7foL{}G zqm{EU`y8yQ=x^k;@9Su8aQC@3-n33jLvLe;Zulzd=br2_; zP&XS?VB@{FPOTVWgS_S!N34N>c3n@z#ebe#4<> zGbEmrHUa;<5;Vk8J?*!WPrGG>b9l3it>-Dd)tIsyRJ>)o3aapfNVbYwwukb_uhY2e ziVsg&=c9arcBtg5`UUgF1>rnA{sfi}W5b%YPcDY$(u4;pDCEC?YO;@>hUtj9wD^=p z$3g)uMpi8NLDxTICfe}KWHy?&4NXQ@wcK(@9G#R<06Jc74dto#D=_5)2;#NFRTyMu zq|T3{uy7HzTpn7Ac||OeTb_)oc&=R)MLV*_<_FJB?Bxps=|j^HsAdm@w{nUvVtumLEDyGRxxT9Lf8#jb>9Lx&mWkleDzk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diff --git a/nlite/output/libs/Voice/mei_normal/COPYRIGHT.txt b/nlite/libs/Voice/mei_normal/COPYRIGHT.txt similarity index 100% rename from nlite/output/libs/Voice/mei_normal/COPYRIGHT.txt rename to nlite/libs/Voice/mei_normal/COPYRIGHT.txt diff --git a/nlite/output/libs/Voice/mei_normal/README.txt b/nlite/libs/Voice/mei_normal/README.txt similarity index 100% rename from nlite/output/libs/Voice/mei_normal/README.txt rename to nlite/libs/Voice/mei_normal/README.txt diff --git a/nlite/output/libs/Voice/mei_normal/dur.pdf b/nlite/libs/Voice/mei_normal/dur.pdf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/dur.pdf rename to nlite/libs/Voice/mei_normal/dur.pdf diff --git a/nlite/output/libs/Voice/mei_normal/gv-lf0.pdf b/nlite/libs/Voice/mei_normal/gv-lf0.pdf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/gv-lf0.pdf rename to nlite/libs/Voice/mei_normal/gv-lf0.pdf diff --git a/nlite/output/libs/Voice/mei_normal/gv-mgc.pdf b/nlite/libs/Voice/mei_normal/gv-mgc.pdf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/gv-mgc.pdf rename to nlite/libs/Voice/mei_normal/gv-mgc.pdf diff --git a/nlite/output/libs/Voice/mei_normal/gv-switch.inf b/nlite/libs/Voice/mei_normal/gv-switch.inf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/gv-switch.inf rename to nlite/libs/Voice/mei_normal/gv-switch.inf diff --git a/nlite/output/libs/Voice/mei_normal/lf0.pdf b/nlite/libs/Voice/mei_normal/lf0.pdf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/lf0.pdf rename to nlite/libs/Voice/mei_normal/lf0.pdf diff --git a/nlite/output/libs/Voice/mei_normal/lf0.win1 b/nlite/libs/Voice/mei_normal/lf0.win1 similarity index 100% rename from nlite/output/libs/Voice/mei_normal/lf0.win1 rename to nlite/libs/Voice/mei_normal/lf0.win1 diff --git a/nlite/output/libs/Voice/mei_normal/lf0.win2 b/nlite/libs/Voice/mei_normal/lf0.win2 similarity index 100% rename from nlite/output/libs/Voice/mei_normal/lf0.win2 rename to nlite/libs/Voice/mei_normal/lf0.win2 diff --git a/nlite/output/libs/Voice/mei_normal/lf0.win3 b/nlite/libs/Voice/mei_normal/lf0.win3 similarity index 100% rename from nlite/output/libs/Voice/mei_normal/lf0.win3 rename to nlite/libs/Voice/mei_normal/lf0.win3 diff --git a/nlite/output/libs/Voice/mei_normal/lpf.pdf b/nlite/libs/Voice/mei_normal/lpf.pdf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/lpf.pdf rename to nlite/libs/Voice/mei_normal/lpf.pdf diff --git a/nlite/output/libs/Voice/mei_normal/lpf.win1 b/nlite/libs/Voice/mei_normal/lpf.win1 similarity index 100% rename from nlite/output/libs/Voice/mei_normal/lpf.win1 rename to nlite/libs/Voice/mei_normal/lpf.win1 diff --git a/nlite/output/libs/Voice/mei_normal/mgc.pdf b/nlite/libs/Voice/mei_normal/mgc.pdf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/mgc.pdf rename to nlite/libs/Voice/mei_normal/mgc.pdf diff --git a/nlite/output/libs/Voice/mei_normal/mgc.win1 b/nlite/libs/Voice/mei_normal/mgc.win1 similarity index 100% rename from nlite/output/libs/Voice/mei_normal/mgc.win1 rename to nlite/libs/Voice/mei_normal/mgc.win1 diff --git a/nlite/output/libs/Voice/mei_normal/mgc.win2 b/nlite/libs/Voice/mei_normal/mgc.win2 similarity index 100% rename from nlite/output/libs/Voice/mei_normal/mgc.win2 rename to nlite/libs/Voice/mei_normal/mgc.win2 diff --git a/nlite/output/libs/Voice/mei_normal/mgc.win3 b/nlite/libs/Voice/mei_normal/mgc.win3 similarity index 100% rename from nlite/output/libs/Voice/mei_normal/mgc.win3 rename to nlite/libs/Voice/mei_normal/mgc.win3 diff --git a/nlite/output/libs/Voice/mei_normal/tree-dur.inf b/nlite/libs/Voice/mei_normal/tree-dur.inf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/tree-dur.inf rename to nlite/libs/Voice/mei_normal/tree-dur.inf diff --git a/nlite/output/libs/Voice/mei_normal/tree-gv-lf0.inf b/nlite/libs/Voice/mei_normal/tree-gv-lf0.inf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/tree-gv-lf0.inf rename to nlite/libs/Voice/mei_normal/tree-gv-lf0.inf diff --git a/nlite/output/libs/Voice/mei_normal/tree-gv-mgc.inf b/nlite/libs/Voice/mei_normal/tree-gv-mgc.inf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/tree-gv-mgc.inf rename to nlite/libs/Voice/mei_normal/tree-gv-mgc.inf diff --git a/nlite/output/libs/Voice/mei_normal/tree-lf0.inf b/nlite/libs/Voice/mei_normal/tree-lf0.inf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/tree-lf0.inf rename to nlite/libs/Voice/mei_normal/tree-lf0.inf diff --git a/nlite/output/libs/Voice/mei_normal/tree-lpf.inf b/nlite/libs/Voice/mei_normal/tree-lpf.inf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/tree-lpf.inf rename to nlite/libs/Voice/mei_normal/tree-lpf.inf diff --git a/nlite/output/libs/Voice/mei_normal/tree-mgc.inf b/nlite/libs/Voice/mei_normal/tree-mgc.inf similarity index 100% rename from nlite/output/libs/Voice/mei_normal/tree-mgc.inf rename to nlite/libs/Voice/mei_normal/tree-mgc.inf diff --git a/nlite/libs/open_jtalk_dic/COPYING b/nlite/libs/open_jtalk_dic/COPYING new file mode 100644 index 0000000..c8b4529 --- /dev/null +++ b/nlite/libs/open_jtalk_dic/COPYING @@ -0,0 +1,69 @@ +Copyright (c) 2009, Nara Institute of Science and Technology, Japan. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +Neither the name of the Nara Institute of Science and Technology +(NAIST) nor the names of its contributors may be used to endorse or +promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* ----------------------------------------------------------------- */ +/* The Japanese TTS System "Open JTalk" */ +/* developed by HTS Working Group */ +/* http://open-jtalk.sourceforge.net/ */ +/* ----------------------------------------------------------------- */ +/* */ +/* Copyright (c) 2008-2011 Nagoya Institute of Technology */ +/* Department of Computer Science */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* - Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* - Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials provided */ +/* with the distribution. */ +/* - Neither the name of the HTS working group nor the names of its */ +/* contributors may be used to endorse or promote products derived */ +/* from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ +/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ +/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ +/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ +/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* ----------------------------------------------------------------- */ diff --git a/nlite/output/libs/open_jtalk_dic/char.bin b/nlite/libs/open_jtalk_dic/char.bin similarity index 100% rename from nlite/output/libs/open_jtalk_dic/char.bin rename to nlite/libs/open_jtalk_dic/char.bin diff --git a/nlite/output/libs/open_jtalk_dic/left-id.def b/nlite/libs/open_jtalk_dic/left-id.def similarity index 100% rename from nlite/output/libs/open_jtalk_dic/left-id.def rename to nlite/libs/open_jtalk_dic/left-id.def diff --git a/nlite/output/libs/open_jtalk_dic/matrix.bin b/nlite/libs/open_jtalk_dic/matrix.bin similarity index 100% rename from nlite/output/libs/open_jtalk_dic/matrix.bin rename to nlite/libs/open_jtalk_dic/matrix.bin diff --git a/nlite/output/libs/open_jtalk_dic/pos-id.def b/nlite/libs/open_jtalk_dic/pos-id.def similarity index 100% rename from nlite/output/libs/open_jtalk_dic/pos-id.def rename to nlite/libs/open_jtalk_dic/pos-id.def diff --git a/nlite/output/libs/open_jtalk_dic/rewrite.def b/nlite/libs/open_jtalk_dic/rewrite.def similarity index 100% rename from nlite/output/libs/open_jtalk_dic/rewrite.def rename to nlite/libs/open_jtalk_dic/rewrite.def diff --git a/nlite/output/libs/open_jtalk_dic/right-id.def b/nlite/libs/open_jtalk_dic/right-id.def similarity index 100% rename from nlite/output/libs/open_jtalk_dic/right-id.def rename to nlite/libs/open_jtalk_dic/right-id.def diff --git a/nlite/output/libs/open_jtalk_dic/sys.dic b/nlite/libs/open_jtalk_dic/sys.dic similarity index 100% rename from nlite/output/libs/open_jtalk_dic/sys.dic rename to nlite/libs/open_jtalk_dic/sys.dic diff --git a/nlite/output/libs/open_jtalk_dic/unk.dic b/nlite/libs/open_jtalk_dic/unk.dic similarity index 100% rename from nlite/output/libs/open_jtalk_dic/unk.dic rename to nlite/libs/open_jtalk_dic/unk.dic diff --git a/nlite/nlite.cpp b/nlite/nlite.cpp index 26a7b35..6935dcf 100644 --- a/nlite/nlite.cpp +++ b/nlite/nlite.cpp @@ -43,10 +43,9 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); } + g_speaker.SynthesisAsync(TEXT("ƒeƒXƒgƒRƒƒ“ƒg")); - - - + //ƒƒbƒZ[ƒWƒ‹[ƒv“o˜^ CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); diff --git a/nlite/nlite.vcxproj b/nlite/nlite.vcxproj index 102b62d..21d5f1f 100644 --- a/nlite/nlite.vcxproj +++ b/nlite/nlite.vcxproj @@ -52,20 +52,20 @@ true - $(solutiondir)\nlib;$(solutiondir)\include\WTL\include;$(solutiondir);$(solutiondir)\include;$(solutiondir)\expat;$(IncludePath) + $(solutiondir)\nlib;$(solutiondir)\include\WTL\include;$(solutiondir);$(solutiondir)\include;$(solutiondir)\expat;$(IncludePath);$(solutiondir)\speaker;$(IncludePath) false true - $(solutiondir)\nlib;$(solutiondir)\include\WTL\include;$(solutiondir);$(solutiondir)\include;$(solutiondir)\expat;$(solutiondir)nlib\;$(solutiondir)memorypool\;$(solutiondir)shareCookie\;$(solutiondir);$(IncludePath) + $(solutiondir)\nlib;$(solutiondir)\include\WTL\include;$(solutiondir);$(solutiondir)\include;$(solutiondir)\expat;$(solutiondir)nlib\;$(solutiondir)memorypool\;$(solutiondir)shareCookie\;$(solutiondir);$(IncludePath);$(solutiondir)\speaker;$(IncludePath) false - $(solutiondir)\nlib;$(solutiondir)\include\WTL\include;$(solutiondir);$(solutiondir)\include;$(solutiondir)\expat;$(WDDK)inc\atl71;$(BOOST);$(IncludePath) + $(solutiondir)\nlib;$(solutiondir)\include\WTL\include;$(solutiondir);$(solutiondir)\include;$(solutiondir)\expat;$(WDDK)inc\atl71;$(BOOST);$(IncludePath);$(solutiondir)\speaker;$(IncludePath) diff --git a/nlite/nlite_common.cpp b/nlite/nlite_common.cpp index cd9293f..c1cb6c6 100644 --- a/nlite/nlite_common.cpp +++ b/nlite/nlite_common.cpp @@ -27,7 +27,7 @@ namespace nlite{ TCHAR appFolderPath[_MAX_PATH]; CString ncvAppSettingPath; TCHAR localAppDataPath[_MAX_PATH]; - + speaker::ISpeaker &g_speaker = speaker::ISpeaker::GetMeiNormal(TEXT("libs\\Voice\\mei_normal\\"),TEXT("libs\\open_jtalk_dic\\")); VOID nlite::UnexpectedErrorMessageShow(LPCTSTR headMessage,LPCTSTR summary,UINT line,LPCTSTR fileName,LPCTSTR function){ CString errLogFilePath(nliteProperty.propertySaveFolderPath); diff --git a/nlite/nlite_common.h b/nlite/nlite_common.h index 0e05fb1..c5e0c45 100644 --- a/nlite/nlite_common.h +++ b/nlite/nlite_common.h @@ -5,6 +5,7 @@ namespace nlite{ //ƒOƒ[ƒoƒ‹•Ï” extern const CApplicationInfo * appInfo; extern CListenerList listenerList; + extern speaker::ISpeaker &g_speaker; extern TCHAR localAppDataPath[]; extern TCHAR appFolderPath[]; extern CString ncvAppSettingPath; diff --git a/nlite/nlite_include.h b/nlite/nlite_include.h index 7357f78..4601db7 100644 --- a/nlite/nlite_include.h +++ b/nlite/nlite_include.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "resource.h" diff --git a/nlite/stdafx.h b/nlite/stdafx.h index 4954d9e..4139959 100644 --- a/nlite/stdafx.h +++ b/nlite/stdafx.h @@ -77,6 +77,6 @@ extern CAppModule _Module; #pragma comment(lib,"atlthunk.lib") #pragma comment(lib,"version.lib") #pragma comment(lib,"Riched20.lib") - - +#pragma comment(lib,"speaker.lib") +#pragma comment(lib,"open_jtalk_lib.lib") diff --git a/nlite_stub/nlite_stub.vcxproj.filters b/nlite_stub/nlite_stub.vcxproj.filters index 785c99e..20a5f14 100644 --- a/nlite_stub/nlite_stub.vcxproj.filters +++ b/nlite_stub/nlite_stub.vcxproj.filters @@ -1,10 +1,6 @@  - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd @@ -13,6 +9,10 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + diff --git a/open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.cpp b/open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.cpp new file mode 100644 index 0000000..3e84b5d --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.cpp @@ -0,0 +1,39 @@ +#include "MMD_AgentDammiy.h" + +#include +#include + +/* MMDFiles_strdup: strdup */ +char *MMDAgent_pathdup(const char *str) +{ + char *buf; + + if(str == NULL) + return NULL; + buf = (char *) malloc(sizeof(char) * (strlen(str) + 1)); + strcpy(buf, str); + + return buf; +} + + +char *MMDAgent_strdup(const char *str) +{ + char *buf; + + if(str == NULL) + return NULL; + buf = (char *) malloc(sizeof(char) * (strlen(str) + 1)); + strcpy(buf, str); + + return buf; +} + + +int MMDAgent_strlen(const char *str) +{ + if(str == NULL) + return 0; + else + return strlen(str); +} diff --git a/open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.h b/open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.h new file mode 100644 index 0000000..8bb4a0a --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/MMD_AgentDammiy.h @@ -0,0 +1,10 @@ +#pragma comment + +#define MMDAGENT_DIRSEPARATOR '\\' + + +extern char *MMDAgent_pathdup(const char *str); + +extern int MMDAgent_strlen(const char *str); + +extern char *MMDAgent_strdup(const char *str); \ No newline at end of file diff --git a/open_jtalk_lib/open_jtalk_manager/Open_JTalk.cpp b/open_jtalk_lib/open_jtalk_manager/Open_JTalk.cpp new file mode 100644 index 0000000..6fcfa3f --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/Open_JTalk.cpp @@ -0,0 +1,425 @@ +/* ----------------------------------------------------------------- */ +/* The Toolkit for Building Voice Interaction Systems */ +/* "MMDAgent" developed by MMDAgent Project Team */ +/* http://www.mmdagent.jp/ */ +/* ----------------------------------------------------------------- */ +/* */ +/* Copyright (c) 2009-2011 Nagoya Institute of Technology */ +/* Department of Computer Science */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* - Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* - Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials provided */ +/* with the distribution. */ +/* - Neither the name of the MMDAgent project team nor the names of */ +/* its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written */ +/* permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ +/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ +/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ +/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ +/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* ----------------------------------------------------------------- */ + +/* headers */ + +#include "MMD_AgentDammiy.h" +#include +#include "mecab.h" +#include "njd.h" +#include "jpcommon.h" +#include "HTS_engine.h" + +#include "text2mecab.h" +#include "mecab2njd.h" +#include "njd2jpcommon.h" + +#include "njd_set_pronunciation.h" +#include "njd_set_digit.h" +#include "njd_set_accent_phrase.h" +#include "njd_set_accent_type.h" +#include "njd_set_unvoiced_vowel.h" +#include "njd_set_long_vowel.h" + +#include "Open_JTalk.h" + + +/* Open_JTalk::initialize: initialize system */ +void Open_JTalk::initialize() +{ + Mecab_initialize(&m_mecab); + NJD_initialize(&m_njd); + JPCommon_initialize(&m_jpcommon); + HTS_Engine_initialize(&m_engine, 3); + + HTS_Engine_set_gamma(&m_engine, OPENJTALK_GAMMA); + HTS_Engine_set_log_gain(&m_engine, OPENJTALK_LOGGAIN); + HTS_Engine_set_sampling_rate(&m_engine, OPENJTALK_SAMPLINGRATE); + HTS_Engine_set_fperiod(&m_engine, OPENJTALK_FPERIOD); + HTS_Engine_set_alpha(&m_engine, OPENJTALK_ALPHA); + HTS_Engine_set_volume(&m_engine, OPENJTALK_VOLUME); + HTS_Engine_set_audio_buff_size(&m_engine, OPENJTALK_AUDIOBUFFSIZE); + + m_f0Shift = OPENJTALK_HALFTONE; + m_numModels = 0; + m_styleWeights = NULL; + m_numStyles = 0; +} + +/* Open_JTalk::clear: free system */ +void Open_JTalk::clear() +{ + Mecab_clear(&m_mecab); + NJD_clear(&m_njd); + JPCommon_clear(&m_jpcommon); + HTS_Engine_clear(&m_engine); + + m_f0Shift = 0.0; + m_numModels = 0; + if (m_styleWeights != NULL) + free(m_styleWeights); + m_styleWeights = NULL; + m_numStyles = 0; +} + +/* Open_JTalk::Open_JTalk: constructor */ +Open_JTalk::Open_JTalk() +{ + initialize(); +} + +/* Open_JTalk::~Open_JTalk: destructor */ +Open_JTalk::~Open_JTalk() +{ + clear(); +} + +/* Open_JTalk::load: load dictionary and models */ +bool Open_JTalk::load(const char *dicDir, char **modelDir, int numModels, double *styleWeights, int numStyles) +{ + int i, j; + + char buff[2048]; + char *dn_mecab; + char **fn_ws_mcp, **fn_ws_lf0, **fn_ws_lpf; + char *fn_gv_switch; + char **fn_ts_dur, **fn_ts_mcp, **fn_ts_lf0, **fn_ts_lpf; + char **fn_ms_dur, **fn_ms_mcp, **fn_ms_lf0, **fn_ms_lpf; + char **fn_ts_gvm, **fn_ts_gvl; + char **fn_ms_gvm, **fn_ms_gvl; + + if (dicDir == NULL || modelDir == NULL || numModels <= 0 || styleWeights == NULL || numStyles <= 0) + return false; + m_numModels = numModels; + m_numStyles = numStyles; + + /* set filenames */ + fn_ws_mcp = (char **) calloc(3, sizeof(char *)); + fn_ws_lf0 = (char **) calloc(3, sizeof(char *)); + fn_ws_lpf = (char **) calloc(1, sizeof(char *)); + fn_ts_dur = (char **) calloc(m_numModels, sizeof(char *)); + fn_ts_mcp = (char **) calloc(m_numModels, sizeof(char *)); + fn_ts_lf0 = (char **) calloc(m_numModels, sizeof(char *)); + fn_ts_lpf = (char **) calloc(m_numModels, sizeof(char *)); + fn_ms_dur = (char **) calloc(m_numModels, sizeof(char *)); + fn_ms_mcp = (char **) calloc(m_numModels, sizeof(char *)); + fn_ms_lf0 = (char **) calloc(m_numModels, sizeof(char *)); + fn_ms_lpf = (char **) calloc(m_numModels, sizeof(char *)); + fn_ts_gvm = (char **) calloc(m_numModels, sizeof(char *)); + fn_ts_gvl = (char **) calloc(m_numModels, sizeof(char *)); + fn_ms_gvm = (char **) calloc(m_numModels, sizeof(char *)); + fn_ms_gvl = (char **) calloc(m_numModels, sizeof(char *)); + + dn_mecab = MMDAgent_pathdup(dicDir); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_MGCWIN1); + fn_ws_mcp[0] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_MGCWIN2); + fn_ws_mcp[1] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_MGCWIN3); + fn_ws_mcp[2] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_LF0WIN1); + fn_ws_lf0[0] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_LF0WIN2); + fn_ws_lf0[1] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_LF0WIN3); + fn_ws_lf0[2] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_LPFWIN1); + fn_ws_lpf[0] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[0], MMDAGENT_DIRSEPARATOR, OPENJTALK_GVSWITCH); + fn_gv_switch = MMDAgent_pathdup(buff); + for (i = 0; i < m_numModels; i++) { + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_DURTREE); + fn_ts_dur[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_MGCTREE); + fn_ts_mcp[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_LF0TREE); + fn_ts_lf0[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_LPFTREE); + fn_ts_lpf[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_DURPDF); + fn_ms_dur[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_MGCPDF); + fn_ms_mcp[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_LF0PDF); + fn_ms_lf0[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_LPFPDF); + fn_ms_lpf[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_MGCGVTREE); + fn_ts_gvm[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_LF0GVTREE); + fn_ts_gvl[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_MGCGVPDF); + fn_ms_gvm[i] = MMDAgent_pathdup(buff); + sprintf(buff, "%s%c%s", modelDir[i], MMDAGENT_DIRSEPARATOR, OPENJTALK_LF0GVPDF); + fn_ms_gvl[i] = MMDAgent_pathdup(buff); + } + + /* load */ + Mecab_load(&m_mecab, dn_mecab); + HTS_Engine_load_duration_from_fn(&m_engine, fn_ms_dur, fn_ts_dur, m_numModels); + HTS_Engine_load_parameter_from_fn(&m_engine, fn_ms_mcp, fn_ts_mcp, fn_ws_mcp, 0, FALSE, 3, m_numModels); + HTS_Engine_load_parameter_from_fn(&m_engine, fn_ms_lf0, fn_ts_lf0, fn_ws_lf0, 1, TRUE, 3, m_numModels); + HTS_Engine_load_parameter_from_fn(&m_engine, fn_ms_lpf, fn_ts_lpf, fn_ws_lpf, 2, FALSE, 1, m_numModels); + HTS_Engine_load_gv_from_fn(&m_engine, fn_ms_gvm, fn_ts_gvm, 0, m_numModels); + HTS_Engine_load_gv_from_fn(&m_engine, fn_ms_gvl, fn_ts_gvl, 1, m_numModels); + HTS_Engine_load_gv_switch_from_fn(&m_engine, fn_gv_switch); + + /* free filenames */ + free(dn_mecab); + for (i = 0; i < 3; i++) { + free(fn_ws_mcp[i]); + free(fn_ws_lf0[i]); + } + for (i = 0; i < 1; i++) { + free(fn_ws_lpf[i]); + } + free(fn_ws_mcp); + free(fn_ws_lf0); + free(fn_ws_lpf); + free(fn_gv_switch); + for (i = 0; i < m_numModels; i++) { + free(fn_ts_dur[i]); + free(fn_ts_mcp[i]); + free(fn_ts_lf0[i]); + free(fn_ts_lpf[i]); + free(fn_ms_dur[i]); + free(fn_ms_mcp[i]); + free(fn_ms_lf0[i]); + free(fn_ms_lpf[i]); + free(fn_ts_gvm[i]); + free(fn_ts_gvl[i]); + free(fn_ms_gvm[i]); + free(fn_ms_gvl[i]); + } + free(fn_ts_dur); + free(fn_ts_mcp); + free(fn_ts_lf0); + free(fn_ts_lpf); + free(fn_ms_dur); + free(fn_ms_mcp); + free(fn_ms_lf0); + free(fn_ms_lpf); + free(fn_ts_gvm); + free(fn_ts_gvl); + free(fn_ms_gvm); + free(fn_ms_gvl); + + /* set style interpolation weight */ + m_styleWeights = (double *) calloc(m_numStyles * (m_numModels * 3 + 4), sizeof(double)); + for (j = 0; j < m_numStyles * (m_numModels * 3 + 4); j++) + m_styleWeights[j] = styleWeights[j]; + + setStyle(0); + return true; +} + +/* Open_JTalk::prepare: text analysis, decision of state durations, and parameter generation */ +void Open_JTalk::prepare(const char *str) +{ + char *buff; + char **label_feature = NULL; + int label_size = 0; + int i; + double f; + + if(m_numStyles <= 0) + return; + + /* text analysis */ + HTS_Engine_set_stop_flag(&m_engine, false); + buff = (char *) calloc(2 * MMDAgent_strlen(str) + 1, sizeof(char)); + text2mecab(buff, str); + Mecab_analysis(&m_mecab, buff); + free(buff); + mecab2njd(&m_njd, Mecab_get_feature(&m_mecab), Mecab_get_size(&m_mecab)); + njd_set_pronunciation(&m_njd); + njd_set_digit(&m_njd); + njd_set_accent_phrase(&m_njd); + njd_set_accent_type(&m_njd); + njd_set_unvoiced_vowel(&m_njd); + njd_set_long_vowel(&m_njd); + njd2jpcommon(&m_jpcommon, &m_njd); + JPCommon_make_label(&m_jpcommon); + if (JPCommon_get_label_size(&m_jpcommon) > 2) { + /* decision of state durations */ + label_feature = JPCommon_get_label_feature(&m_jpcommon); + label_size = JPCommon_get_label_size(&m_jpcommon); + HTS_Engine_load_label_from_string_list(&m_engine, &label_feature[1], label_size - 1); /* skip first silence */ + HTS_Engine_create_sstream(&m_engine); + /* parameter generation */ + if (m_f0Shift != 0.0) { + for (i = 0; i < HTS_Engine_get_total_state(&m_engine); i++) { + f = HTS_Engine_get_state_mean(&m_engine, 1, i, 0); + f += m_f0Shift * log(2.0) / 12; + if (f < OPENJTALK_MINLF0VAL) + f = OPENJTALK_MINLF0VAL; + HTS_Engine_set_state_mean(&m_engine, 1, i, 0, f); + } + } + HTS_Engine_create_pstream(&m_engine); + } +} + +/* Open_JTalk::getPhonemeSequence: get phoneme sequence */ +void Open_JTalk::getPhonemeSequence(char *str) +{ + int i, j, k; + int size; + char **feature; + int nstate; + int fperiod; + int sampling_rate; + char *ch, *start, *end; + + strcpy(str, ""); + + if(m_numStyles <= 0) + return; + + size = JPCommon_get_label_size(&m_jpcommon); + feature = JPCommon_get_label_feature(&m_jpcommon); + nstate = HTS_Engine_get_nstate(&m_engine); + fperiod = HTS_Engine_get_fperiod(&m_engine); + sampling_rate = HTS_Engine_get_sampling_rate(&m_engine); + + if (size <= 2) + return; + + /* skip first and final silence */ + size -= 2; + feature = &feature[1]; + + for (i = 0; i < size; i++) { + if (i > 0) + strcat(str, ","); + /* get phoneme from full-context label */ + start = strchr(feature[i], '-'); + end = strchr(feature[i], '+'); + if (start != NULL && end != NULL) { + for (ch = start + 1; ch != end; ch++) + sprintf(str, "%s%c", str, *ch); + } else { + strcat(str, feature[i]); + } + /* get ms */ + for (j = 0, k = 0; j < nstate; j++) + k += (HTS_Engine_get_state_duration(&m_engine, i * nstate + j) * fperiod * 1000) / sampling_rate; + sprintf(str, "%s,%d", str, k); + } +} + +/* Open_JTalk::synthesis: speech synthesis */ +void Open_JTalk::synthesis() +{ + if(m_numStyles <= 0) + return; + if (JPCommon_get_label_size(&m_jpcommon) > 2) { + HTS_Engine_create_gstream(&m_engine); + HTS_Engine_refresh(&m_engine); + } + JPCommon_refresh(&m_jpcommon); + NJD_refresh(&m_njd); + Mecab_refresh(&m_mecab); +} + +/* Open_JTalk::stop: stop speech synthesis */ +void Open_JTalk::stop() +{ + if(m_numStyles <= 0) + return; + HTS_Engine_set_stop_flag(&m_engine, TRUE); +} + +/* Open_JTalk::setStyle: set style interpolation weight */ +bool Open_JTalk::setStyle(int val) +{ + int i, index; + double f; + + if (m_numStyles <= 0 || m_styleWeights == NULL || val < 0 || val >= m_numStyles) + return false; + + index = val * (m_numModels * 3 + 4); + for (i = 0; i < m_numModels; i++) + HTS_Engine_set_parameter_interpolation_weight(&m_engine, 0, i, m_styleWeights[index + m_numModels * 0 + i]); + for (i = 0; i < m_numModels; i++) + HTS_Engine_set_parameter_interpolation_weight(&m_engine, 1, i, m_styleWeights[index + m_numModels * 1 + i]); + for (i = 0; i < m_numModels; i++) + HTS_Engine_set_duration_interpolation_weight(&m_engine, i, m_styleWeights[index + m_numModels * 2 + i]); + + /* speed */ + f = OPENJTALK_FPERIOD / m_styleWeights[index + m_numModels * 3 + 0]; + if(f > OPENJTALK_MAXFPERIOD) + HTS_Engine_set_fperiod(&m_engine, OPENJTALK_MAXFPERIOD); + else if(f < OPENJTALK_MINFPERIOD) + HTS_Engine_set_fperiod(&m_engine, OPENJTALK_MINFPERIOD); + else + HTS_Engine_set_fperiod(&m_engine, (int) f); + + /* pitch */ + f = m_styleWeights[index + m_numModels * 3 + 1]; + if(f > OPENJTALK_MAXHALFTONE) + m_f0Shift = OPENJTALK_MAXHALFTONE; + else if(f < OPENJTALK_MINHALFTONE) + m_f0Shift = OPENJTALK_MINHALFTONE; + else + m_f0Shift = f; + + /* alpha */ + f = m_styleWeights[index + m_numModels * 3 + 2]; + if(f > OPENJTALK_MAXALPHA) + HTS_Engine_set_alpha(&m_engine, OPENJTALK_MAXALPHA); + else if(f < OPENJTALK_MINALPHA) + HTS_Engine_set_alpha(&m_engine, OPENJTALK_MINALPHA); + else + HTS_Engine_set_alpha(&m_engine, f); + + /* volume */ + f = m_styleWeights[index + m_numModels * 3 + 3]; + if(f > OPENJTALK_MAXVOLUME) + HTS_Engine_set_volume(&m_engine, OPENJTALK_MAXVOLUME); + else if(f < OPENJTALK_MINVOLUME) + HTS_Engine_set_volume(&m_engine, OPENJTALK_MINVOLUME); + else + HTS_Engine_set_volume(&m_engine, f); + + return true; +} diff --git a/open_jtalk_lib/open_jtalk_manager/Open_JTalk.h b/open_jtalk_lib/open_jtalk_manager/Open_JTalk.h new file mode 100644 index 0000000..4bcca97 --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/Open_JTalk.h @@ -0,0 +1,131 @@ +/* ----------------------------------------------------------------- */ +/* The Toolkit for Building Voice Interaction Systems */ +/* "MMDAgent" developed by MMDAgent Project Team */ +/* http://www.mmdagent.jp/ */ +/* ----------------------------------------------------------------- */ +/* */ +/* Copyright (c) 2009-2011 Nagoya Institute of Technology */ +/* Department of Computer Science */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* - Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* - Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials provided */ +/* with the distribution. */ +/* - Neither the name of the MMDAgent project team nor the names of */ +/* its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written */ +/* permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ +/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ +/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ +/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ +/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* ----------------------------------------------------------------- */ + +/* definitions */ + +#define OPENJTALK_MGCWIN1 "mgc.win1" +#define OPENJTALK_MGCWIN2 "mgc.win2" +#define OPENJTALK_MGCWIN3 "mgc.win3" +#define OPENJTALK_LF0WIN1 "lf0.win1" +#define OPENJTALK_LF0WIN2 "lf0.win2" +#define OPENJTALK_LF0WIN3 "lf0.win3" +#define OPENJTALK_LPFWIN1 "lpf.win1" +#define OPENJTALK_GVSWITCH "gv-switch.inf" +#define OPENJTALK_DURTREE "tree-dur.inf" +#define OPENJTALK_MGCTREE "tree-mgc.inf" +#define OPENJTALK_LF0TREE "tree-lf0.inf" +#define OPENJTALK_LPFTREE "tree-lpf.inf" +#define OPENJTALK_DURPDF "dur.pdf" +#define OPENJTALK_MGCPDF "mgc.pdf" +#define OPENJTALK_LF0PDF "lf0.pdf" +#define OPENJTALK_LPFPDF "lpf.pdf" +#define OPENJTALK_MGCGVTREE "tree-gv-mgc.inf" +#define OPENJTALK_LF0GVTREE "tree-gv-lf0.inf" +#define OPENJTALK_MGCGVPDF "gv-mgc.pdf" +#define OPENJTALK_LF0GVPDF "gv-lf0.pdf" + +#define OPENJTALK_MINLF0VAL log(10.0) + +#define OPENJTALK_GAMMA 0 +#define OPENJTALK_LOGGAIN false +#define OPENJTALK_SAMPLINGRATE 48000 +#define OPENJTALK_FPERIOD 240 +#define OPENJTALK_HALFTONE 0.0 +#define OPENJTALK_ALPHA 0.55 +#define OPENJTALK_VOLUME 1.0 +#define OPENJTALK_AUDIOBUFFSIZE 4800 + +#define OPENJTALK_MAXFPERIOD 48000 +#define OPENJTALK_MINFPERIOD 1 +#define OPENJTALK_MAXHALFTONE 24.0 +#define OPENJTALK_MINHALFTONE -24.0 +#define OPENJTALK_MAXALPHA 1.0 +#define OPENJTALK_MINALPHA 0.0 +#define OPENJTALK_MAXVOLUME 10.0 +#define OPENJTALK_MINVOLUME 0.0 + +/* Open_JTalk: Japanese TTS system */ +class Open_JTalk +{ +private: + + Mecab m_mecab; /* text analyzer */ + NJD m_njd; /* container for Naist Japanese Dictionary */ + JPCommon m_jpcommon; /* dictionary-independent container */ + HTS_Engine m_engine; /* speech synthesizer */ + + double m_f0Shift; /* pitch parameter */ + int m_numModels; /* number of models */ + double *m_styleWeights; /* weights of speaking styles */ + int m_numStyles; /* number of speaking styles */ + + /* initialize: initialize system */ + void initialize(); + + /* clear: free system */ + void clear(); + +public: + + /* Open_JTalk: constructor */ + Open_JTalk(); + + /* ~Open_JTalk: destructor */ + ~Open_JTalk(); + + /* load: load dictionary and models */ + bool load(const char *dicDir, char **modelDir, int numModels, double *styleWeights, int numStyles); + + /* prepare: text analysis, decision of state durations, and parameter generation */ + void prepare(const char *str); + + /* getPhonemeSequence: get phoneme sequence */ + void getPhonemeSequence(char *str); + + /* synthesis: speech synthesis */ + void synthesis(); + + /* stop: stop speech synthesis */ + void stop(); + + /* setStyle: set style interpolation weight */ + bool setStyle(int val); +}; diff --git a/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.cpp b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.cpp new file mode 100644 index 0000000..e8ebcce --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.cpp @@ -0,0 +1,356 @@ +/* ----------------------------------------------------------------- */ +/* The Toolkit for Building Voice Interaction Systems */ +/* "MMDAgent" developed by MMDAgent Project Team */ +/* http://www.mmdagent.jp/ */ +/* ----------------------------------------------------------------- */ +/* */ +/* Copyright (c) 2009-2011 Nagoya Institute of Technology */ +/* Department of Computer Science */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* - Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* - Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials provided */ +/* with the distribution. */ +/* - Neither the name of the MMDAgent project team nor the names of */ +/* its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written */ +/* permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ +/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ +/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ +/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ +/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* ----------------------------------------------------------------- */ + +/* headers */ + +#include "MMD_AgentDammiy.h" + +#include "mecab.h" +#include "njd.h" +#include "jpcommon.h" +#include "HTS_engine.h" + +#include "text2mecab.h" +#include "mecab2njd.h" +#include "njd2jpcommon.h" + +#include "njd_set_pronunciation.h" +#include "njd_set_digit.h" +#include "njd_set_accent_phrase.h" +#include "njd_set_accent_type.h" +#include "njd_set_unvoiced_vowel.h" +#include "njd_set_long_vowel.h" + +#include "Open_JTalk.h" +#include "Open_JTalk_Thread.h" +#include "Open_JTalk_Manager.h" + +/* Open_JTalk_Event_initialize: initialize input message buffer */ +static void Open_JTalk_Event_initialize(Open_JTalk_Event *e, const char *str) +{ + if (str != NULL) + e->event = MMDAgent_strdup(str); + else + e->event = NULL; + e->next = NULL; +} + +/* Open_JTalk_Event_clear: free input message buffer */ +static void Open_JTalk_Event_clear(Open_JTalk_Event *e) +{ + if (e->event != NULL) + free(e->event); + Open_JTalk_Event_initialize(e, NULL); +} + +/* Open_JTalk_EventQueue_initialize: initialize queue */ +static void Open_JTalk_EventQueue_initialize(Open_JTalk_EventQueue *q) +{ + q->head = NULL; + q->tail = NULL; +} + +/* Open_JTalk_EventQueue_clear: free queue */ +static void Open_JTalk_EventQueue_clear(Open_JTalk_EventQueue *q) +{ + Open_JTalk_Event *tmp1, *tmp2; + + for (tmp1 = q->head; tmp1 != NULL; tmp1 = tmp2) { + tmp2 = tmp1->next; + Open_JTalk_Event_clear(tmp1); + free(tmp1); + } + Open_JTalk_EventQueue_initialize(q); +} + +/* Open_JTalk_EventQueue_enqueue: enqueue */ +static void Open_JTalk_EventQueue_enqueue(Open_JTalk_EventQueue *q, const char *str) +{ + if(MMDAgent_strlen(str) <= 0) + return; + + if (q->tail == NULL) { + q->tail = (Open_JTalk_Event *) calloc(1, sizeof (Open_JTalk_Event)); + Open_JTalk_Event_initialize(q->tail, str); + q->head = q->tail; + } else { + q->tail->next = (Open_JTalk_Event *) calloc(1, sizeof (Open_JTalk_Event)); + Open_JTalk_Event_initialize(q->tail->next, str); + q->tail = q->tail->next; + } +} + +/* Open_JTalk_EventQueue_dequeue: dequeue */ +static void Open_JTalk_EventQueue_dequeue(Open_JTalk_EventQueue *q, char **str) +{ + Open_JTalk_Event *tmp; + + if (q->head == NULL) { + *str = NULL; + return; + } + *str = MMDAgent_strdup(q->head->event); + + tmp = q->head->next; + Open_JTalk_Event_clear(q->head); + free(q->head); + q->head = tmp; + if (tmp == NULL) + q->tail = NULL; +} + +/* mainThread: main thread */ +static void mainThread(void *param) +{ + Open_JTalk_Manager *open_jtalk_manager = (Open_JTalk_Manager *) param; + open_jtalk_manager->run(); +} + +/* Open_JTalk_Manager::initialize: initialize */ +void Open_JTalk_Manager::initialize() +{ + m_mmdagent = NULL; + + m_mutex = NULL; + m_cond = NULL; + m_thread = -1; + + m_count = 0; + + m_list = NULL; + + m_dicDir = NULL; + m_config = NULL; + + m_kill = false; + + Open_JTalk_EventQueue_initialize(&m_bufferQueue); +} + +/* Open_JTalk_Manager::clear clear */ +void Open_JTalk_Manager::clear() +{ + Open_JTalk_Link *tmp1, *tmp2; + + m_kill = true; + + /* stop and release all thread */ + for(tmp1 = m_list; tmp1; tmp1 = tmp2) { + tmp2 = tmp1->next; + tmp1->open_jtalk_thread.stopAndRelease(); + delete tmp1; + } + + /* wait */ + if(m_cond != NULL) + glfwSignalCond(m_cond); + + if(m_mutex != NULL || m_cond != NULL || m_thread >= 0) { + if(m_thread >= 0) { + glfwWaitThread(m_thread, GLFW_WAIT); + glfwDestroyThread(m_thread); + } + if(m_cond != NULL) + glfwDestroyCond(m_cond); + if(m_mutex != NULL) + glfwDestroyMutex(m_mutex); + glfwTerminate(); + } + + if(m_dicDir) + free(m_dicDir); + if(m_config) + free(m_config); + + Open_JTalk_EventQueue_clear(&m_bufferQueue); + + initialize(); +} + +/* Open_JTalk_Manager::Open_JTalk_Manager: constructor */ +Open_JTalk_Manager::Open_JTalk_Manager() +{ + initialize(); +} + +/* Open_JTalk_Manager::~Open_JTalk_Manager: destructor */ +Open_JTalk_Manager::~Open_JTalk_Manager() +{ + clear(); +} + +/* Open_JTalk_Manager::loadAndStart: load and start thread */ +void Open_JTalk_Manager::loadAndStart(MMDAgent *mmdagent, const char *dicDir, const char *config) +{ + clear(); + + m_mmdagent = mmdagent; + m_dicDir = MMDAgent_strdup(dicDir); + m_config = MMDAgent_strdup(config); + + if(m_mmdagent == NULL || m_dicDir == NULL || m_config == NULL) { + clear(); + return; + } + + glfwInit(); + m_mutex = glfwCreateMutex(); + m_cond = glfwCreateCond(); + m_thread = glfwCreateThread(mainThread, this); + if(m_mutex == NULL || m_cond == NULL || m_thread < 0) { + clear(); + return; + } +} + +/* Open_JTalk_Manager::stopAndRelease: stop and release thread */ +void Open_JTalk_Manager::stopAndRelease() +{ + clear(); +} + +/* Open_JTalk_Manager::run: main loop */ +void Open_JTalk_Manager::run() +{ + int i; + Open_JTalk_Link *link; + char *buff, *save; + char *chara, *style, *text; + bool ret = true; + + /* create initial threads */ + for(i = 0; i < OPENJTALKMANAGER_INITIALNTHREAD; i++) { + link = new Open_JTalk_Link; + if(link->open_jtalk_thread.loadAndStart(m_mmdagent, m_dicDir, m_config) == false) + ret = false; + link->next = m_list; + m_list = link; + } + + if(ret == false) + return; + + while(m_kill == false) { + glfwLockMutex(m_mutex); + while(m_count <= 0) { + glfwWaitCond(m_cond, m_mutex, GLFW_INFINITY); + if(m_kill == true) + return; + } + Open_JTalk_EventQueue_dequeue(&m_bufferQueue, &buff); + m_count--; + glfwUnlockMutex(m_mutex); + + if(buff != NULL) { + chara = MMDAgent_strtok(buff, "|", &save); + style = MMDAgent_strtok(NULL, "|", &save); + text = MMDAgent_strtok(NULL, "|", &save); + + if(chara != NULL && style != NULL && text != NULL) { + /* check character */ + for(i = 0, link = m_list; link; link = link->next, i++) + if(link->open_jtalk_thread.checkCharacter(chara) == true) + break; + if(link) { + if(link->open_jtalk_thread.isSpeaking() == true) + link->open_jtalk_thread.stop(); /* if the same character is speaking, stop immediately */ + } else { + for(i = 0, link = m_list; link; link = link->next, i++) + if(link->open_jtalk_thread.isRunning() == true && link->open_jtalk_thread.isSpeaking() == false) + break; + if(link == NULL) { + link = new Open_JTalk_Link; + link->open_jtalk_thread.loadAndStart(m_mmdagent, m_dicDir, m_config); + link->next = m_list; + m_list = link; + } + } + /* set */ + link->open_jtalk_thread.synthesis(chara, style, text); + } + free(buff); /* free buffer */ + } + } +} + +/* Open_JTalk_Manager::isRunning: check running */ +bool Open_JTalk_Manager::isRunning() +{ + if(m_kill == true || m_mutex == NULL || m_cond == NULL || m_thread < 0) + return false; + else + return true; +} + +/* Open_JTalk_Manager::synthesis: start synthesis */ +void Open_JTalk_Manager::synthesis(const char *str) +{ + /* check */ + if(isRunning() == false || MMDAgent_strlen(str) <= 0) + return; + + /* wait buffer mutex */ + glfwLockMutex(m_mutex); + + /* enqueue character name, speaking style, and text */ + Open_JTalk_EventQueue_enqueue(&m_bufferQueue, str); + m_count++; + + /* start synthesis event */ + if(m_count <= 1) + glfwSignalCond(m_cond); + + /* release buffer mutex */ + glfwUnlockMutex(m_mutex); +} + +/* Open_JTalk_Manager::stop: stop synthesis */ +void Open_JTalk_Manager::stop(const char *str) +{ + Open_JTalk_Link *link; + + for(link = m_list; link; link = link->next) { + if(link->open_jtalk_thread.checkCharacter(str)) { + link->open_jtalk_thread.stop(); + return; + } + } +} diff --git a/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.h b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.h new file mode 100644 index 0000000..43230d0 --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Manager.h @@ -0,0 +1,116 @@ +/* ----------------------------------------------------------------- */ +/* The Toolkit for Building Voice Interaction Systems */ +/* "MMDAgent" developed by MMDAgent Project Team */ +/* http://www.mmdagent.jp/ */ +/* ----------------------------------------------------------------- */ +/* */ +/* Copyright (c) 2009-2011 Nagoya Institute of Technology */ +/* Department of Computer Science */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* - Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* - Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials provided */ +/* with the distribution. */ +/* - Neither the name of the MMDAgent project team nor the names of */ +/* its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written */ +/* permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ +/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ +/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ +/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ +/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* ----------------------------------------------------------------- */ + +/* definitions */ + +#define OPENJTALKMANAGER_INITIALNTHREAD 1 /* initial number of thread */ + +/* Open_JTalk_Link: thread list for Open JTalk */ +typedef struct _Open_JTalk_Link { + Open_JTalk_Thread open_jtalk_thread; + struct _Open_JTalk_Link *next; +} Open_JTalk_Link; + +/* Open_JTalk_Event: input message buffer */ +typedef struct _Open_JTalk_Event { + char *event; + struct _Open_JTalk_Event *next; +} Open_JTalk_Event; + +/* Open_JTalk_EventQueue: queue of Open_JTalk_Event */ +typedef struct _Open_JTalk_EventQueue { + Open_JTalk_Event *head; + Open_JTalk_Event *tail; +} Open_JTalk_EventQueue; + +/* Open_JTalk_Manager: multi thread manager for Open JTalk */ +class Open_JTalk_Manager +{ +private: + + MMDAgent *m_mmdagent; + + GLFWmutex m_mutex; + GLFWcond m_cond; + GLFWthread m_thread; + + int m_count; + + bool m_kill; + + Open_JTalk_EventQueue m_bufferQueue; + Open_JTalk_Link *m_list; + + char *m_dicDir; + char *m_config; + + /* initialize: initialize */ + void initialize(); + + /* clear: clear */ + void clear(); + +public: + + /* Open_JTalk_Manager: constructor */ + Open_JTalk_Manager(); + + /* ~Open_JTalk_Manager: destructor */ + ~Open_JTalk_Manager(); + + /* loadAndStart: load and start thread */ + void loadAndStart(MMDAgent *mmdagent, const char *dicDir, const char *config); + + /* stopAndRelease: stop and release thread */ + void stopAndRelease(); + + /* run: main loop */ + void run(); + + /* isRunning: check running */ + bool isRunning(); + + /* synthesis: start synthesis */ + void synthesis(const char *str); + + /* stop: stop synthesis */ + void stop(const char *str); +}; diff --git a/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.cpp b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.cpp new file mode 100644 index 0000000..d7228a9 --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.cpp @@ -0,0 +1,398 @@ +/* ----------------------------------------------------------------- */ +/* The Toolkit for Building Voice Interaction Systems */ +/* "MMDAgent" developed by MMDAgent Project Team */ +/* http://www.mmdagent.jp/ */ +/* ----------------------------------------------------------------- */ +/* */ +/* Copyright (c) 2009-2011 Nagoya Institute of Technology */ +/* Department of Computer Science */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* - Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* - Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials provided */ +/* with the distribution. */ +/* - Neither the name of the MMDAgent project team nor the names of */ +/* its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written */ +/* permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ +/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ +/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ +/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ +/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* ----------------------------------------------------------------- */ + +/* headers */ + +#include + +#include "MMD_AgentDammiy.h" + +#include "mecab.h" +#include "njd.h" +#include "jpcommon.h" +#include "HTS_engine.h" + +#include "text2mecab.h" +#include "mecab2njd.h" +#include "njd2jpcommon.h" + +#include "njd_set_pronunciation.h" +#include "njd_set_digit.h" +#include "njd_set_accent_phrase.h" +#include "njd_set_accent_type.h" +#include "njd_set_unvoiced_vowel.h" +#include "njd_set_long_vowel.h" + +#include "Open_JTalk.h" +#include "Open_JTalk_Thread.h" + +/* mainThread: main thread */ +static void mainThread(void *param) +{ + Open_JTalk_Thread *open_jtalk_thread = (Open_JTalk_Thread *) param; + open_jtalk_thread->run(); +} + +/* Open_JTalk_Thread::initialize: initialize thread */ +void Open_JTalk_Thread::initialize() +{ + m_mmdagent = NULL; + + m_mutex = NULL; + m_cond = NULL; + m_thread = -1; + + m_count = 0; + + m_speaking = false; + m_kill = false; + + m_charaBuff = NULL; + m_styleBuff = NULL; + m_textBuff = NULL; + + m_numModels = 0; + m_modelNames = NULL; + m_numStyles = 0; + m_styleNames = NULL; +} + +/* Open_JTalk_Thread::clear: free thread */ +void Open_JTalk_Thread::clear() +{ + int i; + + stop(); + m_kill = true; + + /* wait */ + if (m_cond != NULL) + glfwSignalCond(m_cond); + + if(m_mutex != NULL || m_cond != NULL || m_thread >= 0) { + if(m_thread >= 0) { + glfwWaitThread(m_thread, GLFW_WAIT); + glfwDestroyThread(m_thread); + } + if(m_cond != NULL) + glfwDestroyCond(m_cond); + if(m_mutex != NULL) + glfwDestroyMutex(m_mutex); + glfwTerminate(); + } + + if(m_charaBuff) free(m_charaBuff); + if(m_styleBuff) free(m_styleBuff); + if(m_textBuff) free(m_textBuff); + + /* free model names */ + if (m_numModels > 0) { + for (i = 0; i < m_numModels; i++) + free(m_modelNames[i]); + free(m_modelNames); + } + + /* free style names */ + if (m_numStyles > 0) { + for (i = 0; i < m_numStyles; i++) + free(m_styleNames[i]); + free(m_styleNames); + } + + initialize(); +} + +/* Open_JTalk_Thread::Open_JTalk_Thread: thread constructor */ +Open_JTalk_Thread::Open_JTalk_Thread() +{ + initialize(); +} + +/* Open_JTalk_Thread::~Open_JTalk_Thread: thread destructor */ +Open_JTalk_Thread::~Open_JTalk_Thread() +{ + clear(); +} + +/* Open_JTalk_Thread::loadAndStart: load models and start thread */ +bool Open_JTalk_Thread::loadAndStart(MMDAgent *mmdagent, const char *dicDir, const char *config) +{ + int i, j, k; + char buff[MMDAGENT_MAXBUFLEN]; + FILE *fp; + bool err = false; + double *weights; + + /* load config file */ + fp = MMDAgent_fopen(config, "r"); + if (fp == NULL) + return false; + + /* number of speakers */ + i = MMDAgent_fgettoken(fp, buff); + if (i <= 0) { + fclose(fp); + clear(); + return false; + } + m_numModels = MMDAgent_str2int(buff); + if (m_numModels <= 0) { + fclose(fp); + clear(); + return false; + } + + /* model directory names */ + m_modelNames = (char **) malloc(sizeof(char *) * m_numModels); + for (i = 0; i < m_numModels; i++) { + j = MMDAgent_fgettoken(fp, buff); + if (j <= 0) + err = true; + m_modelNames[i] = MMDAgent_strdup(buff); + } + if (err) { + fclose(fp); + clear(); + return false; + } + + /* number of speaking styles */ + i = MMDAgent_fgettoken(fp, buff); + if (i <= 0) { + fclose(fp); + clear(); + return false; + } + m_numStyles = MMDAgent_str2int(buff); + if (m_numStyles <= 0) { + m_numStyles = 0; + fclose(fp); + clear(); + return false; + } + + /* style names and weights */ + m_styleNames = (char **) calloc(m_numStyles, sizeof(char *)); + weights = (double *) calloc((3 * m_numModels + 4) * m_numStyles, sizeof(double)); + for (i = 0; i < m_numStyles; i++) { + j = MMDAgent_fgettoken(fp, buff); + if(j <= 0) + err = true; + m_styleNames[i] = MMDAgent_strdup(buff); + for (j = 0; j < 3 * m_numModels + 4; j++) { + k = MMDAgent_fgettoken(fp, buff); + if (k <= 0) + err = true; + weights[(3 * m_numModels + 4) * i + j] = MMDAgent_str2float(buff); + } + } + fclose(fp); + if(err) { + free(weights); + clear(); + return false; + } + + /* load models for TTS */ + if (m_openJTalk.load(dicDir, m_modelNames, m_numModels, weights, m_numStyles) != true) { + free(weights); + clear(); + return false; + } + setlocale(LC_CTYPE, "japanese"); + + free(weights); + + m_mmdagent = mmdagent; + + /* start thread */ + glfwInit(); + m_mutex = glfwCreateMutex(); + m_cond = glfwCreateCond(); + m_thread = glfwCreateThread(mainThread, this); + if(m_mutex == NULL || m_cond == NULL || m_thread < 0) { + clear(); + return false; + } + + return true; +} + +/* Open_JTalk_Thread::stopAndRelease: stop thread and free Open JTalk */ +void Open_JTalk_Thread::stopAndRelease() +{ + clear(); +} + +/* Open_JTalk_Thread::run: main thread loop for TTS */ +void Open_JTalk_Thread::run() +{ + char lip[MMDAGENT_MAXBUFLEN]; + char *chara, *style, *text; + int index; + + while (m_kill == false) { + /* wait text */ + glfwLockMutex(m_mutex); + while(m_count <= 0) { + glfwWaitCond(m_cond, m_mutex, GLFW_INFINITY); + if(m_kill == true) + return; + } + chara = MMDAgent_strdup(m_charaBuff); + style = MMDAgent_strdup(m_styleBuff); + text = MMDAgent_strdup(m_textBuff); + m_count--; + glfwUnlockMutex(m_mutex); + + m_speaking = true; + + /* search style index */ + for (index = 0; index < m_numStyles; index++) + if (MMDAgent_strequal(m_styleNames[index], style)) + break; + if (index >= m_numStyles) /* unknown style */ + index = 0; + + /* send SYNTH_EVENT_START */ + m_mmdagent->sendEventMessage(OPENJTALKTHREAD_EVENTSTART, chara); + + /* synthesize */ + m_openJTalk.setStyle(index); + m_openJTalk.prepare(text); + m_openJTalk.getPhonemeSequence(lip); + if (MMDAgent_strlen(lip) > 0) { + m_mmdagent->sendCommandMessage(OPENJTALKTHREAD_COMMANDSTARTLIP, "%s|%s", chara, lip); + m_openJTalk.synthesis(); + } + + /* send SYNTH_EVENT_STOP */ + m_mmdagent->sendEventMessage(OPENJTALKTHREAD_EVENTSTOP, chara); + + if(chara) free(chara); + if(style) free(style); + if(text) free(text); + m_speaking = false; + } +} + +/* Open_JTalk_Thread::isRunning: check running */ +bool Open_JTalk_Thread::isRunning() +{ + if(m_kill == true || m_mutex == NULL || m_cond == NULL || m_thread < 0) + return false; + else + return true; +} + +/* Open_JTalk_Thread::isSpeaking: check speaking */ +bool Open_JTalk_Thread::isSpeaking() +{ + return m_speaking; +} + +/* checkCharacter: check speaking character */ +bool Open_JTalk_Thread::checkCharacter(const char *chara) +{ + bool ret; + + /* check */ + if(isRunning() == false) + return false; + + /* wait buffer mutex */ + glfwLockMutex(m_mutex); + + /* save character name, speaking style, and text */ + ret = MMDAgent_strequal(m_charaBuff, chara); + + /* release buffer mutex */ + glfwUnlockMutex(m_mutex); + + return ret; +} + +/* Open_JTalk_Thread::synthesis: start synthesis */ +void Open_JTalk_Thread::synthesis(const char *chara, const char *style, const char *text) +{ + /* check */ + if(isRunning() == false) + return; + if(MMDAgent_strlen(chara) <= 0 || MMDAgent_strlen(style) <= 0 || MMDAgent_strlen(text) <= 0) + return; + + /* wait buffer mutex */ + glfwLockMutex(m_mutex); + + /* save character name, speaking style, and text */ + if(m_charaBuff) free(m_charaBuff); + if(m_styleBuff) free(m_styleBuff); + if(m_textBuff) free(m_textBuff); + m_charaBuff = MMDAgent_strdup(chara); + m_styleBuff = MMDAgent_strdup(style); + m_textBuff = MMDAgent_strdup(text); + m_count++; + + /* start synthesis thread */ + if(m_count <= 1) + glfwSignalCond(m_cond); + + /* release buffer mutex */ + glfwUnlockMutex(m_mutex); +} + +/* Open_JTalk_Thread::stop: barge-in function */ +void Open_JTalk_Thread::stop() +{ + if(isRunning() == true) { + m_openJTalk.stop(); + + /* wait buffer mutex */ + glfwLockMutex(m_mutex); + + /* stop lip sync */ + m_mmdagent->sendCommandMessage(OPENJTALKTHREAD_COMMANDSTOPLIP, m_charaBuff); + + /* release buffer mutex */ + glfwUnlockMutex(m_mutex); + + } +} diff --git a/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.h b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.h new file mode 100644 index 0000000..f351b77 --- /dev/null +++ b/open_jtalk_lib/open_jtalk_manager/Open_JTalk_Thread.h @@ -0,0 +1,112 @@ +/* ----------------------------------------------------------------- */ +/* The Toolkit for Building Voice Interaction Systems */ +/* "MMDAgent" developed by MMDAgent Project Team */ +/* http://www.mmdagent.jp/ */ +/* ----------------------------------------------------------------- */ +/* */ +/* Copyright (c) 2009-2011 Nagoya Institute of Technology */ +/* Department of Computer Science */ +/* */ +/* All rights reserved. */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* - Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* - Redistributions in binary form must reproduce the above */ +/* copyright notice, this list of conditions and the following */ +/* disclaimer in the documentation and/or other materials provided */ +/* with the distribution. */ +/* - Neither the name of the MMDAgent project team nor the names of */ +/* its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written */ +/* permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ +/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ +/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ +/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ +/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ +/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ +/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ +/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ +/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ +/* ----------------------------------------------------------------- */ + +/* definitions */ + +#define OPENJTALKTHREAD_EVENTSTART "SYNTH_EVENT_START" +#define OPENJTALKTHREAD_EVENTSTOP "SYNTH_EVENT_STOP" +#define OPENJTALKTHREAD_COMMANDSTARTLIP "LIPSYNC_START" +#define OPENJTALKTHREAD_COMMANDSTOPLIP "LIPSYNC_STOP" + +/* Open_JTalk_Thread: thread for Open JTalk */ +class Open_JTalk_Thread +{ +private: + + MMDAgent *m_mmdagent; + + GLFWmutex m_mutex; + GLFWcond m_cond; + GLFWthread m_thread; + + int m_count; + + bool m_speaking; + bool m_kill; + + char *m_charaBuff; + char *m_styleBuff; + char *m_textBuff; + + Open_JTalk m_openJTalk; /* Japanese TTS system */ + int m_numModels; /* number of models */ + char **m_modelNames; /* model names */ + int m_numStyles; /* number of styles */ + char **m_styleNames; /* style names */ + + /* initialize: initialize thread */ + void initialize(); + + /* clear: free thread */ + void clear(); + +public: + + /* Open_JTalk_Thraed: thread constructor */ + Open_JTalk_Thread(); + + /* ~Open_JTalk_Thread: thread destructor */ + ~Open_JTalk_Thread(); + + /* loadAndStart: load models and start thread */ + bool loadAndStart(MMDAgent *mmdagent, const char *dicDir, const char *config); + + /* stopAndRelease: stop thread and free Open JTalk */ + void stopAndRelease(); + + /* run: main thread loop for TTS */ + void run(); + + /* isRunning: check running */ + bool isRunning(); + + /* isSpeaking: check speaking */ + bool isSpeaking(); + + /* checkCharacter: check speaking character */ + bool checkCharacter(const char *chara); + + /* synthesis: start synthesis */ + void synthesis(const char *chara, const char *style, const char *text); + + /* stop: stop synthesis */ + void stop(); +}; diff --git a/open_jtalk_lib/output/libs/Voice/mei_normal/README.txt b/open_jtalk_lib/output/libs/Voice/mei_normal/README.txt new file mode 100644 index 0000000..81398e1 --- /dev/null +++ b/open_jtalk_lib/output/libs/Voice/mei_normal/README.txt @@ -0,0 +1,78 @@ +=============================================================================== + HTS Voice "Mei (Normal)" version 1.1 + release August 3, 2011 + + +The work is released as a part of MMDAgent (http://www.mmdagent.jp/). + +******************************************************************************* + Copying +******************************************************************************* + +# ----------------------------------------------------------------- # +# HTS Voice "Mei (Normal)" # +# released by MMDAgent Project Team # +# http://www.mmdagent.jp/ # +# ----------------------------------------------------------------- # +# # +# Copyright (c) 2009-2011 Nagoya Institute of Technology # +# Department of Computer Science # +# # +# Some rights reserved. # +# # +# This work is licensed under the Creative Commons Attribution 3.0 # +# license. # +# # +# You are free: # +# * to Share - to copy, distribute and transmit the work # +# * to Remix - to adapt the work # +# Under the following conditions: # +# * Attribution - You must attribute the work in the manner # +# specified by the author or licensor (but not in any way that # +# suggests that they endorse you or your use of the work). # +# With the understanding that: # +# * Waiver - Any of the above conditions can be waived if you get # +# permission from the copyright holder. # +# * Public Domain - Where the work or any of its elements is in # +# the public domain under applicable law, that status is in no # +# way affected by the license. # +# * Other Rights - In no way are any of the following rights # +# affected by the license: # +# - Your fair dealing or fair use rights, or other applicable # +# copyright exceptions and limitations; # +# - The author's moral rights; # +# - Rights other persons may have either in the work itself or # +# in how the work is used, such as publicity or privacy # +# rights. # +# * Notice - For any reuse or distribution, you must make clear to # +# others the license terms of this work. The best way to do this # +# is with a link to this web page. # +# # +# See http://creativecommons.org/ for details. # +# ----------------------------------------------------------------- # + +See also "COPYRIGHT.txt" file in the current directory for details. + +******************************************************************************* + Acknowledgements +******************************************************************************* + +Keiichi Tokuda +Akinobu Lee +Keiichiro Oura + +******************************************************************************* + Who we are +******************************************************************************* + +The MMDAgent project team is a voluntary group for developing the Toolkit for +Building Voice Interaction System. Current members are + + Keiichi Tokuda http://www.sp.nitech.ac.jp/~tokuda/ + Akinobu Lee http://www.sp.nitech.ac.jp/~ri/ + Keiichiro Oura http://www.sp.nitech.ac.jp/~uratec/ + +and the members are dynamically changing. The current formal contact address of +MMDAgent project team and a mailing list for MMDAgent users can be found at +http://www.mmdagent.jp/ +=============================================================================== diff --git a/open_jtalk_test/ReadMe.txt b/open_jtalk_test/ReadMe.txt new file mode 100644 index 0000000..ccd3c65 --- /dev/null +++ b/open_jtalk_test/ReadMe.txt @@ -0,0 +1,45 @@ +======================================================================== + コンソール アプリケーション: open_jtalk_test プロジェクトの概要 +======================================================================== + +この open_jtalk_test アプリケーションは、AppWizard により作成されました。 + +このファイルには、open_jtalk_test +アプリケーションを構成する各ファイルの内容の概要が含まれています。 + + +open_jtalk_test.vcxproj + これは、アプリケーション ウィザードを使用して生成された VC++ + プロジェクトのメイン プロジェクト ファイルです。 + ファイルを生成した Visual C++ のバージョンに関する情報と、アプリケーション + ウィザードで選択されたプラットフォーム、 + 構成、およびプロジェクト機能に関する情報が含まれています。 + +open_jtalk_test.vcxproj.filters + これは、アプリケーション ウィザードで生成された VC++ プロジェクトのフィルター + ファイルです。 + このファイルには、プロジェクト内のファイルとフィルターとの間の関連付けに関する + 情報が含まれています。 この関連付けは、特定のノー + ドで同様の拡張子を持つファイルのグループ化を + 示すために IDE で使用されます (たとえば、".cpp" ファイルは "ソース ファイル" + フィルターに関連付けられています)。 + +open_jtalk_test.cpp + これは、メインのアプリケーション ソース ファイルです。 + +///////////////////////////////////////////////////////////////////////////// +その他の標準ファイル : + +StdAfx.h、StdAfx.cpp + これらのファイルは、open_jtalk_test.pch + という名前のプリコンパイル済みヘッダー (PCH) ファイルと、StdAfx.obj + という名前のプリコンパイル済みの型ファイルを構築するために使用されます。 + +///////////////////////////////////////////////////////////////////////////// +その他のメモ : + +AppWizard では "TODO:" +コメントを使用して、ユーザーが追加またはカスタマイズする必要のあるソース +コードを示します。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/open_jtalk_test/open_jtalk_test.cpp b/open_jtalk_test/open_jtalk_test.cpp new file mode 100644 index 0000000..da5a28e --- /dev/null +++ b/open_jtalk_test/open_jtalk_test.cpp @@ -0,0 +1,14 @@ +// open_jtalk_test.cpp : ƒRƒ“ƒ\[ƒ‹ ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̃Gƒ“ƒgƒŠ ƒ|ƒCƒ“ƒg‚ð’è‹`‚µ‚Ü‚·B +// + +#include "stdafx.h" +#include + +int _tmain(int argc, _TCHAR* argv[]) +{ + + Open_JTalk open_jtalk; + //open_jtalk.load( + return 0; +} + diff --git a/open_jtalk_test/open_jtalk_test.vcxproj b/open_jtalk_test/open_jtalk_test.vcxproj new file mode 100644 index 0000000..f2ef5f3 --- /dev/null +++ b/open_jtalk_test/open_jtalk_test.vcxproj @@ -0,0 +1,91 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {2EE744C8-848A-4BE8-907F-AAE6AF61655B} + Win32Proj + open_jtalk_test + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + true + $(solutiondir)open_jtalk_lib\open_jtalk_manager\;$(IncludePath) + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/open_jtalk_test/open_jtalk_test.vcxproj.filters b/open_jtalk_test/open_jtalk_test.vcxproj.filters new file mode 100644 index 0000000..2cf71b3 --- /dev/null +++ b/open_jtalk_test/open_jtalk_test.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + ヘッダー ファイル + + + ヘッダー ファイル + + + + + ソース ファイル + + + ソース ファイル + + + \ No newline at end of file diff --git a/open_jtalk_test/open_jtalk_test.vcxproj.user b/open_jtalk_test/open_jtalk_test.vcxproj.user new file mode 100644 index 0000000..ace9a86 --- /dev/null +++ b/open_jtalk_test/open_jtalk_test.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/open_jtalk_test/stdafx.cpp b/open_jtalk_test/stdafx.cpp new file mode 100644 index 0000000..07e7bff --- /dev/null +++ b/open_jtalk_test/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : •W€ƒCƒ“ƒNƒ‹[ƒh open_jtalk_test.pch ‚Ì‚Ý‚ð +// ŠÜ‚Þƒ\[ƒX ƒtƒ@ƒCƒ‹‚́AƒvƒŠƒRƒ“ƒpƒCƒ‹Ï‚݃wƒbƒ_[‚É‚È‚è‚Ü‚·B +// stdafx.obj ‚ɂ̓vƒŠƒRƒ“ƒpƒCƒ‹Ï‚ÝŒ^î•ñ‚ªŠÜ‚Ü‚ê‚Ü‚·B + +#include "stdafx.h" + +// TODO: ‚±‚̃tƒ@ƒCƒ‹‚Å‚Í‚È‚­ASTDAFX.H ‚Å•K—v‚È +// ’ljÁƒwƒbƒ_[‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B diff --git a/open_jtalk_test/stdafx.h b/open_jtalk_test/stdafx.h new file mode 100644 index 0000000..93c07ff --- /dev/null +++ b/open_jtalk_test/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : •W€‚̃VƒXƒeƒ€ ƒCƒ“ƒNƒ‹[ƒh ƒtƒ@ƒCƒ‹‚̃Cƒ“ƒNƒ‹[ƒh ƒtƒ@ƒCƒ‹A‚Ü‚½‚Í +// ŽQÆ‰ñ”‚ª‘½‚­A‚©‚‚ ‚Ü‚è•ÏX‚³‚ê‚È‚¢AƒvƒƒWƒFƒNƒgê—p‚̃Cƒ“ƒNƒ‹[ƒh ƒtƒ@ƒCƒ‹ +// ‚ð‹Lq‚µ‚Ü‚·B +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ƒvƒƒOƒ‰ƒ€‚É•K—v‚ȒljÁƒwƒbƒ_[‚ð‚±‚±‚ÅŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B diff --git a/open_jtalk_test/targetver.h b/open_jtalk_test/targetver.h new file mode 100644 index 0000000..10b7ccd --- /dev/null +++ b/open_jtalk_test/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h ‚ðƒCƒ“ƒNƒ‹[ƒh‚·‚é‚ƁA—˜—p‚Å‚«‚éÅ‚àãˆÊ‚Ì Windows ƒvƒ‰ƒbƒgƒtƒH[ƒ€‚ª’è‹`‚³‚ê‚Ü‚·B + +// ˆÈ‘O‚Ì Windows ƒvƒ‰ƒbƒgƒtƒH[ƒ€—p‚ɃAƒvƒŠƒP[ƒVƒ‡ƒ“‚ðƒrƒ‹ƒh‚·‚éê‡‚́AWinSDKVer.h ‚ðƒCƒ“ƒNƒ‹[ƒh‚µA +// SDKDDKVer.h ‚ðƒCƒ“ƒNƒ‹[ƒh‚·‚é‘O‚ɁAƒTƒ|[ƒg‘ΏۂƂ·‚éƒvƒ‰ƒbƒgƒtƒH[ƒ€‚ðŽ¦‚·‚悤‚É _WIN32_WINNT ƒ}ƒNƒ‚ðÝ’肵‚Ü‚·B + +#include diff --git a/speaker/mei_normal.cpp b/speaker/mei_normal.cpp index 4f7e340..5522af2 100644 --- a/speaker/mei_normal.cpp +++ b/speaker/mei_normal.cpp @@ -9,8 +9,12 @@ namespace openJtalk{ /// ///ƒRƒ“ƒXƒgƒ‰ƒNƒ^ /// -CMeiNormal::CMeiNormal() -{} +CMeiNormal::CMeiNormal(const TChar_P voiceDataDir,const TChar_P dictionaryDataDir) +{ + Initialize(); + Load(voiceDataDir,dictionaryDataDir); + +} /// @@ -25,8 +29,22 @@ void CMeiNormal::Initialize(){ void CMeiNormal::Load(const TChar_P voiceDataDir,const TChar_P dictionaryDataDir){ + + static char *mgc_winList[] = {"mgc.win1","mgc.win2","mgc.win3"}; + static char *lf0_winList[] = {"lf0.win1","lf0.win2","lf0.win3"}; + static char *lpf_winList[] = {"lpf.win1"}; + COpenJtalkCore::Load( + voiceDataDir,dictionaryDataDir, + "dur.pdf","tree-dur.inf", + "mgc.pdf","tree-mgc.inf",mgc_winList,sizeof(mgc_winList)/sizeof(mgc_winList[0]), + "lf0.pdf","tree-lf0.inf",lf0_winList,sizeof(lf0_winList)/sizeof(lf0_winList[0]), + "lpf.pdf","tree-lpf.inf",lpf_winList,sizeof(lpf_winList)/sizeof(lpf_winList[0]), + "gv-mgc.pdf","tree-gv-mgc.inf", + "gv-lf0.pdf","tree-gv-lf0.inf", + NULL,NULL, + "gv-switch.inf" + ); - //COpenJtalkCore::Load(voiceDataDir,dictionaryDataDir,"dur.pdf","tree-dur.inf","mgc.pdf", return; } diff --git a/speaker/mei_normal.h b/speaker/mei_normal.h index c80a5a3..c7f567c 100644 --- a/speaker/mei_normal.h +++ b/speaker/mei_normal.h @@ -7,10 +7,12 @@ namespace openJtalk{ class CMeiNormal:public COpenJtalkCore{ + public: + /// ///ƒRƒ“ƒXƒgƒ‰ƒNƒ^ /// - CMeiNormal(); + CMeiNormal(const TChar_P voiceDataDir,const TChar_P dictionaryDataDir); /// diff --git a/speaker/open_jtalk_core.cpp b/speaker/open_jtalk_core.cpp index fe8a611..cbe756f 100644 --- a/speaker/open_jtalk_core.cpp +++ b/speaker/open_jtalk_core.cpp @@ -7,11 +7,33 @@ namespace openJtalk{ COpenJtalkCore::COpenJtalkCore(): -manageFlag(false){} +manageFlag(false){ + + this->synthesisThreadHandle = (HANDLE)_beginthreadex(NULL,0,COpenJtalkCore::SynthesisThreadFunction,this,0,NULL); + this->synthesisEventObject = ::CreateEvent(NULL,false,false,NULL); + this->endEventObject = ::CreateEvent(NULL,true,false,NULL); + +} 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); + } + + } + + ::CloseHandle(this->synthesisThreadHandle); + ::CloseHandle(this->synthesisEventObject); + ::CloseHandle(this->endEventObject); + } void COpenJtalkCore::Initialize( HTS_Boolean use_lpf, int sampling_rate, @@ -37,64 +59,120 @@ void COpenJtalkCore::Load( const TChar_P in_voiceDataDir,const TChar_P in_dictin CStringA dictionaryDataDir(in_dictinalyDataDir); //Ž«‘ƒf[ƒ^ƒfƒBƒŒƒNƒgƒŠ CStringA voiceDataDir(in_voiceDataDir); //‰¹º[ƒf[ƒ^ƒfƒBƒŒƒNƒgƒŠ - std::vector ws_mgcList(num_ws_mgc); - + std::vector ws_mgcList; + std::vector ws_mgcBuffList; + for(int ws_mgc_index = 0;ws_mgc_index < num_ws_mgc;++ws_mgc_index){ - ws_mgcList.push_back((char *)(const char*)(voiceDataDir + fn_ws_mgc[ws_mgc_index])); + ws_mgcBuffList.push_back((const char*)(voiceDataDir + fn_ws_mgc[ws_mgc_index])); + ws_mgcList.push_back(&ws_mgcBuffList.back()[0]); } - std::vector ws_lf0List(num_ws_lf0); - + std::vector ws_lf0List; + std::vector ws_lf0BuffList; for(int ws_lf0Index = 0;ws_lf0Index < num_ws_lf0;++ws_lf0Index){ - ws_mgcList.push_back((char *)(const char*)(voiceDataDir + fn_ws_mgc[ws_lf0Index])); + ws_lf0BuffList.push_back((const char*)(voiceDataDir + fn_ws_mgc[ws_lf0Index])); + ws_lf0List.push_back(&ws_lf0BuffList.back()[0]); } - std::vector ws_lpfList(num_ws_lpf); - + std::vector ws_lpfList; + std::vector ws_lpfBuffList; for(int ws_lpfIndex = 0;ws_lpfIndex < num_ws_lpf;++ws_lpfIndex){ - ws_mgcList.push_back((char *)(const char*)(voiceDataDir + fn_ws_mgc[ws_lpfIndex])); + ws_lpfBuffList.push_back((const char*)(voiceDataDir + fn_ws_mgc[ws_lpfIndex])); + ws_lpfList.push_back(&ws_lpfBuffList.back()[0]); } ::OpenJTalk_load(&this->openJtalk_internal, (char *)(const char*)(dictionaryDataDir), - (char *)(const char*)(voiceDataDir +fn_ms_dur), - (char *)(const char*)(voiceDataDir +fn_ts_dur), - (char *)(const char*)(voiceDataDir +fn_ms_mgc), - (char *)(const char*)(voiceDataDir +fn_ts_mgc), + fn_ms_dur != NULL ?(char *)(const char*)(voiceDataDir +fn_ms_dur) : NULL, + fn_ts_dur != NULL ? (char *)(const char*)(voiceDataDir +fn_ts_dur) : NULL, + fn_ms_mgc != NULL ? (char *)(const char*)(voiceDataDir +fn_ms_mgc) : NULL, + fn_ts_mgc != NULL ? (char *)(const char*)(voiceDataDir +fn_ts_mgc) : NULL, &ws_mgcList[0], num_ws_mgc, - (char *)(const char*)(voiceDataDir +fn_ms_lf0), - (char *)(const char*)(voiceDataDir +fn_ts_lf0), + fn_ms_lf0 != NULL ?(char *)(const char*)(voiceDataDir +fn_ms_lf0) : NULL, + fn_ts_lf0 != NULL ? (char *)(const char*)(voiceDataDir +fn_ts_lf0) : NULL, &ws_mgcList[0], num_ws_lf0, - (char *)(const char*)(voiceDataDir +fn_ms_lpf), - (char *)(const char*)(voiceDataDir +fn_ts_lpf), + fn_ms_lpf != NULL ? (char *)(const char*)(voiceDataDir +fn_ms_lpf) : NULL, + fn_ts_lpf != NULL ? (char *)(const char*)(voiceDataDir +fn_ts_lpf) : NULL, &ws_lpfList[0], num_ws_lpf, - (char *)(const char*)(voiceDataDir +fn_ms_gvm), - (char *)(const char*)(voiceDataDir +fn_ts_gvm), - (char *)(const char*)(voiceDataDir +fn_ms_gvl), - (char *)(const char*)(voiceDataDir +fn_ts_gvl), - (char *)(const char*)(voiceDataDir +fn_ms_gvf), - (char *)(const char*)(voiceDataDir +fn_ts_gvf), - fn_gv_switch + fn_ms_gvm != NULL ? (char *)(const char*)(voiceDataDir +fn_ms_gvm) : NULL, + fn_ts_gvm != NULL ? (char *)(const char*)(voiceDataDir +fn_ts_gvm) : NULL, + fn_ms_gvl != NULL ? (char *)(const char*)(voiceDataDir +fn_ms_gvl) : NULL, + fn_ts_gvl != NULL ? (char *)(const char*)(voiceDataDir +fn_ts_gvl) : NULL, + fn_ms_gvf != NULL ? (char *)(const char*)(voiceDataDir +fn_ms_gvf) : NULL, + fn_ts_gvf != NULL ? (char *)(const char*)(voiceDataDir +fn_ts_gvf) : NULL, + fn_gv_switch != NULL ? (char *)(const char*)(voiceDataDir +fn_gv_switch) : NULL + ); } } -void COpenJtalkCore::Synthesis( Char_P txt, FILE * wavfp, FILE * logfp){ - ::OpenJTalk_synthesis(&this->openJtalk_internal,txt,wavfp,logfp); +void COpenJtalkCore::Synthesis( const TChar_P txt, FILE * wavfp, FILE * logfp){ + CStringA txtA(txt); + ::OpenJTalk_synthesis(&this->openJtalk_internal,(Char_P)(const char*)txtA,wavfp,logfp); +} + +void COpenJtalkCore::Synthesis(const TChar_P txt){ + + Synthesis(txt,NULL,NULL); + } +void COpenJtalkCore::SynthesisAsync(const TChar_P txt){ + + this->synthesisQueueCS.Lock(); + + if(this->synthesisQueue.size() > 3)this->synthesisQueue.pop(); + + this->synthesisQueue.push(txt); + + this->synthesisQueueCS.Unlock(); + +} + void COpenJtalkCore::Clear(){ ::OpenJTalk_clear(&this->openJtalk_internal); this->manageFlag = false; } +unsigned WINAPI COpenJtalkCore::SynthesisThreadFunction(void *userData){ + + auto &self = *(COpenJtalkCore*)userData; + + HANDLE eventList[2] = {self.synthesisEventObject,self.endEventObject}; + + DWORD dwRslt; + + do{ + dwRslt = ::WaitForMultipleObjects(sizeof(eventList) / sizeof(eventList[0]),eventList,false,INFINITE); + + if(dwRslt- WAIT_OBJECT_0 == 1)break; + + CString synthesisString; + + self.synthesisQueueCS.Lock(); + + synthesisString = self.synthesisQueue.back(); + self.synthesisQueue.pop(); + + self.synthesisQueueCS.Unlock(); + + self.Synthesis((const TChar_P)(const wchar_t*)synthesisString); + + + } while(true); + + _endthreadex(0); + + return 0; +} + } } \ No newline at end of file diff --git a/speaker/open_jtalk_core.h b/speaker/open_jtalk_core.h index ad76cc5..09366ac 100644 --- a/speaker/open_jtalk_core.h +++ b/speaker/open_jtalk_core.h @@ -1,5 +1,6 @@ #pragma once +#include namespace speaker{ namespace openJtalk{ @@ -7,13 +8,16 @@ namespace openJtalk{ ///OpenJtalk‚ðƒ‰ƒbƒv‚µ‚½ƒNƒ‰ƒX ///ƒfƒBƒŒƒNƒgƒŠ‚̈µ‚¢‚̊ȈՉ»‚ƃIƒuƒWƒFƒNƒg‚ðƒfƒXƒgƒ‰ƒNƒ^‚ÅŽ©“®”jŠü‚³‚ê‚é‚悤‚É‚µ‚½‚à‚Ì /// - class COpenJtalkCore{ + class COpenJtalkCore:public ISpeaker{ private: OpenJTalk openJtalk_internal; //“à•”ƒIƒuƒWƒFƒNƒg bool manageFlag; //ŠÇ—ƒtƒ‰ƒO - - + CComAutoCriticalSection synthesisQueueCS; + std::queue synthesisQueue; + HANDLE synthesisThreadHandle; //“ǂݏグƒXƒŒƒbƒhƒnƒ“ƒhƒ‹ + HANDLE synthesisEventObject; + HANDLE endEventObject; protected: /// ///ƒRƒ“ƒXƒgƒ‰ƒNƒ^ @@ -25,10 +29,7 @@ namespace openJtalk{ /// virtual ~COpenJtalkCore(); - //ƒRƒs[ƒK[ƒh - private: - COpenJtalkCore (const COpenJtalkCore&); - COpenJtalkCore& operator=(const COpenJtalkCore&); + protected: /// @@ -55,15 +56,31 @@ namespace openJtalk{ /// ///‰¹º‡¬ /// - void Synthesis( Char_P txt, FILE * wavfp, FILE * logfp); + void Synthesis( const TChar_P txt, FILE * wavfp, FILE * logfp); - + /// + ///‰¹º‡¬ƒCƒ“ƒ^[ƒtƒF[ƒXŽÀ‘• + /// + void Synthesis(const TChar_P txt); + + + /// + ///”ñ“¯Šú“ǂݏグƒCƒ“ƒ^[ƒtƒF[ƒXŽÀ‘• + /// + void SynthesisAsync(const TChar_P txt); + /// ///ƒIƒuƒWƒFƒNƒg‚̃NƒŠƒA /// void Clear(); + + private: + /// + ///”ñ“¯Šú“ǂݏグ—p‚̃XƒŒƒbƒhŠÖ” + /// + static unsigned WINAPI SynthesisThreadFunction(void *userData); }; diff --git a/speaker/speaker.cpp b/speaker/speaker.cpp new file mode 100644 index 0000000..a98c154 --- /dev/null +++ b/speaker/speaker.cpp @@ -0,0 +1,15 @@ +#include "stdafx.h" +#include "speaker_include.h" + +namespace speaker{ + + ISpeaker::ISpeaker(){} + ISpeaker &ISpeaker::GetMeiNormal(const TChar_P voiceDataDir,const TChar_P dictinaryDataDir){ + + static openJtalk::CMeiNormal mei_normal(voiceDataDir,dictinaryDataDir); + + + return mei_normal; + + } +} \ No newline at end of file diff --git a/speaker/speaker.h b/speaker/speaker.h new file mode 100644 index 0000000..85b41b3 --- /dev/null +++ b/speaker/speaker.h @@ -0,0 +1,41 @@ +#pragma once + +#include "speaker_define.h" + +namespace speaker{ +class ISpeaker{ + +protected: + ISpeaker(); + + //ƒRƒs[ƒK[ƒh +private: + ISpeaker (const ISpeaker&); + ISpeaker& operator=(const ISpeaker&); + +public: + + /// + ///“ǂݏグ + /// + virtual void Synthesis(const TChar_P txt) = 0; + + /// + ///”ñ“¯Šú‚œǂݏグ + /// + virtual void SynthesisAsync(const TChar_P txt) = 0; + + /// + ///ƒIƒuƒWƒFƒNƒgŠJ•ú + /// + virtual void Clear() = 0; + + + /// + ///ƒƒCŽæ“¾ + /// + static ISpeaker &GetMeiNormal(const TChar_P voiceDataDir,const TChar_P dictinaryDataDir); + +}; + +} \ No newline at end of file diff --git a/speaker/speaker.vcxproj b/speaker/speaker.vcxproj index d5a802c..aae6a5e 100644 --- a/speaker/speaker.vcxproj +++ b/speaker/speaker.vcxproj @@ -48,7 +48,7 @@ Use Level3 Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + WIN32;OPENJTALK_STATIC_MACRO;_DEBUG;_LIB;%(PreprocessorDefinitions);%(PreprocessorDefinitions) Windows @@ -62,7 +62,7 @@ MaxSpeed true true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + WIN32;OPENJTALK_STATIC_MACRO;NDEBUG;_LIB;%(PreprocessorDefinitions);%(PreprocessorDefinitions) Windows @@ -77,6 +77,7 @@ + @@ -85,6 +86,7 @@ + Create Create diff --git a/speaker/speaker.vcxproj.filters b/speaker/speaker.vcxproj.filters index e18f22f..42d8845 100644 --- a/speaker/speaker.vcxproj.filters +++ b/speaker/speaker.vcxproj.filters @@ -36,6 +36,9 @@ ヘッダー ファイル + + ヘッダー ファイル + @@ -47,5 +50,8 @@ ソース ファイル + + ソース ファイル + \ No newline at end of file diff --git a/speaker/speaker_include.h b/speaker/speaker_include.h index 0636735..1eaa530 100644 --- a/speaker/speaker_include.h +++ b/speaker/speaker_include.h @@ -2,7 +2,8 @@ #include -#include "speaker_define.h" +#include "speaker_define.h" +#include "speaker.h" #include "open_jtalk_core.h" #include "mei_normal.h" \ No newline at end of file diff --git a/speaker/stdafx.h b/speaker/stdafx.h index d7efdb3..c4c8d09 100644 --- a/speaker/stdafx.h +++ b/speaker/stdafx.h @@ -13,4 +13,6 @@ // TODO: ƒvƒƒOƒ‰ƒ€‚É•K—v‚ȒljÁƒwƒbƒ_[‚ð‚±‚±‚ÅŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B #include +#include #include +#include -- 2.11.0