From: HyungKyu Song Date: Fri, 15 Feb 2013 15:55:50 +0000 (+0900) Subject: Tizen 2.0 Release X-Git-Tag: submit/tizen_2.0/20130215.192247^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_2.0;p=platform%2Fcore%2Fuifw%2Flibttssmt.git Tizen 2.0 Release --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..aed715a --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Wonyoung Lee +Sungchan Kim +Samsung Multimedia R&D Group + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..9a61c57 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,75 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ttssmt) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}") +SET(LIBDIR "${PREFIX}/lib/voice/tts/1.0/engine") +SET(USRLIBDIR "${PREFIX}/lib") +SET(INCLUDEDIR "${PREFIX}/include") +SET(INCLUDEDIRGLIB "${PREFIX}/include/glib-2.0") +SET(INCLUDEDIRLIB "${PREFIX}/lib/glib-2.0/include") +SET(LIBRARY_NAME "smt") +SET(VERSION 0.0.1) + +SET(SRCS + src/ttsp.c + src/plugin_internal.cpp + src/_SlpSmtApis.cpp + ) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${INCLUDEDIR}) +INCLUDE_DIRECTORIES(${INCLUDEDIRLIB}) +INCLUDE_DIRECTORIES(${INCLUDEDIRGLIB}) + +## Dependent packages ## +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED + glib-2.0 + tts +) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +########################### +# DEFINITION TTS FEATURES # +########################### +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DSLP" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCOMPILE_FEATURE_TTS_SLIM") +#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D__FIXED_C" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DKOREAN" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DUSENGLISH" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCHINESE" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDICTIONARY" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC" ) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0") +#SET(CMAKE_C_FLAGS_RELEASE "-O2") +SET(CMAKE_EXE_LINKER_FLAGS "-Wall,--as-needed") + +########################### +# COMPILE AS RELEASE MODE # +########################### +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") + +#ADD_LIBRARY(${LIBRARY_NAME} STATIC ${LIB_SRCS}) +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ) + +#SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" MATCHES "^arm.*") +TARGET_LINK_LIBRARIES(${PROJECT_NAME} -Llib/arm -lsmt ${pkgs_LDFLAGS}) +INSTALL(FILES lib/arm/libsmt.so DESTINATION ${USRLIBDIR}) +ELSE("${ARCH}" MATCHES "^arm.*") +TARGET_LINK_LIBRARIES(${PROJECT_NAME} -Llib/i386 -lsmt ${pkgs_LDFLAGS}) +INSTALL(FILES lib/i386/libsmt.so DESTINATION ${USRLIBDIR}) +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) diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100755 index 0000000..9c95663 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.0 (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. + diff --git a/NOTICE b/NOTICE new file mode 100755 index 0000000..3997999 --- /dev/null +++ b/NOTICE @@ -0,0 +1,4 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE file for Flora License terms and conditions. + diff --git a/README b/README new file mode 100755 index 0000000..e69de29 diff --git a/lib/arm/libsmt.so b/lib/arm/libsmt.so new file mode 100755 index 0000000..cfb4635 Binary files /dev/null and b/lib/arm/libsmt.so differ diff --git a/lib/i386/libsmt.so b/lib/i386/libsmt.so new file mode 100755 index 0000000..696bed4 Binary files /dev/null and b/lib/i386/libsmt.so differ diff --git a/libttssmt.manifest b/libttssmt.manifest new file mode 100755 index 0000000..357525a --- /dev/null +++ b/libttssmt.manifest @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/libttssmt.spec b/packaging/libttssmt.spec new file mode 100755 index 0000000..5231568 --- /dev/null +++ b/packaging/libttssmt.spec @@ -0,0 +1,41 @@ +#sbs-git:slp/pkgs/l/libttssmt libttssmt 0.0.15 9c82c715d55cf32bb3d69112526145654ec2fbcc +%define _optdir /opt +%define _appdir %{_optdir}/apps + + + +Name: libttssmt +Summary: Text To Speech smt plugin shared library +Version: 0.0.28 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO_BE/FILLED_IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(tts) + +provides : libsmt.so + +%description +Description: Text To Speech smt plugin shared library + + +%prep +%setup -q + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} + +%build +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%files +%manifest libttssmt.manifest +%defattr(-,root,root,-) +%{_libdir}/voice/tts/1.0/engine/* +/usr/share/voice/tts/smt_vdata/* +%{_libdir}/libsmt.so* diff --git a/src/SMTApis.h b/src/SMTApis.h new file mode 100755 index 0000000..b5406c1 --- /dev/null +++ b/src/SMTApis.h @@ -0,0 +1,103 @@ +/* + * Samsung TTS + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (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 + + +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 + +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); + + +typedef enum +{ + eSMTSpeechSpeed_VerySlow, + eSMTSpeechSpeed_Slow, + eSMTSpeechSpeed_Normal, + eSMTSpeechSpeed_Fast, + eSMTSpeechSpeed_VeryFast, +} etypeSpeechSpeed; + +void SMTSetSpeechSpeed(etypeSpeechSpeed const speed); + +int SMTSaveWave(char* pszFileName, short* pOutData, int const nDataSize); + +#ifdef __cplusplus +} +#endif + +#endif //_SMTAPIS_H_ + + diff --git a/src/_SlpSmtApis.cpp b/src/_SlpSmtApis.cpp new file mode 100755 index 0000000..567a2ae --- /dev/null +++ b/src/_SlpSmtApis.cpp @@ -0,0 +1,636 @@ +/* + * Samsung TTS + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (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 +#include +#include + +#include + + + + +#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; + ttsp_voice_type_e const eVoiceType; + +}; + + +static char const _pszKorean [] = "ko_KR"; +static char const _pszUSEnglish [] = "en_US"; +static char const _pszChinese [] = "zh_CN"; + + +static char const _pszUKEnglish [] = "en_GB"; +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 _sszChinese = sizeof(_pszChinese); +static unsigned int const _sszUKEnglish = sizeof(_pszUKEnglish); +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 }, + { _pszChinese , _sszChinese , TTSP_VOICE_TYPE_FEMALE }, + + { _pszUKEnglish , _sszUKEnglish , 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_CHINESE_WOMAN 2 +#define VOICE_INDEX_UKENGLISH_WOMAN 3 +#define VOICE_INDEX_GERMAN_WOMAN 4 +#define VOICE_INDEX_SPANISH_WOMAN 5 +#define VOICE_INDEX_FRENCH_WOMAN 6 +#define VOICE_INDEX_ITALIAN_WOMAN 7 + + + + +typedef struct _TypeThreadQueueNode TypeThreadQueueNode; +struct _TypeThreadQueueNode +{ + int iVoiceInfo; + char * pszTextUtf8; + void * pUserParam; + TypeThreadQueueNode * pNext; +}; + +static struct _global +{ + ttspe_result_cb pfnCallback; + ttsp_speed_e 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_GetPszChinese (void) { return _pszChinese ; } +char const * SLPSMT_GetPszUKEnglish (void) { return _pszUKEnglish ; } +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; + +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(ttsp_speed_e const eSpeechSpeed) +{ + switch (eSpeechSpeed) + { + case TTSP_SPEED_VERY_FAST : + case TTSP_SPEED_FAST : + case TTSP_SPEED_SLOW : + case TTSP_SPEED_VERY_SLOW : + case TTSP_SPEED_NORMAL : _g.eSpeechSpeed = eSpeechSpeed; break; + default : _g.eSpeechSpeed = TTSP_SPEED_NORMAL; break; + } +} + +int SLPSMT_GetiVoiceInfo(char* const pszLanguage, ttsp_voice_type_e 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; + _g.ThreadId = -1; + + 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_CHINESE_WOMAN : SMTSet_Language(eCHINESE , 1, 0); break; + + case VOICE_INDEX_UKENGLISH_WOMAN : SMTSet_Language(eGBENGLISH , 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 TTSP_SPEED_VERY_FAST : SMTSetSpeechSpeed(eSMTSpeechSpeed_VeryFast); break; + case TTSP_SPEED_FAST : SMTSetSpeechSpeed(eSMTSpeechSpeed_Fast ); break; + case TTSP_SPEED_SLOW : SMTSetSpeechSpeed(eSMTSpeechSpeed_Slow ); break; + case TTSP_SPEED_VERY_SLOW : 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_CANCEL : printf("TTSPE_CBEVENT_SYNTH_CANCEL\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 const cbreturn = _g.pfnCallback(eEvent, pPCMs, n, 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 > +// diff --git a/src/_SlpSmtApis.h b/src/_SlpSmtApis.h new file mode 100755 index 0000000..d2f4042 --- /dev/null +++ b/src/_SlpSmtApis.h @@ -0,0 +1,44 @@ +/* + * Samsung TTS + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (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 +#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(ttsp_speed_e const eSpeechSpeed); +int SLPSMT_GetiVoiceInfo (char* const pszLanguage, ttsp_voice_type_e 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_GetPszChinese (void); +char const * SLPSMT_GetPszUKEnglish (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__ diff --git a/src/plugin_internal.cpp b/src/plugin_internal.cpp new file mode 100755 index 0000000..4171774 --- /dev/null +++ b/src/plugin_internal.cpp @@ -0,0 +1,194 @@ +/* + * Samsung TTS + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (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 +#include +#include +#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, ttsp_voice_type_e eVoiceType_0, char const * pszTextUtf8, + ttsp_speed_e eSpeechSpeed_0, void* pUserParam) +{ + int iVoiceInfo = -1; + ttsp_voice_type_e eVoiceType = eVoiceType_0; + ttsp_speed_e 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 = %s\n", //eSpeechSpeed==TTSPE_SPEED_DEFAULT ? "TTSPE_SPEED_DEFAULT" : + eSpeechSpeed==TTSP_SPEED_VERY_FAST ? "TTSP_SPEED_VERY_FAST" : + eSpeechSpeed==TTSP_SPEED_FAST ? "TTSP_SPEED_FAST" : + eSpeechSpeed==TTSP_SPEED_NORMAL ? "TTSP_SPEED_NORMAL" : + eSpeechSpeed==TTSP_SPEED_SLOW ? "TTSP_SPEED_SLOW" : + eSpeechSpeed==TTSP_SPEED_VERY_SLOW ? "TTSP_SPEED_VERY_SLOW" : "" + ); + 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" : + eVoiceType==TTSP_VOICE_TYPE_USER1 ? "TTSP_VOICE_TYPE_USER1" : + eVoiceType==TTSP_VOICE_TYPE_USER2 ? "TTSP_VOICE_TYPE_USER2" : + eVoiceType==TTSP_VOICE_TYPE_USER3 ? "TTSP_VOICE_TYPE_USER3" : "" + ); + + SLPSMT_SetSpeechSpeed(eSpeechSpeed); + + printf(">>> \n"); + printf(">>> eSpeechSpeed = %s\n", //eSpeechSpeed==TTSP_SPEED_DEFAULT ? "TTSPE_SPEED_DEFAULT" : + eSpeechSpeed==TTSP_SPEED_VERY_FAST ? "TTSPE_SPEED_VERY_FAST" : + eSpeechSpeed==TTSP_SPEED_FAST ? "TTSPE_SPEED_FAST" : + eSpeechSpeed==TTSP_SPEED_NORMAL ? "TTSPE_SPEED_NORMAL" : + eSpeechSpeed==TTSP_SPEED_SLOW ? "TTSPE_SPEED_SLOW" : + eSpeechSpeed==TTSP_SPEED_VERY_SLOW ? "TTSPE_SPEED_VERY_SLOW" : "" + ); + printf(">>> pszLanguage = %s\n", pszLanguage); + printf(">>> eVoiceType = %s\n", //eVoiceType==TTSPE_VCTYPE_DEFAULT ? "TTSPE_VCTYPE_DEFAULT" : + eVoiceType==TTSP_VOICE_TYPE_MALE ? "TTSPE_VCTYPE_MALE" : + eVoiceType==TTSP_VOICE_TYPE_FEMALE ? "TTSPE_VCTYPE_FEMALE" : + eVoiceType==TTSP_VOICE_TYPE_CHILD ? "TTSPE_VCTYPE_CHILD" : + eVoiceType==TTSP_VOICE_TYPE_USER1 ? "TTSPE_VCTYPE_USER1" : + eVoiceType==TTSP_VOICE_TYPE_USER2 ? "TTSPE_VCTYPE_USER2" : + eVoiceType==TTSP_VOICE_TYPE_USER3 ? "TTSPE_VCTYPE_USER3" : "" + ); + + // set voice + iVoiceInfo = SLPSMT_GetiVoiceInfo(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_GetAudioFormat(ttsp_audio_type_e* pType, int* pSamplingRate, int* pnChannels) +{ + if (pType && pSamplingRate && pnChannels) + { + *pSamplingRate = 16000; + *pnChannels = 1; + *pType = TTSP_AUDIO_TYPE_RAW; + return TTSP_ERROR_NONE; + } + return TTSP_ERROR_INVALID_PARAMETER; +} + + + + +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, ttsp_voice_type_e type) +{ + if (NULL == language) + return TTSP_ERROR_INVALID_PARAMETER; + + int iVoiceInfo = SLPSMT_GetiVoiceInfo((char* )language, type); + + if (iVoiceInfo < 0) + { + printf("iVoiceInfo < 0\n"); + return false; + } + + return true; +} + +int plugin_SetSettingInfo(const char* key, const char* value) +{ + if (NULL == key || NULL == value) { + return TTSP_ERROR_INVALID_PARAMETER; + } + + printf("Set engine setting : key(%s) value(%s)\n", key, value); + + return TTSP_ERROR_NONE; +} + +int plugin_ForeachEngineSetting(ttspe_engine_setting_cb callback, void* user_data) +{ + if (false == callback("Sample_key1", "Sample_value1", user_data)) + return TTSP_ERROR_NONE; + + if (false == callback("Sample_key2", "Sample_value2", user_data)) + return TTSP_ERROR_NONE; + + return TTSP_ERROR_NONE; +} + +void plugin_SetDaemonAPIs(ttspd_funcs_s const * pAPIs) +{ + gpDaemonAPIs = pAPIs; +} diff --git a/src/plugin_internal.h b/src/plugin_internal.h new file mode 100755 index 0000000..99cb633 --- /dev/null +++ b/src/plugin_internal.h @@ -0,0 +1,81 @@ +/* + * Samsung TTS + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (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 + +#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 */ + ttsp_voice_type_e 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, + ttsp_voice_type_e const eVoiceType, + char const * pszTextUtf8, + ttsp_speed_e const eSpeechSpeed, + void * pUserParam +); + +int plugin_StopSynthesis(void); + +int plugin_GetAudioFormat(ttsp_audio_type_e* pType, int* pSamplingRate, int* pnChannels); + +int plugin_ForeachVoices(ttspe_supported_voice_cb callback, void* user_data); + +bool plugin_IsValidVoice(const char* language, ttsp_voice_type_e type); + +int plugin_SetDefaultSpeechSpeed(ttsp_speed_e const SpeechSpeed); + +int plugin_SetSettingInfo(const char* key, const char* value); + +int plugin_ForeachEngineSetting(ttspe_engine_setting_cb callback, void* user_data); + +void plugin_SetDaemonAPIs (ttspd_funcs_s const * pAPIs); + + + +#ifdef __cplusplus +} +#endif + +#endif /* _PLUGIN_INTERNAL_H_ */ diff --git a/src/ttsp.c b/src/ttsp.c new file mode 100755 index 0000000..51bfc5b --- /dev/null +++ b/src/ttsp.c @@ -0,0 +1,78 @@ +/* + * Samsung TTS + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.0 (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 +#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->get_audio_format = plugin_GetAudioFormat; + + pefuncs->foreach_voices = plugin_ForeachVoices; + pefuncs->is_valid_voice = plugin_IsValidVoice; + + pefuncs->set_engine_setting = plugin_SetSettingInfo; + pefuncs->foreach_engine_setting = plugin_ForeachEngineSetting; + + 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; +} diff --git a/vdata/smt_de_DE.lng b/vdata/smt_de_DE.lng new file mode 100644 index 0000000..16b9f18 Binary files /dev/null and b/vdata/smt_de_DE.lng differ diff --git a/vdata/smt_de_DE_f01.am b/vdata/smt_de_DE_f01.am new file mode 100644 index 0000000..4edf9c9 Binary files /dev/null and b/vdata/smt_de_DE_f01.am differ diff --git a/vdata/smt_de_DE_f01.cfg b/vdata/smt_de_DE_f01.cfg new file mode 100644 index 0000000..23e53cd Binary files /dev/null and b/vdata/smt_de_DE_f01.cfg differ diff --git a/vdata/smt_de_DE_f01.dt b/vdata/smt_de_DE_f01.dt new file mode 100644 index 0000000..980cf48 Binary files /dev/null and b/vdata/smt_de_DE_f01.dt differ diff --git a/vdata/smt_de_DE_f01.qs b/vdata/smt_de_DE_f01.qs new file mode 100644 index 0000000..4d0f97e Binary files /dev/null and b/vdata/smt_de_DE_f01.qs differ diff --git a/vdata/smt_en_US.lng b/vdata/smt_en_US.lng new file mode 100644 index 0000000..28442a9 Binary files /dev/null and b/vdata/smt_en_US.lng differ diff --git a/vdata/smt_en_US_f01.am b/vdata/smt_en_US_f01.am new file mode 100644 index 0000000..3b0bdb8 Binary files /dev/null and b/vdata/smt_en_US_f01.am differ diff --git a/vdata/smt_en_US_f01.cfg b/vdata/smt_en_US_f01.cfg new file mode 100644 index 0000000..5005438 Binary files /dev/null and b/vdata/smt_en_US_f01.cfg differ diff --git a/vdata/smt_en_US_f01.dt b/vdata/smt_en_US_f01.dt new file mode 100644 index 0000000..b7ad79a Binary files /dev/null and b/vdata/smt_en_US_f01.dt differ diff --git a/vdata/smt_en_US_f01.qs b/vdata/smt_en_US_f01.qs new file mode 100644 index 0000000..fed56fa Binary files /dev/null and b/vdata/smt_en_US_f01.qs differ diff --git a/vdata/smt_es_ES.lng b/vdata/smt_es_ES.lng new file mode 100644 index 0000000..03b53cb Binary files /dev/null and b/vdata/smt_es_ES.lng differ diff --git a/vdata/smt_es_ES_f01.am b/vdata/smt_es_ES_f01.am new file mode 100644 index 0000000..e9f7a28 Binary files /dev/null and b/vdata/smt_es_ES_f01.am differ diff --git a/vdata/smt_es_ES_f01.cfg b/vdata/smt_es_ES_f01.cfg new file mode 100644 index 0000000..f0cdd4c Binary files /dev/null and b/vdata/smt_es_ES_f01.cfg differ diff --git a/vdata/smt_es_ES_f01.dt b/vdata/smt_es_ES_f01.dt new file mode 100644 index 0000000..7ba3003 Binary files /dev/null and b/vdata/smt_es_ES_f01.dt differ diff --git a/vdata/smt_es_ES_f01.qs b/vdata/smt_es_ES_f01.qs new file mode 100644 index 0000000..39be1c6 Binary files /dev/null and b/vdata/smt_es_ES_f01.qs differ diff --git a/vdata/smt_fr_FR.lng b/vdata/smt_fr_FR.lng new file mode 100755 index 0000000..3d8325c Binary files /dev/null and b/vdata/smt_fr_FR.lng differ diff --git a/vdata/smt_fr_FR_f01.am b/vdata/smt_fr_FR_f01.am new file mode 100755 index 0000000..31dd1be Binary files /dev/null and b/vdata/smt_fr_FR_f01.am differ diff --git a/vdata/smt_fr_FR_f01.cfg b/vdata/smt_fr_FR_f01.cfg new file mode 100755 index 0000000..bcd6f8a Binary files /dev/null and b/vdata/smt_fr_FR_f01.cfg differ diff --git a/vdata/smt_fr_FR_f01.dt b/vdata/smt_fr_FR_f01.dt new file mode 100755 index 0000000..ce66425 Binary files /dev/null and b/vdata/smt_fr_FR_f01.dt differ diff --git a/vdata/smt_fr_FR_f01.qs b/vdata/smt_fr_FR_f01.qs new file mode 100755 index 0000000..1721bde Binary files /dev/null and b/vdata/smt_fr_FR_f01.qs differ diff --git a/vdata/smt_it_IT.lng b/vdata/smt_it_IT.lng new file mode 100644 index 0000000..d644dc3 Binary files /dev/null and b/vdata/smt_it_IT.lng differ diff --git a/vdata/smt_it_IT_f01.am b/vdata/smt_it_IT_f01.am new file mode 100644 index 0000000..f35c185 Binary files /dev/null and b/vdata/smt_it_IT_f01.am differ diff --git a/vdata/smt_it_IT_f01.cfg b/vdata/smt_it_IT_f01.cfg new file mode 100644 index 0000000..58d2400 Binary files /dev/null and b/vdata/smt_it_IT_f01.cfg differ diff --git a/vdata/smt_it_IT_f01.dt b/vdata/smt_it_IT_f01.dt new file mode 100644 index 0000000..171d921 Binary files /dev/null and b/vdata/smt_it_IT_f01.dt differ diff --git a/vdata/smt_it_IT_f01.qs b/vdata/smt_it_IT_f01.qs new file mode 100644 index 0000000..0e63ef8 Binary files /dev/null and b/vdata/smt_it_IT_f01.qs differ diff --git a/vdata/smt_ko_KR.lng b/vdata/smt_ko_KR.lng new file mode 100644 index 0000000..2e51f89 Binary files /dev/null and b/vdata/smt_ko_KR.lng differ diff --git a/vdata/smt_ko_KR_f01.am b/vdata/smt_ko_KR_f01.am new file mode 100644 index 0000000..56a31a0 Binary files /dev/null and b/vdata/smt_ko_KR_f01.am differ diff --git a/vdata/smt_ko_KR_f01.cfg b/vdata/smt_ko_KR_f01.cfg new file mode 100644 index 0000000..dd9e202 Binary files /dev/null and b/vdata/smt_ko_KR_f01.cfg differ diff --git a/vdata/smt_ko_KR_f01.dt b/vdata/smt_ko_KR_f01.dt new file mode 100644 index 0000000..5c51359 Binary files /dev/null and b/vdata/smt_ko_KR_f01.dt differ diff --git a/vdata/smt_ko_KR_f01.qs b/vdata/smt_ko_KR_f01.qs new file mode 100644 index 0000000..1416266 Binary files /dev/null and b/vdata/smt_ko_KR_f01.qs differ diff --git a/vdata/smt_ko_KR_f02.am b/vdata/smt_ko_KR_f02.am new file mode 100644 index 0000000..fe601e7 Binary files /dev/null and b/vdata/smt_ko_KR_f02.am differ diff --git a/vdata/smt_ko_KR_f02.cfg b/vdata/smt_ko_KR_f02.cfg new file mode 100644 index 0000000..e59a3c2 Binary files /dev/null and b/vdata/smt_ko_KR_f02.cfg differ diff --git a/vdata/smt_ko_KR_f02.dt b/vdata/smt_ko_KR_f02.dt new file mode 100644 index 0000000..a2d9175 Binary files /dev/null and b/vdata/smt_ko_KR_f02.dt differ diff --git a/vdata/smt_ko_KR_f02.qs b/vdata/smt_ko_KR_f02.qs new file mode 100644 index 0000000..9303d37 Binary files /dev/null and b/vdata/smt_ko_KR_f02.qs differ