tizen 2.3 release tizen_2.3 submit/tizen_2.3/20150202.065643 tizen_2.3_release
authorjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 05:04:23 +0000 (14:04 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 05:04:23 +0000 (14:04 +0900)
CMakeLists.txt [changed mode: 0755->0644]
packaging/libttssmt.spec
src/SMTApis.h
src/_SlpSmtApis.cpp
src/_SlpSmtApis.h
src/plugin_internal.cpp
src/plugin_internal.h
src/ttsp.c

old mode 100755 (executable)
new mode 100644 (file)
index e76c659..921f1d5
@@ -74,11 +74,7 @@ ENDIF("${ARCH}" MATCHES "^arm.*")
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vdata/ DESTINATION /usr/share/voice/tts/smt_vdata)
 
-IF(${CMAKE_BUILD_PROFILE} STREQUAL "wearable")
-    SET(SMACK_RULE_PATH "/etc/smack/accesses2.d")
-ELSE()
-    SET(SMACK_RULE_PATH "/etc/smack/accesses.d")
-ENDIF()
+SET(SMACK_RULE_PATH "/etc/smack/accesses.d")
 
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/libttssmt.rule DESTINATION ${SMACK_RULE_PATH})
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/ttssmt-info.xml DESTINATION /usr/lib/voice/tts/1.0/engine-info/)
index 84679eb..a1890d2 100644 (file)
@@ -25,11 +25,7 @@ Description: Text To Speech smt plugin shared library
 %prep
 %setup -q
 
-%if "%{_repository}" == "wearable"
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_BUILD_PROFILE="wearable"
-%else
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_BUILD_PROFILE="mobile"
-%endif
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
 %build
 make %{?jobs:-j%jobs}
@@ -42,11 +38,7 @@ cp %{_builddir}/%{name}-%{version}/LICENSE.Flora %{buildroot}/usr/share/license/
 
 %files
 %manifest libttssmt.manifest
-%if "%{_repository}" == "wearable"
-/etc/smack/accesses2.d/libttssmt.rule
-%else
 /etc/smack/accesses.d/libttssmt.rule
-%endif
 %defattr(-,root,root,-)
 %{_libdir}/voice/tts/1.0/engine/*
 /usr/share/voice/tts/smt_vdata/*
index a3b908b..9acc560 100644 (file)
-/*\r
- * Samsung TTS\r
- * Copyright 2012-2014  Samsung Electronics Co., Ltd\r
- *\r
- * Licensed under the Flora License, Version 1.1 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://floralicense.org/license/\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef   _SMTAPIS_H_\r
-#define   _SMTAPIS_H_\r
-\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#define UINT unsigned int\r
-\r
-typedef enum _eTypeLanguage\r
-{\r
-  eLANGUAGE_BEGIN       = 0x00000000,\r
-\r
-  eKOREAN               = eLANGUAGE_BEGIN, // Çѱ¹¾î\r
-\r
-  eUSENGLISH            = 0x00000100,      // ¹Ì±¹¿µ¾î\r
-  eUSENGLISH_OLD        = 0x0000010F,\r
-  eGBENGLISH            = 0x00000110,      // ¿µ±¹¿µ¾î\r
-  eGBENGLISH_OLD        = 0x0000011F,\r
-  eINENGLISH            = 0x00000120,      // Àεµ¿µ¾î\r
-\r
-  eCHINESE              = 0x00000200,      // Áß±¹¾î(ºÏ°æ¾î)\r
-  eTAIWANESE            = 0x00000210,      // ´ë¸¸¾î\r
-  eCANTONESE            = 0x00000220,      // ±¤µ¿¾î(È«Äá¾î)\r
-\r
-  eGERMAN               = 0x00000300,      // µ¶ÀϾî\r
-  eGERMAN_OLD           = 0x0000030F,\r
-  eSPANISH              = 0x00000400,      // ½ºÆäÀξî\r
-  eSPANISH_OLD          = 0x0000040F,\r
-  eFRENCH               = 0x00000500,      // ÇÁ¶û½º¾î\r
-  eFRENCH_OLD           = 0x0000050F,\r
-  eITALIAN              = 0x00000600,      // ÀÌÅ»¸®¾Æ¾î\r
-  eITALIAN_OLD          = 0x0000060F,\r
-  eDUTCH                = 0x00000700,      // ³×´ú¶õµå¾î\r
-  ePORTUGUESE           = 0x00000800,      // Æ÷¸£ÅõÄ®¾î\r
-  eGREEK                = 0x00000900,      // ±×¸®½º¾î\r
-  eTURKISH              = 0x00000A00,      // ÅÍÅ°¾î\r
-\r
-  eRUSSIAN              = 0x00000B00,      // ·¯½Ã¾Æ¾î\r
-\r
-  eJAPANESE             = 0x00000C00,      // ÀϺ»¾î\r
-  eJAPANESE_OLD         = 0x00000C0F,\r
-\r
-  ///////////////////////////////////////////\r
-  eDICTIONARY_USENGLISH = 0x10000100,      // ¿µ¾î»çÀü\r
-\r
-  eLANGUAGE_END,\r
-  eLANGUAGE_INVALID     = eLANGUAGE_END,\r
-} eTypeLanguage;\r
-\r
-\r
-#define SMT_SUCCESS                    0\r
-#define SMT_SYNTHESIS_FRAME_GENERATED  0\r
-#define SMT_SYNTHESIS_ALL_DONE         1\r
-#define SMT_SYNTHESIS_SENTENCE_DONE    2\r
-#define SMT_SYNTHESIS_PAUSE_DONE       3\r
-\r
-typedef enum _eTypeTTSMode\r
-{\r
-  eTTSMode_Normal,\r
-  eTTSMode_Dictionary,\r
-  \r
-  ///////////////////////////////////////////\r
-  \r
-  eTTSMode_INVALID,\r
-} eTypeTTSMode;\r
-\r
-typedef enum\r
-{\r
-  eSMTSpeechSpeed_VerySlow,\r
-  eSMTSpeechSpeed_Slow,\r
-  eSMTSpeechSpeed_Normal,\r
-  eSMTSpeechSpeed_Fast,\r
-  eSMTSpeechSpeed_VeryFast,\r
-} etypeSpeechSpeed;\r
-\r
-int SMTSetVoice           (eTypeTTSMode const eTTSMode, char const * const pszFilePath, char const DirDelimiter, char const * const pszLanguage, char const * const pszContry, char const * const pszVoiceType, UINT const VoiceIndex);\r
-int SMTCheckVoiceAvailable(eTypeTTSMode const eTTSMode, char const * const pszFilePath, char const DirDelimiter, char const * const pszLanguage, char const * const pszContry, char const * const pszVoiceType, UINT const VoiceIndex);\r
-\r
-\r
-int SMTInitialize(void);\r
-int SMTFinalize(void);\r
-int SMTSet_Language(eTypeLanguage eLanguage, int VoiceType, int ModelFileLocation);\r
-int SMTInputText(char const * const pszText_UTF8);\r
-int SMTSynthesize(short * const pPcmBuffer);\r
-\r
-int  SMTGetFramePeriod (void);\r
-\r
-void SMTSetSpeechSpeed(etypeSpeechSpeed const speed);\r
-\r
-int SMTSaveWave(char* pszFileName, short* pOutData, int const nDataSize);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif //_SMTAPIS_H_\r
-\r
-\r
+/*
+ * Samsung TTS
+ * Copyright 2012-2014  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef   _SMTAPIS_H_
+#define   _SMTAPIS_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UINT unsigned int
+
+typedef enum _eTypeLanguage
+{
+  eLANGUAGE_BEGIN       = 0x00000000,
+
+  eKOREAN               = eLANGUAGE_BEGIN, // Çѱ¹¾î
+
+  eUSENGLISH            = 0x00000100,      // ¹Ì±¹¿µ¾î
+  eUSENGLISH_OLD        = 0x0000010F,
+  eGBENGLISH            = 0x00000110,      // ¿µ±¹¿µ¾î
+  eGBENGLISH_OLD        = 0x0000011F,
+  eINENGLISH            = 0x00000120,      // Àεµ¿µ¾î
+
+  eCHINESE              = 0x00000200,      // Áß±¹¾î(ºÏ°æ¾î)
+  eTAIWANESE            = 0x00000210,      // ´ë¸¸¾î
+  eCANTONESE            = 0x00000220,      // ±¤µ¿¾î(È«Äá¾î)
+
+  eGERMAN               = 0x00000300,      // µ¶ÀϾî
+  eGERMAN_OLD           = 0x0000030F,
+  eSPANISH              = 0x00000400,      // ½ºÆäÀξî
+  eSPANISH_OLD          = 0x0000040F,
+  eFRENCH               = 0x00000500,      // ÇÁ¶û½º¾î
+  eFRENCH_OLD           = 0x0000050F,
+  eITALIAN              = 0x00000600,      // ÀÌÅ»¸®¾Æ¾î
+  eITALIAN_OLD          = 0x0000060F,
+  eDUTCH                = 0x00000700,      // ³×´ú¶õµå¾î
+  ePORTUGUESE           = 0x00000800,      // Æ÷¸£ÅõÄ®¾î
+  eGREEK                = 0x00000900,      // ±×¸®½º¾î
+  eTURKISH              = 0x00000A00,      // ÅÍÅ°¾î
+
+  eRUSSIAN              = 0x00000B00,      // ·¯½Ã¾Æ¾î
+
+  eJAPANESE             = 0x00000C00,      // ÀϺ»¾î
+  eJAPANESE_OLD         = 0x00000C0F,
+
+  ///////////////////////////////////////////
+  eDICTIONARY_USENGLISH = 0x10000100,      // ¿µ¾î»çÀü
+
+  eLANGUAGE_END,
+  eLANGUAGE_INVALID     = eLANGUAGE_END,
+} eTypeLanguage;
+
+
+#define SMT_SUCCESS                    0
+#define SMT_SYNTHESIS_FRAME_GENERATED  0
+#define SMT_SYNTHESIS_ALL_DONE         1
+#define SMT_SYNTHESIS_SENTENCE_DONE    2
+#define SMT_SYNTHESIS_PAUSE_DONE       3
+
+typedef enum _eTypeTTSMode
+{
+  eTTSMode_Normal,
+  eTTSMode_Dictionary,
+  
+  ///////////////////////////////////////////
+  
+  eTTSMode_INVALID,
+} eTypeTTSMode;
+
+typedef enum
+{
+  eSMTSpeechSpeed_VerySlow,
+  eSMTSpeechSpeed_Slow,
+  eSMTSpeechSpeed_Normal,
+  eSMTSpeechSpeed_Fast,
+  eSMTSpeechSpeed_VeryFast,
+} etypeSpeechSpeed;
+
+int SMTSetVoice           (eTypeTTSMode const eTTSMode, char const * const pszFilePath, char const DirDelimiter, char const * const pszLanguage, char const * const pszContry, char const * const pszVoiceType, UINT const VoiceIndex);
+int SMTCheckVoiceAvailable(eTypeTTSMode const eTTSMode, char const * const pszFilePath, char const DirDelimiter, char const * const pszLanguage, char const * const pszContry, char const * const pszVoiceType, UINT const VoiceIndex);
+
+
+int SMTInitialize(void);
+int SMTFinalize(void);
+int SMTSet_Language(eTypeLanguage eLanguage, int VoiceType, int ModelFileLocation);
+int SMTInputText(char const * const pszText_UTF8);
+int SMTSynthesize(short * const pPcmBuffer);
+
+int  SMTGetFramePeriod (void);
+
+void SMTSetSpeechSpeed(etypeSpeechSpeed const speed);
+
+int SMTSaveWave(char* pszFileName, short* pOutData, int const nDataSize);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_SMTAPIS_H_
+
+
index 4aab741..ca44e12 100644 (file)
-/*\r
- * Samsung TTS\r
- * Copyright 2012-2014  Samsung Electronics Co., Ltd\r
- *\r
- * Licensed under the Flora License, Version 1.1 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://floralicense.org/license/\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "SMTApis.h"\r
-\r
-#include "_SlpSmtApis.h"\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <unistd.h>\r
-#include <pthread.h>\r
-\r
-\r
-#define SMT_SAMPLING_RATE  16000\r
-\r
-#define PCM_BUFFER_SIZE    640000\r
-\r
-// Not supported yet {\r
-#define TTSPE_LANG_CANTONESE    "zh_HK"\r
-#define TTSPE_LANG_TAIWAN       "zh_TW"\r
-#define TTSPE_LANG_RUSSIAN      "ru_RU"\r
-#define TTSPE_LANG_JAPANESE     "ja_JP"\r
-#define TTSPE_LANG_NETHERLANDS  "nl_NL"\r
-#define TTSPE_LANG_PORTUGUESE   "pt_PT"\r
-#define TTSPE_LANG_GREEK        "el_GR"\r
-#define TTSPE_LANG_TURKEY       "tr_TR"\r
-// Not supported yet }\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-typedef struct __TypeVoiceInfo _TypeVoiceInfo;\r
-struct __TypeVoiceInfo\r
-{\r
-  char const         * const pszLanguage;\r
-  unsigned int          const sszLanguage;\r
-  ttsp_voice_type_e const eVoiceType;\r
-\r
-};\r
-\r
-\r
-static char const _pszKorean              [] = "ko_KR";\r
-static char const _pszUSEnglish           [] = "en_US";\r
-static char const _pszGerman              [] = "de_DE";\r
-static char const _pszSpanish             [] = "es_ES";\r
-static char const _pszFrench              [] = "fr_FR";\r
-static char const _pszItalian             [] = "it_IT";\r
-\r
-static unsigned int const _sszKorean                 = sizeof(_pszKorean);\r
-static unsigned int const _sszUSEnglish              = sizeof(_pszUSEnglish);\r
-static unsigned int const _sszGerman                 = sizeof(_pszGerman);\r
-static unsigned int const _sszSpanish                = sizeof(_pszSpanish);\r
-static unsigned int const _sszFrench                 = sizeof(_pszFrench);\r
-static unsigned int const _sszItalian                = sizeof(_pszItalian);\r
-\r
-\r
-static const _TypeVoiceInfo _pVoiceInfos[] =\r
-{\r
-  { _pszKorean              , _sszKorean              , TTSP_VOICE_TYPE_FEMALE },\r
-  { _pszUSEnglish           , _sszUSEnglish           , TTSP_VOICE_TYPE_FEMALE },\r
-\r
-  { _pszGerman              , _sszGerman              , TTSP_VOICE_TYPE_FEMALE },\r
-  { _pszSpanish             , _sszSpanish             , TTSP_VOICE_TYPE_FEMALE },\r
-  { _pszFrench              , _sszFrench              , TTSP_VOICE_TYPE_FEMALE },\r
-  { _pszItalian             , _sszItalian             , TTSP_VOICE_TYPE_FEMALE },\r
-};\r
-\r
-#define _nVoiceInfos   (sizeof(_pVoiceInfos) / sizeof(_pVoiceInfos[0]))\r
-\r
-// index of VoiceInfos\r
-#define VOICE_INDEX_KOREAN_WOMAN         0\r
-#define VOICE_INDEX_USENGLISH_WOMAN       1\r
-#define VOICE_INDEX_GERMAN_WOMAN           2\r
-#define VOICE_INDEX_SPANISH_WOMAN          3\r
-#define VOICE_INDEX_FRENCH_WOMAN           4\r
-#define VOICE_INDEX_ITALIAN_WOMAN          5\r
-\r
-\r
-\r
-\r
-typedef struct _TypeThreadQueueNode TypeThreadQueueNode;\r
-struct _TypeThreadQueueNode\r
-{\r
-  int                   iVoiceInfo;\r
-  char                * pszTextUtf8;\r
-  void                * pUserParam;\r
-  TypeThreadQueueNode * pNext;\r
-};\r
-\r
-static struct _global\r
-{\r
-  ttspe_result_cb      pfnCallback;\r
-  ttsp_speed_e        eSpeechSpeed;\r
-  int                  iVoiceInfo;\r
-  bool                 bStop;\r
-  bool                 bSentenceDone;\r
-\r
-  // thread\r
-  int                  ThreadId;\r
-  pthread_t            Thread;\r
-  pthread_mutex_t      ThreadLock;\r
-  pthread_mutex_t      MainThreadFinalizeLock;\r
-  TypeThreadQueueNode* ThreadQueue_pHead;\r
-  TypeThreadQueueNode* ThreadQueue_pTail;\r
-\r
-} _g =\r
-{\r
-  NULL                     , // pfnCallback\r
-\r
-  TTSP_SPEED_NORMAL       , // eSpeechSpeed\r
-  -1                       , // iVoiceInfo, initial value means INVALID INDEX\r
-  false                    , // bStop\r
-  true                     , // bSentenceDone\r
-\r
-  -1                       , // ThreadId\r
-  0                        , // Thread\r
-  PTHREAD_MUTEX_INITIALIZER, // ThreadLock\r
-  PTHREAD_MUTEX_INITIALIZER, // MainThreadFinalizeLock\r
-  NULL                     , // ThreadQueue_pHead\r
-  NULL                     , // ThreadQueue_pTail\r
-};\r
-\r
-static void                 _PushThreadData (int const iVoiceInfo, char const * pszTextUtf8, void* pUserParam);\r
-static TypeThreadQueueNode* _PopThreadData  (void);\r
-static bool                 _bEmptyThreadData(void);\r
-static void                 _CleanThreadData(void);\r
-static void *               _Synthesize     (void* NotUsed); // Thread routine\r
-\r
-\r
-static int  _ChangeVoice         (int const iVoiceInfo);\r
-static void _SetSpeechSpeed      (void);\r
-static void _CallBack            (ttsp_result_event_e eEvent, unsigned int const nPCMs, void * pPCMs, void* pUserParam);\r
-static int _Synthesize_SamsungTTS(char const * const pszTextUtf8, void* pUserParam, int const FramePeriod);\r
-\r
-\r
-\r
-\r
-char const * SLPSMT_GetPszKorean              (void) { return _pszKorean              ; }\r
-char const * SLPSMT_GetPszUSEnglish           (void) { return _pszUSEnglish           ; }\r
-\r
-\r
-char const * SLPSMT_GetPszGerman              (void) { return _pszGerman              ; }\r
-char const * SLPSMT_GetPszSpanish             (void) { return _pszSpanish             ; }\r
-char const * SLPSMT_GetPszFrench              (void) { return _pszFrench              ; }\r
-char const * SLPSMT_GetPszItalian             (void) { return _pszItalian             ; }\r
-\r
-int          SLPSMT_GetWorkingThreadId(void) { return _g.ThreadId; }\r
-\r
-\r
-\r
-\r
-int SLPSMT_StopSynthesis(void)\r
-{\r
-  printf(">> SLPSMT_StopSynthesis()\n");\r
-  _g.bStop         = true;\r
-  _g.bSentenceDone = true;\r
-  _CleanThreadData();\r
-  return TTSP_ERROR_NONE;\r
-}\r
-\r
-int SLPSMT_SynthesizeText(int const iVoiceInfo, char const * pszTextUtf8, void * const pUserParam)\r
-{\r
-  if (! _g.pfnCallback)                { return TTSP_ERROR_INVALID_STATE; }\r
-  if (! pszTextUtf8 || ! *pszTextUtf8) { return TTSP_ERROR_INVALID_PARAMETER; }\r
-\r
-  printf(">> SLPSMT_SynthesizeText()\n");\r
-  printf(">>>> iVoiceInfo  : %d\n", iVoiceInfo );\r
-  printf(">>>> pszTextUtf8 : %s\n", pszTextUtf8);\r
-\r
-  _g.bStop = false;\r
-\r
-  _PushThreadData(iVoiceInfo, pszTextUtf8, pUserParam);\r
-\r
-  if (_g.ThreadId < 0)\r
-  {\r
-    _g.ThreadId = pthread_create(& _g.Thread, NULL, _Synthesize, pUserParam);\r
-    if (_g.ThreadId < 0)\r
-    {\r
-      printf(">>>  Fail to create thread\n");\r
-      return TTSP_ERROR_OPERATION_FAILED;\r
-    }\r
-  }\r
-  return TTSP_ERROR_NONE;\r
-}\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-ttspe_voice_info_s * _gpVoiceInfos  = NULL;\r
-#define DATA_DIR1  "/usr/share/voice/tts/smt_vdata/"\r
-\r
-\r
-int SLPSMT_GetiVoiceInfoEx(char const *pszLanguage, ttsp_voice_type_e const eVoiceType)\r
-{\r
-       int i;\r
-       for (i=0 ; i<_nVoiceInfos ; i++)\r
-               {\r
-               if ( eVoiceType == _pVoiceInfos[i].eVoiceType  && ! strcmp(pszLanguage ,  _pVoiceInfos[i].pszLanguage)   )\r
-               {\r
-                       int iResult = -1;\r
-                       _eTypeTTSMode TTSType =   eTTSMode_Normal;\r
-                       char Language[3] = {0,};\r
-                       char Contry[3] = {0,};\r
-                       char VoiceType[2] = {0,};\r
-\r
-                       VoiceType[0] = 'f';\r
-                       VoiceType[1] = 0;\r
-                       memcpy( Language , pszLanguage , sizeof(Language)-1);\r
-                       memcpy( Contry , pszLanguage+3 , sizeof(Contry)-1);\r
-\r
-                       if( eVoiceType == TTSP_VOICE_TYPE_MALE ) VoiceType[0] = 'm';\r
-\r
-                       iResult = SMTCheckVoiceAvailable( (_eTypeTTSMode)TTSType , DATA_DIR1 , '/' , Language , Contry , VoiceType , 1 );\r
-\r
-                       printf("%d)####### iResult [%d]\n",i , iResult);\r
-\r
-                       if( iResult == 0 ) return i ;\r
-               }\r
-       }\r
-       return -1;\r
-}\r
-\r
-int SLPSMT_SetVoiceList(ttspe_voice_list_s * p)\r
-{\r
-  if (! _gpVoiceInfos)\r
-  {\r
-    unsigned int i;\r
-\r
-    _gpVoiceInfos = (ttspe_voice_info_s*) calloc(_nVoiceInfos, sizeof(ttspe_voice_info_s));\r
-    if (! _gpVoiceInfos) { return TTSP_ERROR_OUT_OF_MEMORY; }\r
-\r
-    for (i=0 ; i<_nVoiceInfos ; i++)\r
-    {\r
-      _gpVoiceInfos[i].lang   = strdup(_pVoiceInfos[i].pszLanguage);\r
-      _gpVoiceInfos[i].vctype =        _pVoiceInfos[i].eVoiceType  ;\r
-    }\r
-  }\r
-  p->voice_info = _gpVoiceInfos;\r
-  p->size       = _nVoiceInfos;\r
-  return TTSP_ERROR_NONE;\r
-}\r
-\r
-void SLPSMT_SetSpeechSpeed(ttsp_speed_e const eSpeechSpeed)\r
-{\r
-  switch (eSpeechSpeed)\r
-  {\r
-    case TTSP_SPEED_VERY_FAST :\r
-    case TTSP_SPEED_FAST      :\r
-    case TTSP_SPEED_SLOW      :\r
-    case TTSP_SPEED_VERY_SLOW :\r
-    case TTSP_SPEED_NORMAL    : _g.eSpeechSpeed = eSpeechSpeed;       break;\r
-    default                    : _g.eSpeechSpeed = TTSP_SPEED_NORMAL; break;\r
-  }\r
-}\r
-\r
-int SLPSMT_GetiVoiceInfo(char const *pszLanguage, ttsp_voice_type_e const eVoiceType)\r
-{\r
-  int i;\r
-  for (i=0 ; i<_nVoiceInfos ; i++)\r
-  {\r
-    if (             eVoiceType == _pVoiceInfos[i].eVoiceType\r
-        && ! strcmp(pszLanguage ,  _pVoiceInfos[i].pszLanguage)\r
-    )\r
-    {\r
-      return i;\r
-    }\r
-  }\r
-  return -1;\r
-}\r
-\r
-int SLPSMT_Initialize(ttspe_result_cb pfnCallBack)\r
-{\r
-  if (pfnCallBack)\r
-  {\r
-    _g.pfnCallback = pfnCallBack;\r
-    return TTSP_ERROR_NONE;\r
-  }\r
-  return TTSP_ERROR_INVALID_STATE;\r
-}\r
-\r
-int SLPSMT_Finalize(void)\r
-{\r
-  printf(">>>> SLPSMT_Finalize() called.\n");\r
-\r
-  _g.bStop = true;\r
-  _CleanThreadData();\r
-\r
-  pthread_mutex_lock  (& _g.MainThreadFinalizeLock);       // <---- lock\r
-  SMTFinalize();\r
-  pthread_mutex_unlock(& _g.MainThreadFinalizeLock);       // <---- unlock\r
-\r
-  if (_gpVoiceInfos)\r
-  {\r
-    unsigned int i;\r
-    for (i=0 ; i<_nVoiceInfos ; i++)\r
-    {\r
-      if (_gpVoiceInfos[i].lang) { free(_gpVoiceInfos[i].lang); }\r
-    }\r
-    free(_gpVoiceInfos);\r
-  }\r
-\r
-  _g.pfnCallback  = NULL;\r
-  _g.eSpeechSpeed = TTSP_SPEED_NORMAL;\r
-  _g.iVoiceInfo   = -1;\r
-while(_g.ThreadId != -1){\r
-       usleep(10000);\r
-}\r
-\r
-  printf(">>>> SLPSMT_Finalize() returns.\n");\r
-  return TTSP_ERROR_NONE;\r
-}\r
-\r
-\r
-\r
-\r
-static void _PushThreadData(int const iVoiceInfo, char const * pszTextUtf8, void* pUserParam)\r
-// iVoiceInfo  should be correct.\r
-// pszTextUtf8 should not be NULL.\r
-{\r
-  bool   b = false;\r
-  char * pszDuplicatedTextUtf8;\r
-\r
-  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock\r
-\r
-  pszDuplicatedTextUtf8 = strdup(pszTextUtf8);\r
-  if (pszDuplicatedTextUtf8)\r
-  {\r
-    TypeThreadQueueNode* p = (TypeThreadQueueNode*) calloc (1, sizeof(TypeThreadQueueNode));\r
-    if (p)\r
-    {\r
-      p->iVoiceInfo  = iVoiceInfo;\r
-      p->pszTextUtf8 = pszDuplicatedTextUtf8;\r
-      p->pUserParam  = pUserParam;\r
-      if (! _g.ThreadQueue_pHead) { _g.ThreadQueue_pHead        = p; }\r
-      if (  _g.ThreadQueue_pTail) { _g.ThreadQueue_pTail->pNext = p; }\r
-      _g.ThreadQueue_pTail = p;\r
-      b = true;\r
-    }\r
-\r
-    if (! b) { free(pszDuplicatedTextUtf8); }\r
-  }\r
-\r
-  if (! b) { printf(">>>__PushThreadData, out of memory\n"); }\r
-\r
-  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock\r
-}\r
-\r
-static TypeThreadQueueNode* _PopThreadData(void)\r
-{\r
-  TypeThreadQueueNode* p;\r
-\r
-  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock\r
-\r
-  p = _g.ThreadQueue_pHead;\r
-  if (_g.ThreadQueue_pHead) { _g.ThreadQueue_pHead = _g.ThreadQueue_pHead->pNext; }\r
-  if (p == _g.ThreadQueue_pTail) { _g.ThreadQueue_pTail = NULL; }\r
-\r
-  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock\r
-\r
-  return p;\r
-}\r
-\r
-static bool _bEmptyThreadData(void)\r
-{\r
-  bool b = true;\r
-  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock\r
-\r
-  if (_g.ThreadQueue_pHead) { b = false; }\r
-\r
-  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock\r
-  return b;\r
-}\r
-\r
-\r
-static void _CleanThreadData(void)\r
-{\r
-  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock\r
-\r
-  while (_g.ThreadQueue_pHead)\r
-  {\r
-    TypeThreadQueueNode* const p = _g.ThreadQueue_pHead;\r
-    _g.ThreadQueue_pHead = p->pNext;\r
-    free(p->pszTextUtf8);\r
-    free(p);\r
-  }\r
-  _g.ThreadQueue_pHead = NULL;\r
-  _g.ThreadQueue_pTail = NULL;\r
-\r
-  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock\r
-}\r
-\r
-static void * _Synthesize(void* NotUsed)\r
-{\r
-  unsigned int const FramePeriod = (unsigned int) SMTGetFramePeriod();\r
-  TypeThreadQueueNode* p = _PopThreadData();\r
-\r
-  for ( ; p ; p=_PopThreadData())\r
-  {\r
-    int  const   iVoiceInfo  = p->iVoiceInfo;\r
-    char const * pszTextUtf8 = p->pszTextUtf8;\r
-    void       * pUserParam  = p->pUserParam;\r
-\r
-    if (_g.pfnCallback)\r
-    {\r
-      int r = SMT_SUCCESS;\r
-\r
-      printf(">>>> Thread, _Synthesize(), iVoiceInfo = %d\n", iVoiceInfo);\r
-      printf(">>>>>> pszTextUtf8 = %s\n", pszTextUtf8);\r
-\r
-      if (iVoiceInfo != _g.iVoiceInfo)\r
-      {\r
-        r = _ChangeVoice(iVoiceInfo);\r
-        printf(">>>>>> iVoiceInfo was changed.\n");\r
-      }\r
-\r
-      if (r == SMT_SUCCESS)\r
-      {\r
-        _SetSpeechSpeed();\r
-\r
-        printf(">>>>>> Set speech-speed\n");\r
-\r
-        pthread_mutex_lock  (& _g.MainThreadFinalizeLock);       // <---- lock\r
-\r
-        r = _Synthesize_SamsungTTS(pszTextUtf8, pUserParam, FramePeriod);\r
-\r
-        pthread_mutex_unlock(& _g.MainThreadFinalizeLock);       // <---- unlock\r
-\r
-      }\r
-      printf(">>>Thread, _Synthesize() done\n");\r
-    }\r
-\r
-    free(p->pszTextUtf8);\r
-    free(p);\r
-  } // end of while loop\r
-\r
-  _g.ThreadId = -1;\r
-  return (void*) 1;\r
-}\r
-\r
-//\r
-// END\r
-//\r
-// functions managing < Thread Queue >\r
-//\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-//\r
-// functions managing < Engine Switching >\r
-//\r
-// BEGIN\r
-//\r
-\r
-static int _ChangeVoice(int const iVoiceInfo)\r
-{\r
-  int          r;\r
-  bool         bSamsungTTS = false;\r
-  bool         bSvoxTTS    = false;\r
-  char const * pszLanguage = NULL;\r
-  char const * pszContury  = NULL;\r
-\r
-   switch (iVoiceInfo)\r
-  {\r
-    case VOICE_INDEX_KOREAN_WOMAN              : SMTSet_Language(eKOREAN              ,  1, 0);                break;\r
-    case VOICE_INDEX_USENGLISH_WOMAN           : SMTSet_Language(eUSENGLISH           ,  1, 0);                        break;\r
-    case VOICE_INDEX_GERMAN_WOMAN              : SMTSet_Language(eGERMAN              ,  1, 0);                        break;\r
-    case VOICE_INDEX_SPANISH_WOMAN             : SMTSet_Language(eSPANISH             ,  1, 0);                        break;\r
-    case VOICE_INDEX_FRENCH_WOMAN              : SMTSet_Language(eFRENCH              ,  1, 0);                        break;\r
-    case VOICE_INDEX_ITALIAN_WOMAN                     : SMTSet_Language(eITALIAN              ,  1, 0);                       break;\r
-\r
-    default : break; // This case has already been checked.\r
-  }\r
-\r
-  _g.iVoiceInfo = iVoiceInfo;\r
-\r
-    SMTFinalize();\r
-    r = SMTInitialize();\r
-\r
-  if (r != SMT_SUCCESS) { printf(">>>  _ChangeVoice() returns %d.\n", r); }\r
-\r
-  return r;\r
-}\r
-\r
-static void _SetSpeechSpeed(void)\r
-{\r
-    switch (_g.eSpeechSpeed)\r
-    {\r
-      case TTSP_SPEED_VERY_FAST : SMTSetSpeechSpeed(eSMTSpeechSpeed_VeryFast);  break;\r
-      case TTSP_SPEED_FAST      : SMTSetSpeechSpeed(eSMTSpeechSpeed_Fast    );  break;\r
-      case TTSP_SPEED_SLOW      : SMTSetSpeechSpeed(eSMTSpeechSpeed_Slow    );  break;\r
-      case TTSP_SPEED_VERY_SLOW : SMTSetSpeechSpeed(eSMTSpeechSpeed_VerySlow);  break;\r
-      case TTSP_SPEED_NORMAL    : SMTSetSpeechSpeed(eSMTSpeechSpeed_Normal  );  break;\r
-    }\r
-}\r
-\r
-static void _CallBack(ttsp_result_event_e eEvent, unsigned int const nPCMs, void * pPCMs, void* pUserParam)\r
-{\r
-  unsigned int const n = nPCMs * sizeof(short);\r
-\r
-\r
-  printf(">>>  callback, pUserParam = 0x%x\n", (unsigned int) pUserParam);\r
-  printf(">>>  callback, event=");\r
-\r
-  switch (eEvent)\r
-  {\r
-    case TTSP_RESULT_EVENT_CONTINUE :\r
-      if (_g.bSentenceDone)\r
-      {\r
-        eEvent = TTSP_RESULT_EVENT_START;\r
-        _g.bSentenceDone = false;\r
-      }\r
-      break;\r
-\r
-    case TTSP_RESULT_EVENT_FINISH :\r
-      _g.bSentenceDone = true;\r
-      break;\r
-  }\r
-\r
-#if 1\r
-  if (nPCMs)\r
-  {\r
-    static int iWave = 0;\r
-    static char pszWave[100];\r
-\r
-    printf("@@@ saving wave file @@@\n");\r
-    sprintf(pszWave, "/mnt/nfs/tts/play%d.wav", iWave++);\r
-    SMTSaveWave(pszWave, (short*) pPCMs, nPCMs * 2);\r
-  }\r
-#endif\r
-\r
-  switch (eEvent)\r
-  {\r
-    case TTSP_RESULT_EVENT_START   : printf("TTSPE_CBEVENT_SYNTH_START\n");     break;\r
-    case TTSP_RESULT_EVENT_CONTINUE: printf("TTSPE_CBEVENT_SYNTH_CONTINUE\n");  break;\r
-    case TTSP_RESULT_EVENT_FINISH  : printf("TTSPE_CBEVENT_SYNTH_FINISH\n");    break;\r
-    case TTSP_RESULT_EVENT_FAIL    : printf("TTSPE_CBEVENT_SYNTH_FAIL\n");      break;\r
-    default                          : printf("invalid\n");                       break;\r
-  }\r
-\r
-  if (eEvent==TTSP_RESULT_EVENT_FINISH && ! _bEmptyThreadData())\r
-  {\r
-    printf(">>> There is another input text.\n");\r
-    printf(">>> TTSPE_CBEVENT_SYNTH_FINISH was chanage into TTSPE_CBEVENT_SYNTH_CONTINUE.\n");\r
-    eEvent = TTSP_RESULT_EVENT_CONTINUE;\r
-  }\r
-\r
-  printf(">>> data size = %d\n", n);\r
-  printf(">> >> Here we jump into the callback function.\n");\r
-\r
-  int cbreturn = -1;\r
-  if(_g.pfnCallback != NULL){\r
-       cbreturn = _g.pfnCallback(eEvent, pPCMs, n, TTSP_AUDIO_TYPE_RAW_S16, SMT_SAMPLING_RATE, pUserParam);\r
-  }\r
-  printf(">> >> Here we return from the callback function.\n");\r
-  printf(">> >> callback function return value = %d\n", cbreturn);\r
-  if (-1 == cbreturn)\r
-  {\r
-    printf(">>> Callback function returns TTS_CALLBACK_HALT.\n");\r
-    _g.bStop         = true;\r
-    _g.bSentenceDone = true;\r
-  }\r
-}\r
-\r
-static int _Synthesize_SamsungTTS(char const * const pszTextUtf8, void* pUserParam, int const FramePeriod)\r
-{\r
-  static short pPcmBuffer[PCM_BUFFER_SIZE];\r
-\r
-  int          r = SMTInputText(pszTextUtf8);\r
-  unsigned int i = 0;\r
-\r
-  if (r != SMT_SUCCESS)\r
-  {\r
-    _CleanThreadData();\r
-    printf(">>>  SMTInputText() returns %d.\n", r);\r
-  }\r
-\r
-\r
-  while (r == SMT_SUCCESS)\r
-  {\r
-    r = SMTSynthesize(& pPcmBuffer[i]);\r
-    if (_g.bStop)\r
-    {\r
-      _CleanThreadData();\r
-//      _CallBack(TTSP_RESULT_EVENT_CANCEL, i, pPcmBuffer, pUserParam);\r
-      break;\r
-    }\r
-    else\r
-    {\r
-      switch (r)\r
-      {\r
-        case SMT_SYNTHESIS_FRAME_GENERATED:\r
-          if (i + FramePeriod == PCM_BUFFER_SIZE)\r
-          {\r
-            _CallBack(TTSP_RESULT_EVENT_CONTINUE, PCM_BUFFER_SIZE, pPcmBuffer, pUserParam);\r
-            i = 0;\r
-          }\r
-          else\r
-          {\r
-            i += FramePeriod;\r
-          }\r
-          break;\r
-\r
-        case SMT_SYNTHESIS_PAUSE_DONE    :\r
-        case SMT_SYNTHESIS_SENTENCE_DONE :\r
-          r = SMT_SUCCESS;\r
-          break;\r
-\r
-        case SMT_SYNTHESIS_ALL_DONE :\r
-          _CallBack(TTSP_RESULT_EVENT_FINISH, i, pPcmBuffer, pUserParam);\r
-          break;\r
-\r
-        default :\r
-          _CleanThreadData();\r
-\r
-          printf(">>>  SMTSynthesize() returns %d\n", r);\r
-\r
-          _CallBack(TTSP_RESULT_EVENT_FAIL, i, pPcmBuffer, pUserParam);\r
-          break;\r
-      }\r
-    }\r
-\r
-  } // end of while loop\r
-\r
-  return r;\r
-}\r
-\r
-//\r
-// END\r
-//\r
-// functions managing < Engine Switching >\r
-//\r
+/*
+ * Samsung TTS
+ * Copyright 2012-2014  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SMTApis.h"
+
+#include "_SlpSmtApis.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+
+
+#define SMT_SAMPLING_RATE  16000
+
+#define PCM_BUFFER_SIZE    640000
+
+// Not supported yet {
+#define TTSPE_LANG_CANTONESE    "zh_HK"
+#define TTSPE_LANG_TAIWAN       "zh_TW"
+#define TTSPE_LANG_RUSSIAN      "ru_RU"
+#define TTSPE_LANG_JAPANESE     "ja_JP"
+#define TTSPE_LANG_NETHERLANDS  "nl_NL"
+#define TTSPE_LANG_PORTUGUESE   "pt_PT"
+#define TTSPE_LANG_GREEK        "el_GR"
+#define TTSPE_LANG_TURKEY       "tr_TR"
+// Not supported yet }
+
+
+
+
+
+
+
+
+
+
+typedef struct __TypeVoiceInfo _TypeVoiceInfo;
+struct __TypeVoiceInfo
+{
+  char const         * const pszLanguage;
+  unsigned int          const sszLanguage;
+  int const eVoiceType;
+
+};
+
+
+static char const _pszKorean              [] = "ko_KR";
+static char const _pszUSEnglish           [] = "en_US";
+static char const _pszGerman              [] = "de_DE";
+static char const _pszSpanish             [] = "es_ES";
+static char const _pszFrench              [] = "fr_FR";
+static char const _pszItalian             [] = "it_IT";
+
+static unsigned int const _sszKorean                 = sizeof(_pszKorean);
+static unsigned int const _sszUSEnglish              = sizeof(_pszUSEnglish);
+static unsigned int const _sszGerman                 = sizeof(_pszGerman);
+static unsigned int const _sszSpanish                = sizeof(_pszSpanish);
+static unsigned int const _sszFrench                 = sizeof(_pszFrench);
+static unsigned int const _sszItalian                = sizeof(_pszItalian);
+
+
+static const _TypeVoiceInfo _pVoiceInfos[] =
+{
+  { _pszKorean              , _sszKorean              , TTSP_VOICE_TYPE_FEMALE },
+  { _pszUSEnglish           , _sszUSEnglish           , TTSP_VOICE_TYPE_FEMALE },
+
+  { _pszGerman              , _sszGerman              , TTSP_VOICE_TYPE_FEMALE },
+  { _pszSpanish             , _sszSpanish             , TTSP_VOICE_TYPE_FEMALE },
+  { _pszFrench              , _sszFrench              , TTSP_VOICE_TYPE_FEMALE },
+  { _pszItalian             , _sszItalian             , TTSP_VOICE_TYPE_FEMALE },
+};
+
+#define _nVoiceInfos   (sizeof(_pVoiceInfos) / sizeof(_pVoiceInfos[0]))
+
+// index of VoiceInfos
+#define VOICE_INDEX_KOREAN_WOMAN         0
+#define VOICE_INDEX_USENGLISH_WOMAN       1
+#define VOICE_INDEX_GERMAN_WOMAN           2
+#define VOICE_INDEX_SPANISH_WOMAN          3
+#define VOICE_INDEX_FRENCH_WOMAN           4
+#define VOICE_INDEX_ITALIAN_WOMAN          5
+
+
+
+
+typedef struct _TypeThreadQueueNode TypeThreadQueueNode;
+struct _TypeThreadQueueNode
+{
+  int                   iVoiceInfo;
+  char                * pszTextUtf8;
+  void                * pUserParam;
+  TypeThreadQueueNode * pNext;
+};
+
+static struct _global
+{
+  ttspe_result_cb      pfnCallback;
+  int        eSpeechSpeed;
+  int                  iVoiceInfo;
+  bool                 bStop;
+  bool                 bSentenceDone;
+
+  // thread
+  int                  ThreadId;
+  pthread_t            Thread;
+  pthread_mutex_t      ThreadLock;
+  pthread_mutex_t      MainThreadFinalizeLock;
+  TypeThreadQueueNode* ThreadQueue_pHead;
+  TypeThreadQueueNode* ThreadQueue_pTail;
+
+} _g =
+{
+  NULL                     , // pfnCallback
+
+  TTSP_SPEED_NORMAL       , // eSpeechSpeed
+  -1                       , // iVoiceInfo, initial value means INVALID INDEX
+  false                    , // bStop
+  true                     , // bSentenceDone
+
+  -1                       , // ThreadId
+  0                        , // Thread
+  PTHREAD_MUTEX_INITIALIZER, // ThreadLock
+  PTHREAD_MUTEX_INITIALIZER, // MainThreadFinalizeLock
+  NULL                     , // ThreadQueue_pHead
+  NULL                     , // ThreadQueue_pTail
+};
+
+static void                 _PushThreadData (int const iVoiceInfo, char const * pszTextUtf8, void* pUserParam);
+static TypeThreadQueueNode* _PopThreadData  (void);
+static bool                 _bEmptyThreadData(void);
+static void                 _CleanThreadData(void);
+static void *               _Synthesize     (void* NotUsed); // Thread routine
+
+
+static int  _ChangeVoice         (int const iVoiceInfo);
+static void _SetSpeechSpeed      (void);
+static void _CallBack            (ttsp_result_event_e eEvent, unsigned int const nPCMs, void * pPCMs, void* pUserParam);
+static int _Synthesize_SamsungTTS(char const * const pszTextUtf8, void* pUserParam, int const FramePeriod);
+
+
+
+
+char const * SLPSMT_GetPszKorean              (void) { return _pszKorean              ; }
+char const * SLPSMT_GetPszUSEnglish           (void) { return _pszUSEnglish           ; }
+
+
+char const * SLPSMT_GetPszGerman              (void) { return _pszGerman              ; }
+char const * SLPSMT_GetPszSpanish             (void) { return _pszSpanish             ; }
+char const * SLPSMT_GetPszFrench              (void) { return _pszFrench              ; }
+char const * SLPSMT_GetPszItalian             (void) { return _pszItalian             ; }
+
+int          SLPSMT_GetWorkingThreadId(void) { return _g.ThreadId; }
+
+
+
+
+int SLPSMT_StopSynthesis(void)
+{
+  printf(">> SLPSMT_StopSynthesis()\n");
+  _g.bStop         = true;
+  _g.bSentenceDone = true;
+  _CleanThreadData();
+  return TTSP_ERROR_NONE;
+}
+
+int SLPSMT_SynthesizeText(int const iVoiceInfo, char const * pszTextUtf8, void * const pUserParam)
+{
+  if (! _g.pfnCallback)                { return TTSP_ERROR_INVALID_STATE; }
+  if (! pszTextUtf8 || ! *pszTextUtf8) { return TTSP_ERROR_INVALID_PARAMETER; }
+
+  printf(">> SLPSMT_SynthesizeText()\n");
+  printf(">>>> iVoiceInfo  : %d\n", iVoiceInfo );
+  printf(">>>> pszTextUtf8 : %s\n", pszTextUtf8);
+
+  _g.bStop = false;
+
+  _PushThreadData(iVoiceInfo, pszTextUtf8, pUserParam);
+
+  if (_g.ThreadId < 0)
+  {
+    _g.ThreadId = pthread_create(& _g.Thread, NULL, _Synthesize, pUserParam);
+    if (_g.ThreadId < 0)
+    {
+      printf(">>>  Fail to create thread\n");
+      return TTSP_ERROR_OPERATION_FAILED;
+    }
+  }
+  return TTSP_ERROR_NONE;
+}
+
+
+
+
+
+
+
+ttspe_voice_info_s * _gpVoiceInfos  = NULL;
+#define DATA_DIR1  "/usr/share/voice/tts/smt_vdata/"
+
+
+int SLPSMT_GetiVoiceInfoEx(char const *pszLanguage, int const eVoiceType)
+{
+       int i;
+       for (i=0 ; i<_nVoiceInfos ; i++)
+               {
+               if ( eVoiceType == _pVoiceInfos[i].eVoiceType  && ! strcmp(pszLanguage ,  _pVoiceInfos[i].pszLanguage)   )
+               {
+                       int iResult = -1;
+                       _eTypeTTSMode TTSType =   eTTSMode_Normal;
+                       char Language[3] = {0,};
+                       char Contry[3] = {0,};
+                       char VoiceType[2] = {0,};
+
+                       VoiceType[0] = 'f';
+                       VoiceType[1] = 0;
+                       memcpy( Language , pszLanguage , sizeof(Language)-1);
+                       memcpy( Contry , pszLanguage+3 , sizeof(Contry)-1);
+
+                       if( eVoiceType == TTSP_VOICE_TYPE_MALE ) VoiceType[0] = 'm';
+
+                       iResult = SMTCheckVoiceAvailable( (_eTypeTTSMode)TTSType , DATA_DIR1 , '/' , Language , Contry , VoiceType , 1 );
+
+                       printf("%d)####### iResult [%d]\n",i , iResult);
+
+                       if( iResult == 0 ) return i ;
+               }
+       }
+       return -1;
+}
+
+int SLPSMT_SetVoiceList(ttspe_voice_list_s * p)
+{
+  if (! _gpVoiceInfos)
+  {
+    unsigned int i;
+
+    _gpVoiceInfos = (ttspe_voice_info_s*) calloc(_nVoiceInfos, sizeof(ttspe_voice_info_s));
+    if (! _gpVoiceInfos) { return TTSP_ERROR_OUT_OF_MEMORY; }
+
+    for (i=0 ; i<_nVoiceInfos ; i++)
+    {
+      _gpVoiceInfos[i].lang   = strdup(_pVoiceInfos[i].pszLanguage);
+      _gpVoiceInfos[i].vctype =        _pVoiceInfos[i].eVoiceType  ;
+    }
+  }
+  p->voice_info = _gpVoiceInfos;
+  p->size       = _nVoiceInfos;
+  return TTSP_ERROR_NONE;
+}
+
+void SLPSMT_SetSpeechSpeed(int const eSpeechSpeed)
+{
+  int level = -1;
+
+  if (eSpeechSpeed == 0) {
+    level = TTSP_SPEED_NORMAL;
+  } else if (eSpeechSpeed >= 1 && eSpeechSpeed <= 3) {
+    level = 2;
+  } else if (eSpeechSpeed >= 4 && eSpeechSpeed <= 6) {
+       level = 5;
+  } else if (eSpeechSpeed >= 7 && eSpeechSpeed <= 9) {
+       level = 8;
+  } else if (eSpeechSpeed >= 10 && eSpeechSpeed <= 12) {
+       level = 11;
+  } else if (eSpeechSpeed >= 13 && eSpeechSpeed <= 15) {
+       level = 14;
+  } else {
+       level = 8;
+  }
+
+  _g.eSpeechSpeed = level;
+}
+
+int SLPSMT_GetiVoiceInfo(char const *pszLanguage, int const eVoiceType)
+{
+  int i;
+  for (i=0 ; i<_nVoiceInfos ; i++)
+  {
+    if (             eVoiceType == _pVoiceInfos[i].eVoiceType
+        && ! strcmp(pszLanguage ,  _pVoiceInfos[i].pszLanguage)
+    )
+    {
+      return i;
+    }
+  }
+  return -1;
+}
+
+int SLPSMT_Initialize(ttspe_result_cb pfnCallBack)
+{
+  if (pfnCallBack)
+  {
+    _g.pfnCallback = pfnCallBack;
+    return TTSP_ERROR_NONE;
+  }
+  return TTSP_ERROR_INVALID_STATE;
+}
+
+int SLPSMT_Finalize(void)
+{
+  printf(">>>> SLPSMT_Finalize() called.\n");
+
+  _g.bStop = true;
+  _CleanThreadData();
+
+  pthread_mutex_lock  (& _g.MainThreadFinalizeLock);       // <---- lock
+  SMTFinalize();
+  pthread_mutex_unlock(& _g.MainThreadFinalizeLock);       // <---- unlock
+
+  if (_gpVoiceInfos)
+  {
+    unsigned int i;
+    for (i=0 ; i<_nVoiceInfos ; i++)
+    {
+      if (_gpVoiceInfos[i].lang) { free(_gpVoiceInfos[i].lang); }
+    }
+    free(_gpVoiceInfos);
+  }
+
+  _g.pfnCallback  = NULL;
+  _g.eSpeechSpeed = TTSP_SPEED_NORMAL;
+  _g.iVoiceInfo   = -1;
+while(_g.ThreadId != -1){
+       usleep(10000);
+}
+
+  printf(">>>> SLPSMT_Finalize() returns.\n");
+  return TTSP_ERROR_NONE;
+}
+
+
+
+
+static void _PushThreadData(int const iVoiceInfo, char const * pszTextUtf8, void* pUserParam)
+// iVoiceInfo  should be correct.
+// pszTextUtf8 should not be NULL.
+{
+  bool   b = false;
+  char * pszDuplicatedTextUtf8;
+
+  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock
+
+  pszDuplicatedTextUtf8 = strdup(pszTextUtf8);
+  if (pszDuplicatedTextUtf8)
+  {
+    TypeThreadQueueNode* p = (TypeThreadQueueNode*) calloc (1, sizeof(TypeThreadQueueNode));
+    if (p)
+    {
+      p->iVoiceInfo  = iVoiceInfo;
+      p->pszTextUtf8 = pszDuplicatedTextUtf8;
+      p->pUserParam  = pUserParam;
+      if (! _g.ThreadQueue_pHead) { _g.ThreadQueue_pHead        = p; }
+      if (  _g.ThreadQueue_pTail) { _g.ThreadQueue_pTail->pNext = p; }
+      _g.ThreadQueue_pTail = p;
+      b = true;
+    }
+
+    if (! b) { free(pszDuplicatedTextUtf8); }
+  }
+
+  if (! b) { printf(">>>__PushThreadData, out of memory\n"); }
+
+  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock
+}
+
+static TypeThreadQueueNode* _PopThreadData(void)
+{
+  TypeThreadQueueNode* p;
+
+  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock
+
+  p = _g.ThreadQueue_pHead;
+  if (_g.ThreadQueue_pHead) { _g.ThreadQueue_pHead = _g.ThreadQueue_pHead->pNext; }
+  if (p == _g.ThreadQueue_pTail) { _g.ThreadQueue_pTail = NULL; }
+
+  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock
+
+  return p;
+}
+
+static bool _bEmptyThreadData(void)
+{
+  bool b = true;
+  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock
+
+  if (_g.ThreadQueue_pHead) { b = false; }
+
+  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock
+  return b;
+}
+
+
+static void _CleanThreadData(void)
+{
+  pthread_mutex_lock  (& _g.ThreadLock);       // <---- lock
+
+  while (_g.ThreadQueue_pHead)
+  {
+    TypeThreadQueueNode* const p = _g.ThreadQueue_pHead;
+    _g.ThreadQueue_pHead = p->pNext;
+    free(p->pszTextUtf8);
+    free(p);
+  }
+  _g.ThreadQueue_pHead = NULL;
+  _g.ThreadQueue_pTail = NULL;
+
+  pthread_mutex_unlock(& _g.ThreadLock);       // <---- unlock
+}
+
+static void * _Synthesize(void* NotUsed)
+{
+  unsigned int const FramePeriod = (unsigned int) SMTGetFramePeriod();
+  TypeThreadQueueNode* p = _PopThreadData();
+
+  for ( ; p ; p=_PopThreadData())
+  {
+    int  const   iVoiceInfo  = p->iVoiceInfo;
+    char const * pszTextUtf8 = p->pszTextUtf8;
+    void       * pUserParam  = p->pUserParam;
+
+    if (_g.pfnCallback)
+    {
+      int r = SMT_SUCCESS;
+
+      printf(">>>> Thread, _Synthesize(), iVoiceInfo = %d\n", iVoiceInfo);
+      printf(">>>>>> pszTextUtf8 = %s\n", pszTextUtf8);
+
+      if (iVoiceInfo != _g.iVoiceInfo)
+      {
+        r = _ChangeVoice(iVoiceInfo);
+        printf(">>>>>> iVoiceInfo was changed.\n");
+      }
+
+      if (r == SMT_SUCCESS)
+      {
+        _SetSpeechSpeed();
+
+        printf(">>>>>> Set speech-speed\n");
+
+        pthread_mutex_lock  (& _g.MainThreadFinalizeLock);       // <---- lock
+
+        r = _Synthesize_SamsungTTS(pszTextUtf8, pUserParam, FramePeriod);
+
+        pthread_mutex_unlock(& _g.MainThreadFinalizeLock);       // <---- unlock
+
+      }
+      printf(">>>Thread, _Synthesize() done\n");
+    }
+
+    free(p->pszTextUtf8);
+    free(p);
+  } // end of while loop
+
+  _g.ThreadId = -1;
+  return (void*) 1;
+}
+
+//
+// END
+//
+// functions managing < Thread Queue >
+//
+
+
+
+
+
+
+
+
+//
+// functions managing < Engine Switching >
+//
+// BEGIN
+//
+
+static int _ChangeVoice(int const iVoiceInfo)
+{
+  int          r;
+  bool         bSamsungTTS = false;
+  bool         bSvoxTTS    = false;
+  char const * pszLanguage = NULL;
+  char const * pszContury  = NULL;
+
+   switch (iVoiceInfo)
+  {
+    case VOICE_INDEX_KOREAN_WOMAN              : SMTSet_Language(eKOREAN              ,  1, 0);                break;
+    case VOICE_INDEX_USENGLISH_WOMAN           : SMTSet_Language(eUSENGLISH           ,  1, 0);                        break;
+    case VOICE_INDEX_GERMAN_WOMAN              : SMTSet_Language(eGERMAN              ,  1, 0);                        break;
+    case VOICE_INDEX_SPANISH_WOMAN             : SMTSet_Language(eSPANISH             ,  1, 0);                        break;
+    case VOICE_INDEX_FRENCH_WOMAN              : SMTSet_Language(eFRENCH              ,  1, 0);                        break;
+    case VOICE_INDEX_ITALIAN_WOMAN                     : SMTSet_Language(eITALIAN              ,  1, 0);                       break;
+
+    default : break; // This case has already been checked.
+  }
+
+  _g.iVoiceInfo = iVoiceInfo;
+
+    SMTFinalize();
+    r = SMTInitialize();
+
+  if (r != SMT_SUCCESS) { printf(">>>  _ChangeVoice() returns %d.\n", r); }
+
+  return r;
+}
+
+static void _SetSpeechSpeed(void)
+{
+    switch (_g.eSpeechSpeed)
+    {
+      case 14  : SMTSetSpeechSpeed(eSMTSpeechSpeed_VeryFast);  break;
+      case 11  : SMTSetSpeechSpeed(eSMTSpeechSpeed_Fast    );  break;
+      case 5   : SMTSetSpeechSpeed(eSMTSpeechSpeed_Slow    );  break;
+      case 2   : SMTSetSpeechSpeed(eSMTSpeechSpeed_VerySlow);  break;
+      case TTSP_SPEED_NORMAL    : SMTSetSpeechSpeed(eSMTSpeechSpeed_Normal  );  break;
+    }
+}
+
+static void _CallBack(ttsp_result_event_e eEvent, unsigned int const nPCMs, void * pPCMs, void* pUserParam)
+{
+  unsigned int const n = nPCMs * sizeof(short);
+
+
+  printf(">>>  callback, pUserParam = 0x%x\n", (unsigned int) pUserParam);
+  printf(">>>  callback, event=");
+
+  switch (eEvent)
+  {
+    case TTSP_RESULT_EVENT_CONTINUE :
+      if (_g.bSentenceDone)
+      {
+        eEvent = TTSP_RESULT_EVENT_START;
+        _g.bSentenceDone = false;
+      }
+      break;
+
+    case TTSP_RESULT_EVENT_FINISH :
+      _g.bSentenceDone = true;
+      break;
+  }
+
+#if 1
+  if (nPCMs)
+  {
+    static int iWave = 0;
+    static char pszWave[100];
+
+    printf("@@@ saving wave file @@@\n");
+    sprintf(pszWave, "/mnt/nfs/tts/play%d.wav", iWave++);
+    SMTSaveWave(pszWave, (short*) pPCMs, nPCMs * 2);
+  }
+#endif
+
+  switch (eEvent)
+  {
+    case TTSP_RESULT_EVENT_START   : printf("TTSPE_CBEVENT_SYNTH_START\n");     break;
+    case TTSP_RESULT_EVENT_CONTINUE: printf("TTSPE_CBEVENT_SYNTH_CONTINUE\n");  break;
+    case TTSP_RESULT_EVENT_FINISH  : printf("TTSPE_CBEVENT_SYNTH_FINISH\n");    break;
+    case TTSP_RESULT_EVENT_FAIL    : printf("TTSPE_CBEVENT_SYNTH_FAIL\n");      break;
+    default                          : printf("invalid\n");                       break;
+  }
+
+  if (eEvent==TTSP_RESULT_EVENT_FINISH && ! _bEmptyThreadData())
+  {
+    printf(">>> There is another input text.\n");
+    printf(">>> TTSPE_CBEVENT_SYNTH_FINISH was chanage into TTSPE_CBEVENT_SYNTH_CONTINUE.\n");
+    eEvent = TTSP_RESULT_EVENT_CONTINUE;
+  }
+
+  printf(">>> data size = %d\n", n);
+  printf(">> >> Here we jump into the callback function.\n");
+
+  int cbreturn = -1;
+  if(_g.pfnCallback != NULL){
+       cbreturn = _g.pfnCallback(eEvent, pPCMs, n, TTSP_AUDIO_TYPE_RAW_S16, SMT_SAMPLING_RATE, pUserParam);
+  }
+  printf(">> >> Here we return from the callback function.\n");
+  printf(">> >> callback function return value = %d\n", cbreturn);
+  if (-1 == cbreturn)
+  {
+    printf(">>> Callback function returns TTS_CALLBACK_HALT.\n");
+    _g.bStop         = true;
+    _g.bSentenceDone = true;
+  }
+}
+
+static int _Synthesize_SamsungTTS(char const * const pszTextUtf8, void* pUserParam, int const FramePeriod)
+{
+  static short pPcmBuffer[PCM_BUFFER_SIZE];
+
+  int          r = SMTInputText(pszTextUtf8);
+  unsigned int i = 0;
+
+  if (r != SMT_SUCCESS)
+  {
+    _CleanThreadData();
+    printf(">>>  SMTInputText() returns %d.\n", r);
+  }
+
+
+  while (r == SMT_SUCCESS)
+  {
+    r = SMTSynthesize(& pPcmBuffer[i]);
+    if (_g.bStop)
+    {
+      _CleanThreadData();
+//      _CallBack(TTSP_RESULT_EVENT_CANCEL, i, pPcmBuffer, pUserParam);
+      break;
+    }
+    else
+    {
+      switch (r)
+      {
+        case SMT_SYNTHESIS_FRAME_GENERATED:
+          if (i + FramePeriod == PCM_BUFFER_SIZE)
+          {
+            _CallBack(TTSP_RESULT_EVENT_CONTINUE, PCM_BUFFER_SIZE, pPcmBuffer, pUserParam);
+            i = 0;
+          }
+          else
+          {
+            i += FramePeriod;
+          }
+          break;
+
+        case SMT_SYNTHESIS_PAUSE_DONE    :
+        case SMT_SYNTHESIS_SENTENCE_DONE :
+          r = SMT_SUCCESS;
+          break;
+
+        case SMT_SYNTHESIS_ALL_DONE :
+          _CallBack(TTSP_RESULT_EVENT_FINISH, i, pPcmBuffer, pUserParam);
+          break;
+
+        default :
+          _CleanThreadData();
+
+          printf(">>>  SMTSynthesize() returns %d\n", r);
+
+          _CallBack(TTSP_RESULT_EVENT_FAIL, i, pPcmBuffer, pUserParam);
+          break;
+      }
+    }
+
+  } // end of while loop
+
+  return r;
+}
+
+//
+// END
+//
+// functions managing < Engine Switching >
+//
index 94edfcf..acf5587 100644 (file)
@@ -1,43 +1,43 @@
-/*\r
- * Samsung TTS\r
- * Copyright 2012-2014  Samsung Electronics Co., Ltd\r
- *\r
- * Licensed under the Flora License, Version 1.1 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://floralicense.org/license/\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#ifndef   __SLP_SMT_APIS_H__\r
-#define   __SLP_SMT_APIS_H__\r
-\r
-#include <ttsp.h>\r
-#include "plugin_internal.h"\r
-\r
-int  SLPSMT_Initialize    (ttspe_result_cb const pfnCallBack);\r
-int  SLPSMT_Finalize      (void);\r
-\r
-int  SLPSMT_SetVoiceList  (ttspe_voice_list_s *);\r
-void SLPSMT_SetSpeechSpeed(ttsp_speed_e const eSpeechSpeed);\r
-int  SLPSMT_GetiVoiceInfo (char const *pszLanguage, ttsp_voice_type_e const eVoiceType);\r
-int  SLPSMT_GetiVoiceInfoEx(char const *pszLanguage, ttsp_voice_type_e const eVoiceType);\r
-int  SLPSMT_SynthesizeText(int const iVoiceInfo, char const * pszTextUtf8, void* const pUserParam);\r
-int  SLPSMT_StopSynthesis (void);\r
-\r
-char const * SLPSMT_GetPszKorean              (void);\r
-char const * SLPSMT_GetPszUSEnglish           (void);\r
-char const * SLPSMT_GetPszGerman              (void);\r
-char const * SLPSMT_GetPszSpanish             (void);\r
-char const * SLPSMT_GetPszFrench              (void);\r
-char const * SLPSMT_GetPszItalian             (void);\r
-int          SLPSMT_GetWorkingThreadId        (void);\r
-\r
-\r
-#endif // __SLP_SMT_APIS_H__\r
+/*
+ * Samsung TTS
+ * Copyright 2012-2014  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef   __SLP_SMT_APIS_H__
+#define   __SLP_SMT_APIS_H__
+
+#include <ttsp.h>
+#include "plugin_internal.h"
+
+int  SLPSMT_Initialize    (ttspe_result_cb const pfnCallBack);
+int  SLPSMT_Finalize      (void);
+
+int  SLPSMT_SetVoiceList  (ttspe_voice_list_s *);
+void SLPSMT_SetSpeechSpeed(int const eSpeechSpeed);
+int  SLPSMT_GetiVoiceInfo (char const *pszLanguage, int const eVoiceType);
+int  SLPSMT_GetiVoiceInfoEx(char const *pszLanguage, int const eVoiceType);
+int  SLPSMT_SynthesizeText(int const iVoiceInfo, char const * pszTextUtf8, void* const pUserParam);
+int  SLPSMT_StopSynthesis (void);
+
+char const * SLPSMT_GetPszKorean              (void);
+char const * SLPSMT_GetPszUSEnglish           (void);
+char const * SLPSMT_GetPszGerman              (void);
+char const * SLPSMT_GetPszSpanish             (void);
+char const * SLPSMT_GetPszFrench              (void);
+char const * SLPSMT_GetPszItalian             (void);
+int          SLPSMT_GetWorkingThreadId        (void);
+
+
+#endif // __SLP_SMT_APIS_H__
index 2b034b4..d41c76e 100644 (file)
-/*\r
- * Samsung TTS\r
- * Copyright 2012-2014  Samsung Electronics Co., Ltd\r
- *\r
- * Licensed under the Flora License, Version 1.1 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://floralicense.org/license/\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include "plugin_internal.h"\r
-#include "_SlpSmtApis.h"\r
-\r
-\r
-// Once eigine was initialize, that means gpDaemonAPIs and its members are not NULL.\r
-// So we do not need to check whether this is NULL, nor its members are NULL.\r
-static ttspd_funcs_s const * gpDaemonAPIs = NULL;\r
-\r
-\r
-int plugin_Initialize(ttspe_result_cb const pfnCallBack)\r
-{\r
-       int r = SLPSMT_Initialize(pfnCallBack);\r
-       printf(">>>plugin Initialize() returns %d.\n", r);\r
-       return r;\r
-}\r
-\r
-int plugin_Finalize(void)\r
-{\r
-       int r = SLPSMT_Finalize();\r
-       printf(">>>plugin Initialize() returns %d.\n", r);\r
-       return r;\r
-}\r
-\r
-int plugin_SynthesizeText(char const *pszLanguage, ttsp_voice_type_e eVoiceType_0,  char const *pszTextUtf8,\r
-                       ttsp_speed_e eSpeechSpeed_0, void* pUserParam)\r
-{\r
-       int               iVoiceInfo   = -1;\r
-       ttsp_voice_type_e eVoiceType   = eVoiceType_0;\r
-       ttsp_speed_e     eSpeechSpeed = eSpeechSpeed_0;\r
-\r
-       int ThreadId = SLPSMT_GetWorkingThreadId();\r
-       printf(">>>plugin SynthesizeText()\n");\r
-       if (ThreadId != -1)\r
-       {\r
-       printf(">>>  A new text is comming into the TTS engine, while Synthesizing.\n");\r
-       printf(">>>  The text would be pushed into the thread queue.\n");\r
-       }\r
-       printf(">>>  ThreadId = %d\n", ThreadId);\r
-       printf(">>>  pUserParam = 0x%x\n", (unsigned int) pUserParam);\r
-\r
-       printf(">>>  eSpeechSpeed = %s\n", //eSpeechSpeed==TTSPE_SPEED_DEFAULT   ? "TTSPE_SPEED_DEFAULT"   :\r
-                                    eSpeechSpeed==TTSP_SPEED_VERY_FAST ? "TTSP_SPEED_VERY_FAST" :\r
-                                    eSpeechSpeed==TTSP_SPEED_FAST      ? "TTSP_SPEED_FAST"      :\r
-                                    eSpeechSpeed==TTSP_SPEED_NORMAL    ? "TTSP_SPEED_NORMAL"    :\r
-                                    eSpeechSpeed==TTSP_SPEED_SLOW      ? "TTSP_SPEED_SLOW"      :\r
-                                    eSpeechSpeed==TTSP_SPEED_VERY_SLOW ? "TTSP_SPEED_VERY_SLOW" : ""\r
-       );\r
-       printf(">>>  pszLanguage  = %s\n", pszLanguage);\r
-       printf(">>>  eVoiceType   = %s\n", //eVoiceType==TTSPE_VCTYPE_DEFAULT ? "TTSPE_VCTYPE_DEFAULT" :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_MALE    ? "TTSP_VOICE_TYPE_MALE"    :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_FEMALE  ? "TTSP_VOICE_TYPE_FEMALE"  :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_CHILD   ? "TTSP_VOICE_TYPE_CHILD"   :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_USER1   ? "TTSP_VOICE_TYPE_USER1"   :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_USER2   ? "TTSP_VOICE_TYPE_USER2"   :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_USER3   ? "TTSP_VOICE_TYPE_USER3"   : ""\r
-       );\r
-\r
-       SLPSMT_SetSpeechSpeed(eSpeechSpeed);\r
-\r
-       printf(">>>  \n");\r
-       printf(">>>  eSpeechSpeed = %s\n", //eSpeechSpeed==TTSP_SPEED_DEFAULT   ? "TTSPE_SPEED_DEFAULT"   :\r
-                                    eSpeechSpeed==TTSP_SPEED_VERY_FAST ? "TTSPE_SPEED_VERY_FAST" :\r
-                                    eSpeechSpeed==TTSP_SPEED_FAST      ? "TTSPE_SPEED_FAST"      :\r
-                                    eSpeechSpeed==TTSP_SPEED_NORMAL    ? "TTSPE_SPEED_NORMAL"    :\r
-                                    eSpeechSpeed==TTSP_SPEED_SLOW      ? "TTSPE_SPEED_SLOW"      :\r
-                                    eSpeechSpeed==TTSP_SPEED_VERY_SLOW ? "TTSPE_SPEED_VERY_SLOW" : ""\r
-       );\r
-       printf(">>>  pszLanguage  = %s\n", pszLanguage);\r
-       printf(">>>  eVoiceType   = %s\n", //eVoiceType==TTSPE_VCTYPE_DEFAULT ? "TTSPE_VCTYPE_DEFAULT" :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_MALE    ? "TTSPE_VCTYPE_MALE"    :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_FEMALE  ? "TTSPE_VCTYPE_FEMALE"  :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_CHILD   ? "TTSPE_VCTYPE_CHILD"   :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_USER1   ? "TTSPE_VCTYPE_USER1"   :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_USER2   ? "TTSPE_VCTYPE_USER2"   :\r
-                                    eVoiceType==TTSP_VOICE_TYPE_USER3   ? "TTSPE_VCTYPE_USER3"   : ""\r
-       );\r
-\r
-       // set voice\r
-       iVoiceInfo = SLPSMT_GetiVoiceInfoEx(pszLanguage, eVoiceType);\r
-       if (iVoiceInfo < 0)\r
-       {\r
-               printf("iVoiceInfo < 0\n");\r
-               return TTSP_ERROR_INVALID_VOICE;\r
-       }\r
-\r
-       return SLPSMT_SynthesizeText(iVoiceInfo, pszTextUtf8, pUserParam);\r
-}\r
-\r
-int plugin_StopSynthesis(void)\r
-{\r
-       return SLPSMT_StopSynthesis();\r
-}\r
-\r
-int plugin_ForeachVoices(ttspe_supported_voice_cb callback, void* user_data)\r
-{\r
-       if(NULL == callback)\r
-               return TTSP_ERROR_INVALID_PARAMETER;\r
-\r
-       ttspe_voice_list_s pVoiceList;\r
-       SLPSMT_SetVoiceList(&pVoiceList);\r
-\r
-       int i = 0;\r
-\r
-       ttspe_voice_info_s* temp = pVoiceList.voice_info;\r
-\r
-       for(i=0 ; i < pVoiceList.size; i++)\r
-       {\r
-               if (false == callback(temp[i].lang, temp[i].vctype, user_data))\r
-               {\r
-                       printf(">> plugin_ForeachVoices(), callback fail!!\n");\r
-                       break;\r
-               }\r
-       }\r
-\r
-       return TTSP_ERROR_NONE;\r
-}\r
-\r
-bool plugin_IsValidVoice(const char* language, ttsp_voice_type_e type)\r
-{\r
-       if (NULL == language)\r
-               return TTSP_ERROR_INVALID_PARAMETER;\r
-\r
-       int iVoiceInfo = SLPSMT_GetiVoiceInfoEx((char* )language, type);\r
-\r
-       if (iVoiceInfo < 0)\r
-       {\r
-               printf("iVoiceInfo < 0\n");\r
-               return false;\r
-       }\r
-\r
-       return true;\r
-}\r
-\r
-int plugin_LoadVoice(const char* language, ttsp_voice_type_e type)\r
-{\r
-       return 0;\r
-}\r
-\r
-int plugin_UnloadVoice(const char* language, ttsp_voice_type_e type)\r
-{\r
-       return 0;\r
-}\r
-\r
-void plugin_SetDaemonAPIs(ttspd_funcs_s const * pAPIs)\r
-{\r
-       gpDaemonAPIs = pAPIs;\r
-}\r
+/*
+ * Samsung TTS
+ * Copyright 2012-2014  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "plugin_internal.h"
+#include "_SlpSmtApis.h"
+
+
+// Once eigine was initialize, that means gpDaemonAPIs and its members are not NULL.
+// So we do not need to check whether this is NULL, nor its members are NULL.
+static ttspd_funcs_s const * gpDaemonAPIs = NULL;
+
+
+int plugin_Initialize(ttspe_result_cb const pfnCallBack)
+{
+       int r = SLPSMT_Initialize(pfnCallBack);
+       printf(">>>plugin Initialize() returns %d.\n", r);
+       return r;
+}
+
+int plugin_Finalize(void)
+{
+       int r = SLPSMT_Finalize();
+       printf(">>>plugin Initialize() returns %d.\n", r);
+       return r;
+}
+
+int plugin_SynthesizeText(char const *pszLanguage, int eVoiceType_0,  char const *pszTextUtf8,
+                       int eSpeechSpeed_0, void* pUserParam)
+{
+       int               iVoiceInfo   = -1;
+       int eVoiceType   = eVoiceType_0;
+       int     eSpeechSpeed = eSpeechSpeed_0;
+
+       int ThreadId = SLPSMT_GetWorkingThreadId();
+       printf(">>>plugin SynthesizeText()\n");
+       if (ThreadId != -1)
+       {
+       printf(">>>  A new text is comming into the TTS engine, while Synthesizing.\n");
+       printf(">>>  The text would be pushed into the thread queue.\n");
+       }
+       printf(">>>  ThreadId = %d\n", ThreadId);
+       printf(">>>  pUserParam = 0x%x\n", (unsigned int) pUserParam);
+
+       printf(">>>  eSpeechSpeed = %d\n", eSpeechSpeed);
+       printf(">>>  pszLanguage  = %s\n", pszLanguage);
+       printf(">>>  eVoiceType   = %s\n", //eVoiceType==TTSPE_VCTYPE_DEFAULT ? "TTSPE_VCTYPE_DEFAULT" :
+                                    eVoiceType==TTSP_VOICE_TYPE_MALE    ? "TTSP_VOICE_TYPE_MALE"    :
+                                    eVoiceType==TTSP_VOICE_TYPE_FEMALE  ? "TTSP_VOICE_TYPE_FEMALE"  :
+                                    eVoiceType==TTSP_VOICE_TYPE_CHILD   ? "TTSP_VOICE_TYPE_CHILD"   : ""
+       );
+
+       SLPSMT_SetSpeechSpeed(eSpeechSpeed);
+
+       // set voice
+       iVoiceInfo = SLPSMT_GetiVoiceInfoEx(pszLanguage, eVoiceType);
+       if (iVoiceInfo < 0)
+       {
+               printf("iVoiceInfo < 0\n");
+               return TTSP_ERROR_INVALID_VOICE;
+       }
+
+       return SLPSMT_SynthesizeText(iVoiceInfo, pszTextUtf8, pUserParam);
+}
+
+int plugin_StopSynthesis(void)
+{
+       return SLPSMT_StopSynthesis();
+}
+
+int plugin_ForeachVoices(ttspe_supported_voice_cb callback, void* user_data)
+{
+       if(NULL == callback)
+               return TTSP_ERROR_INVALID_PARAMETER;
+
+       ttspe_voice_list_s pVoiceList;
+       SLPSMT_SetVoiceList(&pVoiceList);
+
+       int i = 0;
+
+       ttspe_voice_info_s* temp = pVoiceList.voice_info;
+
+       for(i=0 ; i < pVoiceList.size; i++)
+       {
+               if (false == callback(temp[i].lang, temp[i].vctype, user_data))
+               {
+                       printf(">> plugin_ForeachVoices(), callback fail!!\n");
+                       break;
+               }
+       }
+
+       return TTSP_ERROR_NONE;
+}
+
+bool plugin_IsValidVoice(const char* language, int type)
+{
+       if (NULL == language)
+               return TTSP_ERROR_INVALID_PARAMETER;
+
+       int iVoiceInfo = SLPSMT_GetiVoiceInfoEx((char* )language, type);
+
+       if (iVoiceInfo < 0)
+       {
+               printf("iVoiceInfo < 0\n");
+               return false;
+       }
+
+       return true;
+}
+
+int plugin_LoadVoice(const char* language, int type)
+{
+       return 0;
+}
+
+int plugin_UnloadVoice(const char* language, int type)
+{
+       return 0;
+}
+
+void plugin_SetDaemonAPIs(ttspd_funcs_s const * pAPIs)
+{
+       gpDaemonAPIs = pAPIs;
+}
index bd3e4ee..4037ba0 100644 (file)
@@ -1,79 +1,79 @@
-/*\r
- * Samsung TTS\r
- * Copyright 2012-2014  Samsung Electronics Co., Ltd\r
- *\r
- * Licensed under the Flora License, Version 1.1 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://floralicense.org/license/\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-\r
-#ifndef _PLUGIN_INTERNAL_H_\r
-#define _PLUGIN_INTERNAL_H_\r
-\r
-#include <ttsp.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#define ENGINE_UUID    "27F277E9-BBC4-4dca-B553-D9884A3CDAA0"\r
-#define ENGINE_NAME    "Samsung TTS"\r
-#define ENGINE_UG_NAME "tts_smt_setting_ug.so"\r
-\r
-#define VTTS_VOICE_NAME_BUF_SIZE 8\r
-\r
-typedef char*  ttspe_language;\r
-\r
-typedef struct {\r
-       ttspe_language    lang;    /**< Language */\r
-       ttsp_voice_type_e vctype;  /**< Voice type */\r
-} ttspe_voice_info_s;\r
-\r
-typedef struct {\r
-       ttspe_voice_info_s* voice_info;  /**< Voice info array */\r
-       int                 size;        /**< size of array */\r
-} ttspe_voice_list_s;\r
-\r
-int plugin_Initialize(ttspe_result_cb const cb_func);\r
-\r
-int plugin_Finalize(void);\r
-\r
-int plugin_SynthesizeText\r
-(\r
-  char    const   *pszLanguage,\r
-  ttsp_voice_type_e const   eVoiceType,\r
-  char              const * pszTextUtf8,\r
-  ttsp_speed_e     const   eSpeechSpeed,\r
-  void                    * pUserParam\r
-);\r
-\r
-int plugin_StopSynthesis(void);\r
-\r
-int plugin_ForeachVoices(ttspe_supported_voice_cb callback, void* user_data);\r
-\r
-bool plugin_IsValidVoice(const char* language, ttsp_voice_type_e type);\r
-\r
-int plugin_SetDefaultSpeechSpeed(ttsp_speed_e const  SpeechSpeed);\r
-\r
-int plugin_LoadVoice(const char* language, ttsp_voice_type_e type);\r
-\r
-int plugin_UnloadVoice(const char* language, ttsp_voice_type_e type);\r
-\r
-void plugin_SetDaemonAPIs (ttspd_funcs_s const * pAPIs);\r
-\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* _PLUGIN_INTERNAL_H_ */\r
+/*
+ * Samsung TTS
+ * Copyright 2012-2014  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef _PLUGIN_INTERNAL_H_
+#define _PLUGIN_INTERNAL_H_
+
+#include <ttsp.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ENGINE_UUID    "27F277E9-BBC4-4dca-B553-D9884A3CDAA0"
+#define ENGINE_NAME    "Samsung TTS"
+#define ENGINE_UG_NAME "tts_smt_setting_ug.so"
+
+#define VTTS_VOICE_NAME_BUF_SIZE 8
+
+typedef char*  ttspe_language;
+
+typedef struct {
+       ttspe_language    lang;    /**< Language */
+       int vctype;  /**< Voice type */
+} ttspe_voice_info_s;
+
+typedef struct {
+       ttspe_voice_info_s* voice_info;  /**< Voice info array */
+       int                 size;        /**< size of array */
+} ttspe_voice_list_s;
+
+int plugin_Initialize(ttspe_result_cb const cb_func);
+
+int plugin_Finalize(void);
+
+int plugin_SynthesizeText
+(
+  char    const   *pszLanguage,
+  int const   eVoiceType,
+  char              const * pszTextUtf8,
+  int     const   eSpeechSpeed,
+  void                    * pUserParam
+);
+
+int plugin_StopSynthesis(void);
+
+int plugin_ForeachVoices(ttspe_supported_voice_cb callback, void* user_data);
+
+bool plugin_IsValidVoice(const char* language, int type);
+
+int plugin_SetDefaultSpeechSpeed(int const  SpeechSpeed);
+
+int plugin_LoadVoice(const char* language, int type);
+
+int plugin_UnloadVoice(const char* language, int type);
+
+void plugin_SetDaemonAPIs (ttspd_funcs_s const * pAPIs);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PLUGIN_INTERNAL_H_ */
index a8505ac..83fcf70 100644 (file)
@@ -1,77 +1,77 @@
-/*\r
- * Samsung TTS\r
- * Copyright 2012-2014  Samsung Electronics Co., Ltd\r
- *\r
- * Licensed under the Flora License, Version 1.1 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://floralicense.org/license/\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "stdio.h"\r
-#include "memory.h"\r
-\r
-#include <ttsp.h>\r
-#include "plugin_internal.h"\r
-\r
-char * _psz             = NULL;\r
-char * _pszEngineUUID;\r
-char * _pszEngineName;\r
-char * _pszEngineUgName;\r
-\r
-\r
-\r
-int ttsp_load_engine(ttspd_funcs_s* pdfuncs, ttspe_funcs_s* pefuncs)\r
-{\r
-  if (! pdfuncs)\r
-  {\r
-    printf("parameter1, pdfuncs is NULL.");\r
-    return TTSP_ERROR_INVALID_PARAMETER;\r
-  }\r
-  if (! pefuncs)\r
-  {\r
-    printf("parameter2, pefuncs is NULL.");\r
-    return TTSP_ERROR_INVALID_PARAMETER;\r
-  }\r
-\r
-  pefuncs->size              = sizeof(ttspe_funcs_s);\r
-  pefuncs->version           = 1;\r
-\r
-  pefuncs->initialize        = plugin_Initialize;\r
-  pefuncs->deinitialize      = plugin_Finalize;\r
-\r
-  pefuncs->start_synth       = plugin_SynthesizeText;\r
-  pefuncs->cancel_synth      = plugin_StopSynthesis;\r
-\r
-  pefuncs->foreach_voices    = plugin_ForeachVoices;\r
-  pefuncs->is_valid_voice    = plugin_IsValidVoice;\r
-\r
-  pefuncs->load_voice       = plugin_LoadVoice;\r
-  pefuncs->unload_voice             = plugin_UnloadVoice;\r
-\r
-  plugin_SetDaemonAPIs(pdfuncs);\r
-\r
-  printf("[SMT] ttsp_load_engine() : version(%d), (6.20110527), size(%d)\n", pefuncs->version, pefuncs->size);\r
-\r
-  return TTSP_ERROR_NONE;\r
-}\r
-\r
-void ttsp_unload_engine(void)\r
-{\r
-  printf("[SMT] ttsp_unload_engine() \n");\r
-}\r
-\r
-int ttsp_get_engine_info(ttsp_engine_info_cb callback, void* user_data)\r
-{\r
-\r
-       callback(ENGINE_UUID, ENGINE_NAME, ENGINE_UG_NAME, false, user_data);\r
-\r
-       return 0;\r
-}\r
+/*
+ * Samsung TTS
+ * Copyright 2012-2014  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "stdio.h"
+#include "memory.h"
+
+#include <ttsp.h>
+#include "plugin_internal.h"
+
+char * _psz             = NULL;
+char * _pszEngineUUID;
+char * _pszEngineName;
+char * _pszEngineUgName;
+
+
+
+int ttsp_load_engine(ttspd_funcs_s* pdfuncs, ttspe_funcs_s* pefuncs)
+{
+  if (! pdfuncs)
+  {
+    printf("parameter1, pdfuncs is NULL.");
+    return TTSP_ERROR_INVALID_PARAMETER;
+  }
+  if (! pefuncs)
+  {
+    printf("parameter2, pefuncs is NULL.");
+    return TTSP_ERROR_INVALID_PARAMETER;
+  }
+
+  pefuncs->size              = sizeof(ttspe_funcs_s);
+  pefuncs->version           = 1;
+
+  pefuncs->initialize        = plugin_Initialize;
+  pefuncs->deinitialize      = plugin_Finalize;
+
+  pefuncs->start_synth       = plugin_SynthesizeText;
+  pefuncs->cancel_synth      = plugin_StopSynthesis;
+
+  pefuncs->foreach_voices    = plugin_ForeachVoices;
+  pefuncs->is_valid_voice    = plugin_IsValidVoice;
+
+  pefuncs->load_voice       = plugin_LoadVoice;
+  pefuncs->unload_voice             = plugin_UnloadVoice;
+
+  plugin_SetDaemonAPIs(pdfuncs);
+
+  printf("[SMT] ttsp_load_engine() : version(%d), (6.20110527), size(%d)\n", pefuncs->version, pefuncs->size);
+
+  return TTSP_ERROR_NONE;
+}
+
+void ttsp_unload_engine(void)
+{
+  printf("[SMT] ttsp_unload_engine() \n");
+}
+
+int ttsp_get_engine_info(ttsp_engine_info_cb callback, void* user_data)
+{
+
+       callback(ENGINE_UUID, ENGINE_NAME, ENGINE_UG_NAME, false, user_data);
+
+       return 0;
+}