Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:58 +0000 (01:50 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:58 +0000 (01:50 +0900)
23 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE.APLv2 [new file with mode: 0755]
NOTICE [new file with mode: 0755]
inc/FUixSpeech.h [new file with mode: 0644]
inc/FUixSpeechISpeechToTextEventListener.h [new file with mode: 0644]
inc/FUixSpeechITextToSpeechEventListener.h [new file with mode: 0644]
inc/FUixSpeechSpeechToText.h [new file with mode: 0644]
inc/FUixSpeechSpeechToTextTypes.h [new file with mode: 0644]
inc/FUixSpeechTextToSpeech.h [new file with mode: 0644]
inc/FUixSpeechTextToSpeechTypes.h [new file with mode: 0644]
osp-speech.manifest [new file with mode: 0644]
osp-speech.pc.in [new file with mode: 0755]
packaging/osp-speech.spec [new file with mode: 0755]
src/inc/FUixSpeech_ITextToSpeech.h [new file with mode: 0644]
src/stt/CMakeLists.txt [new file with mode: 0755]
src/stt/FUixSpeechSpeechToText.cpp [new file with mode: 0644]
src/stt/FUixSpeech_SpeechToTextImpl.cpp [new file with mode: 0644]
src/stt/FUixSpeech_SpeechToTextImpl.h [new file with mode: 0644]
src/tts/CMakeLists.txt [new file with mode: 0755]
src/tts/FUixSpeechTextToSpeech.cpp [new file with mode: 0644]
src/tts/FUixSpeech_TextToSpeechImpl.cpp [new file with mode: 0644]
src/tts/FUixSpeech_TextToSpeechImpl.h [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..32bdca2
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+SEONGOOK JEONG <so.jeong at samsung dot com>
+YOUNGIL SHIN <yi.shin at samsung dot com>
+DAEKYU SHIN <daekyu.shin at samsung dot com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..3d837d5
--- /dev/null
@@ -0,0 +1,50 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(osp-speech)
+
+SET(COMMON_INCLUDE_DIRS
+    ${CMAKE_SOURCE_DIR}/inc
+    ${CMAKE_SOURCE_DIR}/src/inc
+    /usr/include/osp
+    /usr/include/osp/base
+       )
+     
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -L/usr/lib/osp" )     
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+MACRO(OSP_STRIP _target)
+    SET_TARGET_PROPERTIES(${_target}
+       PROPERTIES
+       VERSION ${FULLVER}
+       SOVERSION ${MAJORVER}
+       CLEAN_DIRECT_OUTPUT 1
+       )
+       ADD_CUSTOM_COMMAND(TARGET ${this_target}
+    POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} 
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+    COMMENT "strip ${this_target}"
+               )   
+ENDMACRO(OSP_STRIP)
+
+ADD_SUBDIRECTORY(src/stt osp-stt)
+ADD_SUBDIRECTORY(src/tts osp-tts)
+
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp 
+                               FILES_MATCHING PATTERN "*.so*" 
+                               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                                          
+                                                                               GROUP_EXECUTE GROUP_READ
+                                                                               WORLD_EXECUTE WORLD_READ)
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug 
+                               FILES_MATCHING PATTERN "*.so*" 
+                               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                                          
+                                                                               GROUP_EXECUTE GROUP_READ
+                                                                               WORLD_EXECUTE WORLD_READ)
+                                                                               
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/uix FILES_MATCHING PATTERN "*.h")
+
+# pkgconfig file
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
\ No newline at end of file
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100755 (executable)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   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.
+
+   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,
+      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 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 in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) 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
+
+      (d) 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 Apache License to your work.
+
+      To apply the Apache 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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+
+   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 (executable)
index 0000000..0e0f016
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
diff --git a/inc/FUixSpeech.h b/inc/FUixSpeech.h
new file mode 100644 (file)
index 0000000..cb7b632
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file       FUixSpeech.h
+ * @brief      This is the header file for the %Speech namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Tizen::Uix::Speech namespace.
+ */
+
+#ifndef _FUIX_SPEECH_H_
+#define _FUIX_SPEECH_H_
+
+#include <FUixSpeechISpeechToTextEventListener.h>
+#include <FUixSpeechITextToSpeechEventListener.h>
+#include <FUixSpeechSpeechToText.h>
+#include <FUixSpeechSpeechToTextTypes.h>
+#include <FUixSpeechTextToSpeech.h>
+#include <FUixSpeechTextToSpeechTypes.h>
+
+/**
+ * @namespace Tizen::Uix::Speech
+ * @brief      This namespace contains the classes for the speech and its related functions.
+ * @since 2.0
+ *
+ * @remarks    @b Header @b %file: @b \#include @b <FUix.h> @n
+ *          @b Library : @b osp-speech-tts, @b osp-speech-stt
+ *
+ * The %Speech namespace provides easy and simplified speech recognition and synthesis methods. @n
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/uix/speech_to_text.htm">Speech-To-Text</a> and 
+ * <a href="../org.tizen.native.appprogramming/html/guide/uix/text_to_speech.htm">Text-To-Speech</a>.
+ *
+ * The following diagram illustrates the relationships between the classes belonging to the %Speech namespace.
+ * @image html uix_speech_using_the_apis_classdiagram.png
+ */
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+} } } // Tizen::Uix::Speech
+
+#endif  //_FUIX_SPEECH_H_
diff --git a/inc/FUixSpeechISpeechToTextEventListener.h b/inc/FUixSpeechISpeechToTextEventListener.h
new file mode 100644 (file)
index 0000000..ba16097
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechISpeechToTextEventListener.h
+ * @brief   This is the header file for the %ISpeechToTextEventListener interface.
+ *
+ * This header file contains the declarations of the %ISpeechToTextEventListener interface.
+ */
+
+#ifndef _FUIX_SPEECH_ISPEECH_TO_TEXT_EVENT_LISTENER_H_
+#define _FUIX_SPEECH_ISPEECH_TO_TEXT_EVENT_LISTENER_H_
+
+#include <FUixSpeechSpeechToTextTypes.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+/**
+ * @interface   ISpeechToTextEventListener
+ * @brief              This interface is a listener for speech recognition events.
+ *
+ * @since 2.0
+ *
+ * @remarks     @b Header @b %file: @b \#include @b <FUix.h> @n
+ *              @b Library : @b osp-speech-stt
+ *
+ * The %ISpeechToTextEventListener interface is a listener interface for speech recognition events.
+ * It provides methods that are invoked by the voice engine when the status is changed, an
+ * error or warning occurs or the result is received in the Speech-To-Text service. @n
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/uix/speech_to_text.htm">Speech-To-Text</a>.
+ *
+ */
+
+class _OSP_EXPORT_ ISpeechToTextEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+    /**
+     * This polymorphic destructor should be overridden if required. @n
+     * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     * @since 2.0
+     */
+    virtual ~ISpeechToTextEventListener(void) {}
+
+    /**
+     * Called when the Speech-To-Text service is initialized.
+     *
+     * @since 2.0
+     *
+     * @see SpeechToText::Initialize()
+     */
+    virtual void OnSpeechToTextInitialized(void) = 0;
+
+    /**
+     * Called when the Speech-To-Text recording status is changed.
+     *
+     * @since 2.0
+     *
+     * @param[in]   status  The recording status of the Speech-To-Text service
+     */
+    virtual void OnSpeechToTextStatusChanged(Tizen::Uix::Speech::SpeechToTextStatus status) = 0;
+
+    /**
+     * Called when an error occurs in the Speech-To-Text service.
+     *
+     * @since 2.0
+     *
+     * @param[in]   error   The reason for an error in the Speech-To-Text service
+     */
+    virtual void OnSpeechToTextErrorOccurred(Tizen::Uix::Speech::SpeechToTextError error) = 0;
+
+    /**
+     * Called when the Speech-To-Text service is completed.
+     *
+     * @since 2.0
+     *
+     * @param[in]   result  The result of the Speech-To-Text service
+     */
+    virtual void OnSpeechToTextCompleted(const Tizen::Base::String& result) = 0;
+
+protected:
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+       //
+    virtual void ISpeechToTextEventListener_Reserved1(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    virtual void ISpeechToTextEventListener_Reserved2(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    virtual void ISpeechToTextEventListener_Reserved3(void) {}
+
+}; // ISpeechToTextEventListener
+
+}}} // Tizen::Uix::Speech
+
+#endif
diff --git a/inc/FUixSpeechITextToSpeechEventListener.h b/inc/FUixSpeechITextToSpeechEventListener.h
new file mode 100644 (file)
index 0000000..d3233be
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechITextToSpeechEventListener.h
+ * @brief   This is the header file for the %ITextToSpeechEventListener interface.
+ *
+ * This header file contains the declarations of the %ITextToSpeechEventListener interface.
+ */
+
+#ifndef _FUIX_SPEECH_ITEXT_TO_SPEECH_EVENT_LISTENER_H_
+#define _FUIX_SPEECH_ITEXT_TO_SPEECH_EVENT_LISTENER_H_
+
+#include <FUixSpeechTextToSpeechTypes.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+/**
+ * @interface   ITextToSpeechEventListener
+ * @brief       This interface is a listener for the speech synthesis events.
+ *
+ * @since 2.0
+ *
+ * @remarks     @b Header @b %file: @b \#include @b <FUix.h> @n
+ *              @b Library : @b osp-speech-tts
+ *
+ * The %ITextToSpeechEventListener interface is a listener interface for the speech synthesis events.
+ * It provides methods that are used to notify when the status is changed and an error occurs from the voice engine. @n
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/uix/text_to_speech.htm">Text-To-Speech</a>.
+ */
+
+class _OSP_EXPORT_ ITextToSpeechEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+    /**
+     * This polymorphic destructor should be overridden if required. @n
+     * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     * @since 2.0
+     */
+    virtual ~ITextToSpeechEventListener(void) {}
+
+    /**
+     * Called when the Text-To-Speech service is initialized.
+     *
+     * @since 2.0
+     *
+     * @see     TextToSpeech::Initialize()
+     */
+     virtual void OnTextToSpeechInitialized(void) = 0;
+
+    /**
+     * Called when the status of the Text-To-Speech service is changed.
+     *
+     * @since 2.0
+     *
+     * @param[in]   status  The status of the Text-To-Speech service
+     * @see         TextToSpeechStatus
+     */
+    virtual void OnTextToSpeechStatusChanged(Tizen::Uix::Speech::TextToSpeechStatus status) = 0;
+
+    /**
+     * Called when an error occurs in the Text-To-Speech service.
+     *
+     * @since 2.0
+     *
+     * @param[in]   error   The reason for an error in the Text-To-Speech service
+     * @see         TextToSpeechError
+     */
+     virtual void OnTextToSpeechErrorOccurred(Tizen::Uix::Speech::TextToSpeechError error) = 0;
+
+    /**
+     * Called when the Text-To-Speech service is completed.
+     *
+     * @since 2.0
+     */
+    virtual void OnTextToSpeechCompleted(void) = 0;
+
+protected:
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+       virtual void ITextToSpeechEventListener_Reserved1(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+       virtual void ITextToSpeechEventListener_Reserved2(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+       virtual void ITextToSpeechEventListener_Reserved3(void) {}
+
+};
+
+} } } // Tizen::Uix::Speech
+
+#endif // _FUIX_ITEXT_TO_SPEECH_EVENT_LISTENER_H_
diff --git a/inc/FUixSpeechSpeechToText.h b/inc/FUixSpeechSpeechToText.h
new file mode 100644 (file)
index 0000000..564f672
--- /dev/null
@@ -0,0 +1,385 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 3.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://www.apache.org/licenses/LICENSE-3.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechSpeechToText.h
+ * @brief   This is the header file for the %SpeechToText class.
+ *
+ * This header file contains the declarations of the %SpeechToText class.
+ */
+
+#ifndef _FUIX_SPEECH_SPEECH_TO_TEXT_H_
+#define _FUIX_SPEECH_SPEECH_TO_TEXT_H_
+
+#include <FBaseObject.h>
+#include <FBaseDataType.h>
+#include <FUixSpeechSpeechToTextTypes.h>
+#include <FUixSpeechISpeechToTextEventListener.h>
+
+namespace Tizen { namespace Base
+{
+    class String;
+    class ByteBuffer;
+}}
+namespace Tizen { namespace Base { namespace Collection
+{
+    class IList;
+}}}
+namespace Tizen { namespace Locales
+{
+    class Locale;
+}}
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+class _SpeechToTextImpl;
+
+/**
+* @class    SpeechToText
+* @brief    This class is used to convert spoken words into text.
+*
+* @since 2.0
+*
+* @remarks  @b Header @b %file: @b \#include @b <FUix.h> @n
+*           @b Library : @b osp-speech-stt
+*
+* The %SpeechToText class converts spoken words into text.
+* @n
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/uix/speech_to_text.htm">Speech-To-Text</a>.
+*
+* The following example demonstrates how to use the %SpeechToText class. @n
+* In the example, the Start() method is called after invoking the ISpeechToTextEventListener::OnSpeechToTextInitialized() method.
+*
+* @code
+*   //Sample code for SpeechToTextSample.h
+*   #include <FUix.h>
+*
+*   using namespace Tizen::Uix::Speech;
+*
+*     class SpeechToTextSample : public ISpeechToTextEventListener
+*     {
+*         public:
+*             SpeechToTextSample(void);
+*             virtual ~SpeechToTextSample(void);
+*
+*             bool Initialize(void);
+*             bool Start(void);
+*
+*             virtual void OnSpeechToTextInitialized(void);
+*             virtual void OnSpeechToTextStatusChanged(Tizen::Uix::Speech::SpeechToTextStatus status);
+*             virtual void OnSpeechToTextErrorOccurred(Tizen::Uix::Speech::SpeechToTextError error);
+*             virtual void OnSpeechToTextCompleted(Tizen::Base::String& result);
+*
+*         private:
+*             Tizen::Uix::Speech::SpeechToText* __pStt;
+*     };
+*
+*     //Sample code for SpeechToTextSample.cpp
+*     #include "SpeechToTextSample.h"
+*
+*     SpeechToTextSample::SpeechToTextSample(void)
+*         : __pStt(null)
+*     {
+*     }
+*
+*     SpeechToTextSample::~SpeechToTextSample(void)
+*     {
+*     }
+*
+*     void SpeechToTextSample::OnSpeechToTextInitialized(void)
+*     {
+*         // ....
+*         __pStt->SetLocale(Locale(LANGUAGE_ENG, COUNTRY_US));
+*
+*         __pStt->SetSilenceDetectionEnabled(true);
+*     }
+*
+*     void SpeechToTextSample::OnSpeechToTextStatusChanged(Tizen::Uix::Speech::SpeechToTextStatus status)
+*     {
+*         // ....
+*     }
+*
+*     void SpeechToTextSample::OnSpeechToTextErrorOccurred(Tizen::Uix::Speech::SpeechToTextError error)
+*     {
+*         // ....
+*     }
+*
+*     void SpeechToTextSample::OnSpeechToTextCompleted(Tizen::Base::String& result)
+*     {
+*         // ....
+*     }
+*
+*     bool SpeechToTextSample::Initialize(void)
+*     {
+*         result r = E_SUCCESS;
+*
+*         __pStt = new SpeechToText();
+*
+*         r = __pStt->Construct(*this);
+*         if (IsFailed(r))
+*         {
+*             AppLog("Error code: %s", GetErrorMessage(r)):
+*             return false;
+*         }
+*
+*         r = __pStt->Initialize();
+*         if (IsFailed(r))
+*         {
+*             AppLog("Error code: %s", GetErrorMessage(r)):
+*             return false;
+*         }
+*         return true;
+*     }
+*
+*     void SpeechToTextSample::Start(void)
+*     {
+*         if (__pStt->GetCurrentStatus() == SPEECH_TO_TEXT_STATUS_READY)
+*         {
+*             __pStt->Start();
+*         }
+*     }
+* @endcode
+*/
+
+class _OSP_EXPORT_ SpeechToText
+    : public Tizen::Base::Object
+{
+public:
+    /**
+     * The object is not fully constructed after this constructor is called. @n
+     * For full construction, the Construct() method must be called right after calling this constructor.
+     *
+     * @since 2.0
+     */
+    SpeechToText(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since 2.0
+     */
+    virtual ~SpeechToText(void);
+
+    /**
+     * Initializes this instance of %SpeechToText with the specified @c listener.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        An instance of ISpeechToTextEventListener
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     */
+    result Construct(ISpeechToTextEventListener& listener);
+
+    /**
+     * Initializes the Speech-To-Text service. @n
+     * This method is asynchronous. @n
+     * The ISpeechToTextEventListener::OnSpeechToTextInitialized() is invoked when the service has been initialized.
+     * @since 2.0
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @remarks     This method must be called after Construct().
+     */
+    result Initialize(void);
+
+    /**
+     * Starts recording the speech of a user and converts it to text.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @exception   E_SERVICE_BUSY      The recorder is busy.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @exception   E_INVALID_OPERATION The current status should be @c SPEECH_TO_TEXT_STATUS_READY.
+     */
+    result Start(void);
+
+    /**
+     * Stops the recording and current Speech-To-Text service.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @exception   E_INVALID_OPERATION The current status should be @c SPEECH_TO_TEXT_STATUS_RECORDING.
+     */
+    result Stop(void);
+
+    /**
+     * Cancels the in-progress recognition of the Speech-To-Text service.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @exception   E_INVALID_OPERATION The current status should be @c SPEECH_TO_TEXT_STATUS_RECORDING or @c SPEECH_TO_TEXT_STATUS_PROCESSING.
+     */
+    result Cancel(void);
+
+    /**
+    * Sets the locale for the Speech-To-Text service.
+    *
+    * @since 2.0
+    *
+    * @return       An error code
+    * @param[in]    locale                  The locale
+    * @exception    E_SUCCESS               The method is successful.
+    * @exception    E_UNSUPPORTED_LOCALE    This locale is not supported.
+    * @exception    E_INVALID_STATE         This instance is not initialized as yet.
+    * @see          GetSupportedLocales()
+    */
+    result SetLocale(const Tizen::Locales::Locale& locale);
+
+    /**
+     * Gets the current locale.
+     *
+     * @since 2.0
+     *
+     * @return      A current locale
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    Tizen::Locales::Locale GetLocale(void) const;
+
+    /**
+     * Checks whether a locale is supported or not.
+     *
+     * @since 2.0
+     *
+     * @return      @c true if the locale is available, @n
+     *              else @c false
+     * @param[in]   locale          The locale
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    bool IsLocaleSupported(const Tizen::Locales::Locale& locale) const;
+
+    /**
+     * Gets the list of supported locales. @n
+     * Each list's item has a pointer of Tizen::Locales::Locale value.
+     *
+     * @since 2.0
+     *
+     * @return      A list of locales
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    const Tizen::Base::Collection::IList* GetSupportedLocales(void) const;
+
+    /**
+     * Sets the grammar for %SpeechToText.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   grammar         A grammar
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     */
+    result SetGrammar(SpeechToTextGrammar grammar);
+
+    /**
+     * Gets the current grammar.
+     *
+     * @since 2.0
+     *
+     * @return      The current grammar used by recognition
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    SpeechToTextGrammar GetGrammar(void) const;
+
+    /**
+     * Sets the silence detection enabled or disabled.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   enable  Set to @c true to enable the silence detection, @n
+     *                      else @c false
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     */
+    result SetSilenceDetectionEnabled(bool enable);
+
+    /**
+     * Checks whether the silence detection feature is enabled.
+     *
+     * @since 2.0
+     *
+     * @return      @c true if the silence detection is enabled, @n
+     *              else @c false
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    bool IsSilenceDetectionEnabled(void) const;
+
+    /**
+     * Gets the current status.
+     *
+     * @since 2.0
+     *
+     * @return      current status
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    SpeechToTextStatus GetCurrentStatus(void) const;
+
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since 2.0
+     */
+    SpeechToText(const SpeechToText& rhs);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since 2.0
+     */
+    SpeechToText& operator =(const SpeechToText& rhs);
+
+private:
+    _SpeechToTextImpl* __pSpeechToTextImpl;
+    friend class _SpeechToTextImpl;
+
+}; // SpeechToText
+
+} } } // Tizen::Uix::Speech
+
+#endif
diff --git a/inc/FUixSpeechSpeechToTextTypes.h b/inc/FUixSpeechSpeechToTextTypes.h
new file mode 100644 (file)
index 0000000..6e88fea
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechSpeechToTextTypes.h
+ * @brief   This is the header file for the common data types used by the SpeechToText class.
+ *
+ * This header file contains the declarations of the common data types and constants used by the SpeechToText class.
+ */
+
+#ifndef _FUIX_SPEECH_SPEECH_TO_TEXT_TYPES_H_
+#define _FUIX_SPEECH_SPEECH_TO_TEXT_TYPES_H_
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+/**
+* @enum SpeechToTextStatus
+*
+* Defines the %SpeechToText status.
+*
+* @since 2.0
+*
+* @see ISpeechToTextEventListener::OnSpeechToTextStatusChanged()
+*/
+enum SpeechToTextStatus
+{
+    SPEECH_TO_TEXT_STATUS_NONE,         /**< The none status */
+    SPEECH_TO_TEXT_STATUS_READY,        /**< The ready status */
+    SPEECH_TO_TEXT_STATUS_RECORDING,    /**< The recording status */
+    SPEECH_TO_TEXT_STATUS_PROCESSING    /**< The recognition processing status */
+};
+
+/**
+* @enum SpeechToTextGrammar
+*
+* Defines the %SpeechToText grammar.
+*
+* @since 2.0
+*
+* @see SetGrammar()
+*/
+enum SpeechToTextGrammar
+{
+    SPEECH_TO_TEXT_GRAMMAR_FREE,        /**< The key is used for general purpose dictation */
+    SPEECH_TO_TEXT_GRAMMAR_WEB_SEARCH   /**< The key is used for recognizing short phrases such as the ones used for %Web search */
+};
+
+/**
+* @enum SpeechToTextError
+*
+* Defines the errors in %SpeechToText. @n
+* When an error occurs, the user can not receive any %SpeechToText result.
+*
+* @since 2.0
+*
+* @see ISpeechToTextEventListener::OnSpeechToTextErrorOccurred()
+*/
+enum SpeechToTextError
+{
+    SPEECH_TO_TEXT_ERROR_OUT_OF_MEMORY,         /**< The out of memory error */
+    SPEECH_TO_TEXT_ERROR_IO_ERROR,              /**< The I/O error */
+    SPEECH_TO_TEXT_ERROR_NETWORK_ERROR,         /**< The network connection error */
+    SPEECH_TO_TEXT_ERROR_TIME_OUT,              /**< The timeout error */
+    SPEECH_TO_TEXT_ERROR_SYSTEM_ERROR,          /**< The system error */
+    SPEECH_TO_TEXT_ERROR_UNSUPPORTED_SERVICE    /**< The unsupported service error */
+};
+
+} } } // Tizen::Uix::Speech
+
+#endif
diff --git a/inc/FUixSpeechTextToSpeech.h b/inc/FUixSpeechTextToSpeech.h
new file mode 100644 (file)
index 0000000..5871d69
--- /dev/null
@@ -0,0 +1,358 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechTextToSpeech.h
+ * @brief   This is the header file for the %TextToSpeech class.
+ *
+ * This header file contains the declarations of the %TextToSpeech class.
+ */
+
+#ifndef _FUIX_SPEECH_TEXT_TO_SPEECH_H_
+#define _FUIX_SPEECH_TEXT_TO_SPEECH_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FUixSpeechITextToSpeechEventListener.h>
+#include <FUixSpeechTextToSpeechTypes.h>
+
+namespace Tizen { namespace Base
+{
+       class String;
+}}
+namespace Tizen { namespace Base { namespace Collection
+{
+       class IList;
+}}}
+namespace Tizen { namespace Locales
+{
+       class Locale;
+}}
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+class _TextToSpeechImpl;
+
+/**
+* @class    TextToSpeech
+* @brief    This class is used to convert normal language text into speech.
+*
+* @since 2.0
+*
+* @remarks  @b Header @b %file: @b \#include @b <FUix.h> @n
+*           @b Library : @b osp-speech-tts
+*
+* The %TextToSpeech class is used to convert normal language text into speech. @n
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/uix/text_to_speech.htm">Text-To-Speech</a>.
+*
+* The following example demonstrates how to use the %TextToSpeech class. @n
+* In the example, the Speak() method is called after invoking the ITextToSpeechEventListener::OnTextToSpeechInitialized() method.
+*
+* @code
+*   //Sample code for TextToSpeechSample.h
+*   #include <FUix.h>
+*
+*   using namespace Tizen::Uix::Speech;
+*
+*     class TextToSpeechSample : public ITextToSpeechEventListener
+*     {
+*         public:
+*             TextToSpeechSample(void);
+*             virtual ~TextToSpeechSample(void);
+*
+*             bool Initialize(void);
+*             bool Speak(void);
+*
+*             virtual void OnTextToSpeechInitialized(void);
+*             virtual void OnTextToSpeechStatusChanged(Tizen::Uix::Speech::TextToSpeechStatus status);
+*             virtual void OnTextToSpeechErrorOccurred(Tizen::Uix::Speech::TextToSpeechError error);
+*             virtual void OnTextToSpeechCompleted();
+*
+*         private:
+*             Tizen::Uix::Speech::TextToSpeech* __pTts;
+*     };
+*
+*     //Sample code for TextToSpeechSample.cpp
+*     #include "TextToSpeechSample.h"
+*
+*     TextToSpeechSample::TextToSpeechSample(void)
+*         : __pTts(null)
+*     {
+*     }
+*
+*     TextToSpeechSample::~TextToSpeechSample(void)
+*     {
+*     }
+*
+*     void TextToSpeechSample::OnTextToSpeechInitialized(void)
+*     {
+*         // ....
+*         __pTts->SetLocale(Locale(LANGUAGE_ENG, COUNTRY_US));
+*
+*         __pTts->SetSpeechRate(TEXT_TO_SPEECH_SPEECH_RATE_NORMAL);
+*     }
+*
+*     void TextToSpeechSample::OnTextToSpeechStatusChanged(Tizen::Uix::Speech::TextToSpeechStatus status)
+*     {
+*         // ....
+*     }
+*
+*     void TextToSpeechSample::OnTextToSpeechErrorOccurred(Tizen::Uix::Speech::TextToSpeechError error)
+*     {
+*         // ....
+*     }
+*
+*     void TextToSpeechSample::OnTextToSpeechCompleted()
+*     {
+*         // ....
+*     }
+*
+*     bool TextToSpeechSample::Initialize(void)
+*     {
+*         result r = E_SUCCESS;
+*
+*         __pTts = new TextToSpeech();
+*
+*         r = __pTts->Construct(*this);
+*         if (IsFailed(r))
+*         {
+*             AppLog("Error code: %s", GetErrorMessage(r)):
+*             return false;
+*         }
+*
+*         r = __pTts->Initialize();
+*         if (IsFailed(r))
+*         {
+*             AppLog("Error code: %s", GetErrorMessage(r)):
+*             return false;
+*         }
+*         return true;
+*     }
+*
+*     void TextToSpeechSample::Speak(void)
+*     {
+*         if (__pTts->GetCurrentStatus() == TEXT_TO_SPEECH_STATUS_READY)
+*         {
+*             __pTts->Speak(L"Hi! Tizen.", TEXT_TO_SPEECH_REQUEST_MODE_APPEND);
+*         }
+*     }
+* @endcode
+*/
+
+class _OSP_EXPORT_ TextToSpeech
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * The object is not fully constructed after this constructor is called. @n
+     * For full construction, the Construct() method must be called right after calling this constructor.
+     *
+     * @since 2.0
+     */
+    TextToSpeech(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since 2.0
+     */
+    virtual ~TextToSpeech(void);
+
+    /**
+     * Initializes this instance of %TextToSpeech with the specified @c listener.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        An instance of ITextToSpeechEventListener
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     */
+    result Construct(ITextToSpeechEventListener& listener);
+
+    /**
+     * Initializes the Text-To-Speech service. @n
+     * This method is asynchronous. @n
+     * The ITextToSpeechEventListener::OnTextToSpeechInitialized() is invoked when the service has been initialized.
+     *
+     * @since 2.0
+        *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @remarks     This method must be called after Construct().
+     */
+       result Initialize(void);
+
+    /**
+     * Starts the conversion of given text and starts playing the synthesized sound.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   text            A text string for synthesizing a speech
+     * @param[in]   requestMode     The request mode
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     */
+    result Speak(const Tizen::Base::String& text, TextToSpeechRequestMode requestMode = TEXT_TO_SPEECH_REQUEST_MODE_APPEND);
+
+    /**
+     * Stops the synthesis or the sound on playing.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @exception   E_INVALID_OPERATION The current status should be @c TEXT_TO_SPEECH_STATUS_PLAYING or @c TEXT_TO_SPEECH_STATUS_PAUSED.
+     */
+    result Stop(void);
+
+    /**
+     * Pauses the speech.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @exception   E_INVALID_OPERATION The current status should be @c TEXT_TO_SPEECH_STATUS_PLAYING.
+     */
+    result Pause(void);
+
+    /**
+     * Resumes the speech.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @exception   E_INVALID_OPERATION The current status should be @c TEXT_TO_SPEECH_STATUS_PAUSED.
+     */
+    result Resume(void);
+
+    /**
+     * Sets the locale for the Text-To-Speech service.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   locale                  The current locale
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_UNSUPPORTED_LOCALE    This locale is not supported.
+     * @exception   E_INVALID_STATE         This instance is not initialized as yet.
+     * @see         GetSupportedLocales()
+     */
+    result SetLocale(const Tizen::Locales::Locale& locale);
+
+    /**
+     * Gets the current locale.
+     *
+     * @since 2.0
+     *
+     * @return      A current locale
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    Tizen::Locales::Locale GetLocale(void) const;
+
+    /**
+     * Checks whether a locale is supported.
+     *
+     * @since 2.0
+     *
+     * @return      @c true if the locale is available, @n
+     *              else @c false
+     * @param[in]   locale          The locale
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_STATE This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    bool IsLocaleSupported(const Tizen::Locales::Locale& locale) const;
+
+    /**
+     * Gets the list of supported locales. @n
+     * Each list's item has a pointer of Tizen::Locales::Locale value.
+     *
+     * @since 2.0
+     *
+     * @return      A list of locales
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    const Tizen::Base::Collection::IList* GetSupportedLocales(void) const;
+
+    /**
+     * Sets the speech rate.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   rate    A speech rate
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_STATE     This instance is not initialized as yet.
+     * @see         TextToSpeechSpeechRate
+     */
+    result SetSpeechRate(TextToSpeechSpeechRate rate);
+
+    /**
+     * Gets the current status.
+     *
+     * @since 2.0
+     *
+     * @return      current status
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_STATE     TThis instance is not initialized as yet.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    TextToSpeechStatus GetCurrentStatus(void) const;
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since 2.0
+     */
+       TextToSpeech(const TextToSpeech& rhs);
+
+       /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since 2.0
+     */
+       TextToSpeech& operator =(const TextToSpeech& rhs);
+
+private:
+       _TextToSpeechImpl* __pTextToSpeechImpl;
+       friend class _TextToSpeechImpl;
+
+}; // TextToSpeech
+
+} } } // Tizen::Uix::Speech
+
+#endif
diff --git a/inc/FUixSpeechTextToSpeechTypes.h b/inc/FUixSpeechTextToSpeechTypes.h
new file mode 100644 (file)
index 0000000..af215d4
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechTextToSpeechTypes.h
+ * @brief   This is the header file for common data types used by the TextToSpeech class.
+ *
+ * This header file contains the declarations of the common data types and constants used by the TextToSpeech class.
+ */
+
+#ifndef _FUIX_SPEECH_TEXT_TO_SPEECH_TYPES_H_
+#define _FUIX_SPEECH_TEXT_TO_SPEECH_TYPES_H_
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+/**
+ * @enum    TextToSpeechRequestMode
+ *
+ * Defines the request mode.
+ *
+ * @since 2.0
+ *
+ * @see     TextToSpeech::Speak()
+ */
+enum TextToSpeechRequestMode
+{
+    TEXT_TO_SPEECH_REQUEST_MODE_APPEND,     /**< The new request is added at the queue */
+    TEXT_TO_SPEECH_REQUEST_MODE_REPLACE     /**< All requests in the queue are dropped and replaced by the new request */
+};
+
+/**
+ * @enum    TextToSpeechSpeechRate
+ *
+ * Defines the level of the speech rate.
+ *
+ * @since 2.0
+ *
+ * @see     TextToSpeech::SetSpeechRate()
+ */
+enum TextToSpeechSpeechRate
+{
+    TEXT_TO_SPEECH_SPEECH_RATE_SYSTEM_SETTING,  /**< The speech rate from system setting */
+    TEXT_TO_SPEECH_SPEECH_RATE_VERY_SLOW,       /**< The very slow speech rate */
+    TEXT_TO_SPEECH_SPEECH_RATE_SLOW,            /**< The slow speech rate*/
+    TEXT_TO_SPEECH_SPEECH_RATE_NORMAL,          /**< The normal speech rate */
+    TEXT_TO_SPEECH_SPEECH_RATE_FAST,            /**< The fast speech rate */
+    TEXT_TO_SPEECH_SPEECH_RATE_VERY_FAST        /**< The very fast speech rate */
+};
+
+/**
+ * @enum    TextToSpeechStatus
+ *
+ * Defines the status of the Text-To-Speech service.
+ *
+ * @since 2.0
+ *
+ * @see     ITextToSpeechEventListener::OnTextToSpeechStatusChanged()
+ */
+enum TextToSpeechStatus
+{
+    TEXT_TO_SPEECH_STATUS_NONE,         /**< The none status */
+    TEXT_TO_SPEECH_STATUS_READY,        /**< The ready status */
+    TEXT_TO_SPEECH_STATUS_SYNTHESIZING, /**< The synthesizing status */
+    TEXT_TO_SPEECH_STATUS_PLAYING,      /**< The playing status */
+    TEXT_TO_SPEECH_STATUS_PAUSED        /**< The paused status*/
+};
+
+/**
+ * @enum    TextToSpeechError
+ *
+ * Defines the errors that occur in the Text-To-Speech service.
+ *
+ * @since 2.0
+ *
+ * @see     ITextToSpeechEventListener::OnTextToSpeechErrorOccurred()
+ */
+enum TextToSpeechError
+{
+    TEXT_TO_SPEECH_ERROR_OUT_OF_MEMORY,         /**< The out of memory error */
+    TEXT_TO_SPEECH_ERROR_IO_ERROR,              /**< The I/O error */
+    TEXT_TO_SPEECH_ERROR_NETWORK_ERROR,         /**< The network connection error */
+    TEXT_TO_SPEECH_ERROR_TIME_OUT,              /**< The timeout error */
+    TEXT_TO_SPEECH_ERROR_SYSTEM_ERROR,          /**< The system error */
+    TEXT_TO_SPEECH_ERROR_UNSUPPORTED_SERVICE    /**< The unsupported service error */
+};
+
+} } } // Tizen::Uix::Speech
+
+#endif
diff --git a/osp-speech.manifest b/osp-speech.manifest
new file mode 100644 (file)
index 0000000..ae3e6f7
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
\ No newline at end of file
diff --git a/osp-speech.pc.in b/osp-speech.pc.in
new file mode 100755 (executable)
index 0000000..eb6c3b7
--- /dev/null
@@ -0,0 +1,14 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib/osp
+includedir=/usr/include/osp
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
diff --git a/packaging/osp-speech.spec b/packaging/osp-speech.spec
new file mode 100755 (executable)
index 0000000..b1ff5c4
--- /dev/null
@@ -0,0 +1,85 @@
+%define debug_package %{nil}
+%define __strip /bin/true
+
+Name:          osp-speech
+Summary:       osp speech library
+Version:       1.2.0.0
+Release:       2
+Group:         System/Libraries
+License:       TO_BE/FILLED_IN
+Source0:       %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(stt)
+BuildRequires:  pkgconfig(tts)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires:  osp-appfw-internal-devel
+
+# runtime requires
+Requires: osp-appfw 
+
+%description
+osp speech library
+
+%package devel
+Summary:    osp speech library (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+osp speech library (DEV)
+
+%package internal-devel
+Summary:    osp speech library (Internal)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description internal-devel
+osp speech library (Internal-DEV)
+
+%package debug
+Summary:    osp speech library (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description debug
+osp speech library (DEV)
+
+%prep
+%setup -q
+
+%build 
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%else
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%endif
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2  %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-speech.manifest
+/usr/share/license/%{name}
+%{_libdir}/osp/*.so*
+
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/osp-speech.pc
+
+%files internal-devel
+%{_includedir}/osp/uix/*.h
+
+%files debug
+%{_libdir}/osp/debug/*.so*
diff --git a/src/inc/FUixSpeech_ITextToSpeech.h b/src/inc/FUixSpeech_ITextToSpeech.h
new file mode 100644 (file)
index 0000000..fd85924
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeech_ITextToSpeech.h
+ * @brief   This is the header file of the _ITextToSpeech class.
+ */
+
+#ifndef _FUIX_SPEECH_INTERNAL_ITEXT_TO_SPEECH_H_
+#define _FUIX_SPEECH_INTERNAL_ITEXT_TO_SPEECH_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FUixSpeechTextToSpeechTypes.h>
+#include <FUixSpeechITextToSpeechEventListener.h>
+
+namespace Tizen { namespace Base { namespace Collection {
+    class IList;
+}}}
+namespace Tizen { namespace Locales {
+    class Locale;
+}}
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+class _ITextToSpeech
+{
+public:
+    virtual ~_ITextToSpeech(void){}
+
+    virtual result Construct(ITextToSpeechEventListener& listener) = 0;
+    virtual result Initialize(void) = 0;
+
+    virtual result Speak(const Tizen::Base::String& text, TextToSpeechRequestMode requestMode) = 0;
+    virtual result Stop(void) = 0;
+    virtual result Pause(void) = 0;
+    virtual result Resume(void) = 0;
+
+    virtual result SetLocale(const Tizen::Locales::Locale& locale) = 0;
+    virtual Tizen::Locales::Locale GetLocale(void) const = 0;
+    virtual const Tizen::Base::Collection::IList* GetSupportedLocales(void) const = 0;
+    virtual bool IsLocaleSupported(const Tizen::Locales::Locale& locale) const = 0;
+
+    virtual result SetSpeechRate(TextToSpeechSpeechRate speechRate) = 0;
+
+    virtual TextToSpeechStatus GetCurrentStatus(void) const = 0;
+
+}; // _ITextToSpeech
+
+} } } // Tizen::Uix::Speech
+#endif
diff --git a/src/stt/CMakeLists.txt b/src/stt/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..397b896
--- /dev/null
@@ -0,0 +1,32 @@
+SET (this_target osp-speech-stt)
+
+INCLUDE_DIRECTORIES(
+       ./
+       ${COMMON_INCLUDE_DIRS}  
+       )
+
+SET (${this_target}_SOURCE_FILES
+       FUixSpeechSpeechToText.cpp
+       FUixSpeech_SpeechToTextImpl.cpp
+)
+
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
+
+TARGET_LINK_LIBRARIES(${this_target} "-losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-lstt" )
+
+OSP_STRIP(${this_target})
+
diff --git a/src/stt/FUixSpeechSpeechToText.cpp b/src/stt/FUixSpeechSpeechToText.cpp
new file mode 100644 (file)
index 0000000..f1f811a
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechSpeechToText.cpp
+ * @brief   This is the implementation file for the SpeechToText class.
+ *
+ * This files contains implementation of the SpeechToText class.
+ */
+
+#include <FLclLocale.h>
+#include <FUixSpeechSpeechToText.h>
+#include <FBaseSysLog.h>
+#include <FUixSpeech_SpeechToTextImpl.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Locales;
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+SpeechToText::SpeechToText(void)
+    : __pSpeechToTextImpl(null)
+{
+}
+
+SpeechToText::~SpeechToText(void)
+{
+    delete __pSpeechToTextImpl;
+}
+
+result
+SpeechToText::Construct(ISpeechToTextEventListener& listener)
+{
+    SysAssertf(__pSpeechToTextImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+    __pSpeechToTextImpl = new (std::nothrow) _SpeechToTextImpl();
+       SysTryReturn(NID_UIX_SPEECH, __pSpeechToTextImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+    return __pSpeechToTextImpl->Construct(listener);
+}
+
+result
+SpeechToText::Initialize(void)
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->Initialize();
+}
+
+result
+SpeechToText::Start(void)
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->Start();
+}
+
+result
+SpeechToText::Stop(void)
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->Stop();
+}
+
+result
+SpeechToText::Cancel(void)
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->Cancel();
+}
+
+result
+SpeechToText::SetLocale(const Locale& locale)
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->SetLocale(locale);
+}
+
+Locale
+SpeechToText::GetLocale(void) const
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->GetLocale();
+}
+
+const Tizen::Base::Collection::IList*
+SpeechToText::GetSupportedLocales(void) const
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->GetSupportedLocales();
+}
+
+bool
+SpeechToText::IsLocaleSupported(const Locale& locale) const
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->IsLocaleSupported(locale);
+}
+
+result
+SpeechToText::SetGrammar(SpeechToTextGrammar grammar)
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->SetGrammar(grammar);
+}
+
+SpeechToTextGrammar
+SpeechToText::GetGrammar(void) const
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->GetGrammar();
+}
+
+result
+SpeechToText::SetSilenceDetectionEnabled(bool enable)
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->SetSilenceDetectionEnabled(enable);
+}
+
+bool
+SpeechToText::IsSilenceDetectionEnabled(void) const
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->IsSilenceDetectionEnabled();
+}
+
+SpeechToTextStatus
+SpeechToText::GetCurrentStatus(void) const
+{
+    SysAssertf(__pSpeechToTextImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pSpeechToTextImpl->GetCurrentStatus();
+}
+
+} } } // Tizen::Uix::Speech
+
diff --git a/src/stt/FUixSpeech_SpeechToTextImpl.cpp b/src/stt/FUixSpeech_SpeechToTextImpl.cpp
new file mode 100644 (file)
index 0000000..11cb404
--- /dev/null
@@ -0,0 +1,605 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0\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
+ * @file    FUixSpeech_SpeechToTextImpl.cpp\r
+ * @brief   This is the implementation file for the _SpeechToTextImpl class.\r
+ *\r
+ * This files contains implementation of the _SpeechToTextImpl class.\r
+ */\r
+\r
+#include <new>\r
+#include <FBaseColIList.h>\r
+#include <FBaseColArrayList.h>\r
+#include <FBaseString.h>\r
+#include <FBaseUtilStringTokenizer.h>\r
+#include <FLclLocale.h>\r
+#include <FUixSpeechSpeechToText.h>\r
+#include <FBaseSysLog.h>\r
+#include <FBase_StringConverter.h>\r
+#include <FUixSpeech_SpeechToTextImpl.h>\r
+\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Base::Collection;\r
+using namespace Tizen::Locales;\r
+\r
+namespace Tizen { namespace Uix { namespace Speech\r
+{\r
+\r
+void\r
+_SpeechToTextImpl::SttResultReceiver(stt_h sttHandle, const char* type, const char* data[], int dataCount, const char* msg, void* pListener)\r
+{\r
+    String userSpeech;\r
+    userSpeech.Clear();\r
+\r
+    if (dataCount == 0)\r
+    {\r
+        userSpeech.Append(msg);\r
+    }\r
+    else\r
+    {\r
+        for (int i = 0; i < dataCount; i++)\r
+        {\r
+            userSpeech.Append(data[i]);\r
+        }\r
+    }\r
+    static_cast < ISpeechToTextEventListener* >(pListener)->OnSpeechToTextCompleted(userSpeech);\r
+}\r
+\r
+void\r
+_SpeechToTextImpl::SttPartialResultReceiver(stt_h sttHandle, const char* data, void* pListener)\r
+{\r
+}\r
+\r
+void\r
+_SpeechToTextImpl::SttStateChangedReceiver(stt_h sttHandle, stt_state_e previousState, stt_state_e currentState, void* pSttInstance)\r
+{\r
+    SysLog(NID_UIX_SPEECH, "The current state is changed to '%s' from '%s'.",\r
+            GetEngineStateMessage(currentState), GetEngineStateMessage(previousState));\r
+\r
+    _SpeechToTextImpl* pInstance = static_cast<_SpeechToTextImpl*>(pSttInstance);\r
+    ISpeechToTextEventListener* pListener = pInstance->__pSpeechToTextListener;\r
+\r
+    // Start()\r
+    if ((previousState == STT_STATE_READY) && (currentState == STT_STATE_RECORDING))\r
+    {\r
+        pInstance->__currentStatus = SPEECH_TO_TEXT_STATUS_RECORDING;\r
+        pListener->OnSpeechToTextStatusChanged(SPEECH_TO_TEXT_STATUS_RECORDING);\r
+    }\r
+    // Cancel()\r
+    else if ((previousState == STT_STATE_RECORDING || previousState == STT_STATE_PROCESSING)\r
+            && (currentState == STT_STATE_READY))\r
+    {\r
+        pInstance->__currentStatus = SPEECH_TO_TEXT_STATUS_READY;\r
+        pListener->OnSpeechToTextStatusChanged(SPEECH_TO_TEXT_STATUS_READY);\r
+    }\r
+    // Stop()\r
+    else if ((previousState == STT_STATE_RECORDING) && (currentState == STT_STATE_PROCESSING))\r
+    {\r
+        pInstance->__currentStatus = SPEECH_TO_TEXT_STATUS_PROCESSING;\r
+        pListener->OnSpeechToTextStatusChanged(SPEECH_TO_TEXT_STATUS_PROCESSING);\r
+    }\r
+    else if ((previousState == STT_STATE_CREATED) && (currentState == STT_STATE_READY))\r
+    {\r
+        char *pDefaultLang = null;\r
+\r
+        int ttsError = stt_get_default_language(sttHandle, &pDefaultLang);\r
+        if (ttsError == STT_ERROR_NONE)\r
+        {\r
+            SysLog(NID_UIX_SPEECH, "The default language is '%s'.", pDefaultLang);\r
+            const Locale* pDefaultLocale = ConvertEngineLocaleToOspN(pDefaultLang);\r
+            *pInstance->__pCurrentLocale = *pDefaultLocale;\r
+\r
+            delete pDefaultLocale;\r
+            free(pDefaultLang);\r
+        }\r
+\r
+        int sttError = stt_foreach_supported_languages(sttHandle, SttSupportedLocaleListGetter, (void *)pInstance->__pSupportedLocaleList);\r
+        SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to get supported voices", GetEngineErrorMessage(sttError));\r
+\r
+        pInstance->__isInitialized = true;\r
+        pInstance->__currentStatus = SPEECH_TO_TEXT_STATUS_READY;\r
+\r
+        pListener->OnSpeechToTextInitialized();\r
+        pListener->OnSpeechToTextStatusChanged(SPEECH_TO_TEXT_STATUS_READY);\r
+    }\r
+    else\r
+    {\r
+        SysLog(NID_UIX_SPEECH, "The unknown state is changed to '%s' from '%s'.",\r
+                       GetEngineStateMessage(currentState), GetEngineStateMessage(previousState));\r
+    }\r
+}\r
+\r
+void\r
+_SpeechToTextImpl::SttErrorReceiver(stt_h sttHandle, stt_error_e error, void* pListener)\r
+{\r
+       SysLog(NID_UIX_SPEECH, "[%s] Error occurred.", GetEngineErrorMessage(error));\r
+\r
+    SpeechToTextError sttError;\r
+\r
+    switch (error)\r
+    {\r
+    case STT_ERROR_OUT_OF_NETWORK:\r
+        sttError = SPEECH_TO_TEXT_ERROR_NETWORK_ERROR;\r
+        break;\r
+    case STT_ERROR_OUT_OF_MEMORY:\r
+        sttError = SPEECH_TO_TEXT_ERROR_OUT_OF_MEMORY;\r
+        break;\r
+    case STT_ERROR_IO_ERROR:\r
+        sttError = SPEECH_TO_TEXT_ERROR_IO_ERROR;\r
+        break;\r
+    case STT_ERROR_ENGINE_NOT_FOUND:\r
+        sttError = SPEECH_TO_TEXT_ERROR_UNSUPPORTED_SERVICE;\r
+        break;\r
+    case STT_ERROR_TIMED_OUT:\r
+        sttError = SPEECH_TO_TEXT_ERROR_TIME_OUT;\r
+        break;\r
+    default:\r
+        sttError = SPEECH_TO_TEXT_ERROR_SYSTEM_ERROR;\r
+        break;\r
+    }\r
+    static_cast <ISpeechToTextEventListener*>(pListener)->OnSpeechToTextErrorOccurred(sttError);\r
+}\r
+\r
+bool\r
+_SpeechToTextImpl::SttSupportedLocaleListGetter(stt_h sttHandle, const char* pLanguage, void* pLocaleList)\r
+{\r
+    SysLog(NID_UIX_SPEECH, "The language is '%s'.", pLanguage);\r
+\r
+    const Locale* pLocale = ConvertEngineLocaleToOspN(String(pLanguage));\r
+    if (pLocale == null)\r
+    {\r
+        static_cast<ArrayList*>(pLocaleList)->RemoveAll(true);\r
+        return false;   // escape call back loop\r
+    }\r
+\r
+    if (pLocale->GetLanguageCode() == LANGUAGE_INVALID)\r
+    {\r
+        SysLog(NID_UIX_SPEECH, "The '%s' language is not supported.", pLanguage);\r
+        delete pLocale;\r
+    }\r
+    else\r
+    {\r
+        result r = static_cast<ArrayList*>(pLocaleList)->Add(*pLocale);\r
+        if (IsFailed(r))\r
+        {\r
+            static_cast<ArrayList*>(pLocaleList)->RemoveAll(true);\r
+            return false;   // escape call back loop\r
+        }\r
+    }\r
+\r
+    return true;        // continue call back loop\r
+}\r
+\r
+_SpeechToTextImpl::_SpeechToTextImpl(void)\r
+    : __sttHandle(null)\r
+    , __pSpeechToTextListener(null)\r
+    , __pCurrentLocale(null)\r
+    , __grammar(SPEECH_TO_TEXT_GRAMMAR_FREE)\r
+    , __pSupportedLocaleList(null)\r
+    , __isInitialized(false)\r
+    , __isSilenceDetection(true)\r
+{\r
+\r
+}\r
+\r
+_SpeechToTextImpl::~_SpeechToTextImpl(void)\r
+{\r
+    stt_state_e sttState = STT_STATE_READY;\r
+    int sttError = stt_get_state(__sttHandle, &sttState);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to get the current state.", GetEngineErrorMessage(sttError));\r
+\r
+    if (sttState == STT_STATE_RECORDING || sttState == STT_STATE_PROCESSING)\r
+    {\r
+        sttError = stt_stop(__sttHandle);\r
+        SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to stop.", GetEngineErrorMessage(sttError));\r
+    }\r
+\r
+    if (__isInitialized)\r
+    {\r
+        sttError = stt_unprepare(__sttHandle);\r
+        SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to unprepare.", GetEngineErrorMessage(sttError));\r
+\r
+        sttError = stt_unset_result_cb(__sttHandle);\r
+        SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to unset the result callback.", GetEngineErrorMessage(sttError));\r
+\r
+        sttError = stt_unset_partial_result_cb(__sttHandle);\r
+        SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to unset the partial result callback.", GetEngineErrorMessage(sttError));\r
+\r
+        sttError = stt_unset_state_changed_cb(__sttHandle);\r
+        SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to unset the state changed callback.", GetEngineErrorMessage(sttError));\r
+\r
+        sttError = stt_unset_error_cb(__sttHandle);\r
+        SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to unset the error callback.", GetEngineErrorMessage(sttError));\r
+    }\r
+\r
+    sttError = stt_destroy(__sttHandle);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to destroy.", GetEngineErrorMessage(sttError));\r
+\r
+    delete __pCurrentLocale;\r
+\r
+    if (__pSupportedLocaleList != null)\r
+    {\r
+        __pSupportedLocaleList->RemoveAll(true);\r
+        delete __pSupportedLocaleList;\r
+    }\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::Construct(ISpeechToTextEventListener& listener)\r
+{\r
+    int sttError = stt_create(&__sttHandle);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to create", GetEngineErrorMessage(sttError));\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_SYSTEM, "Failed to create.");\r
+\r
+    Locale *pLocale = new (std::nothrow) Locale(LANGUAGE_INVALID, COUNTRY_INVALID);\r
+    SysTryReturnResult(NID_UIX_SPEECH, pLocale != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    ArrayList* pLocaleList = new (std::nothrow) ArrayList();\r
+    SysTryReturnResult(NID_UIX_SPEECH, pLocaleList != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    result r = pLocaleList->Construct();\r
+    SysTryReturnResult(NID_UIX_SPEECH, r == E_SUCCESS, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    __pCurrentLocale = pLocale;\r
+    __pSupportedLocaleList = pLocaleList;\r
+    __pSpeechToTextListener = &listener;\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::Initialize(void)\r
+{\r
+    SysAssertf(__isInitialized != true,\r
+                "Already calling Initialize() twice or more on a same instance is not allowed for this class.");\r
+\r
+    int sttError = stt_set_error_cb(__sttHandle, SttErrorReceiver, __pSpeechToTextListener);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to set the error callback.", GetEngineErrorMessage(sttError));\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    sttError = stt_set_state_changed_cb(__sttHandle, SttStateChangedReceiver, this);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE,  "[%s] Failed to set the state changed callback.", GetEngineErrorMessage(sttError));\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    sttError = stt_set_partial_result_cb(__sttHandle, SttPartialResultReceiver, __pSpeechToTextListener);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to set the partial result callback.", GetEngineErrorMessage(sttError));\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    sttError = stt_set_result_cb(__sttHandle, SttResultReceiver, __pSpeechToTextListener);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to set the result callback.", GetEngineErrorMessage(sttError));\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    sttError = stt_prepare(__sttHandle);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to prepare.", GetEngineErrorMessage(sttError));\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::Start(void)\r
+{\r
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,\r
+                "Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    stt_state_e sttState = STT_STATE_READY;\r
+    const char* sttRecognitionType = null;\r
+    const char* pSttRecognitionLanguageN = null;\r
+\r
+    int sttError = stt_get_state(__sttHandle, &sttState);\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] The current state is '%s'.",\r
+               GetEngineErrorMessage(sttError), GetEngineStateMessage(sttState));\r
+\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttState == STT_STATE_READY, E_INVALID_OPERATION, "The TTS state should be SPEECH_TO_TEXT_STATUS_READY.");\r
+\r
+\r
+    sttRecognitionType = ConvertOspRecognitionTypeToEngine(__grammar);\r
+    pSttRecognitionLanguageN = ConvertOspLocaleToEngineN(*__pCurrentLocale);\r
+    SysTryReturnResult(NID_UIX_SPEECH, pSttRecognitionLanguageN != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+    sttError = stt_start(__sttHandle, pSttRecognitionLanguageN, sttRecognitionType);\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError != STT_ERROR_RECORDER_BUSY, E_SERVICE_BUSY, "The recorder is busy.");\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_SYSTEM, "Failed to start.");\r
+\r
+    delete[] pSttRecognitionLanguageN;\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::Stop(void)\r
+{\r
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,\r
+                "Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    stt_state_e sttState = STT_STATE_READY;\r
+\r
+    int sttError = stt_get_state(__sttHandle, &sttState);\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");\r
+\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttState == STT_STATE_RECORDING, E_INVALID_OPERATION,\r
+            "The STT state should be SPEECH_TO_TEXT_STATUS_RECORDING.");\r
+\r
+    sttError = stt_stop(__sttHandle);\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError != STT_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_SYSTEM, "Failed to stop.");\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::Cancel(void)\r
+{\r
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,\r
+                "Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    stt_state_e sttState = STT_STATE_READY;\r
+\r
+    int sttError = stt_get_state(__sttHandle, &sttState);\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");\r
+\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttState != STT_STATE_READY, E_INVALID_OPERATION,\r
+            "The STT state should be SPEECH_TO_TEXT_STATUS_RECORDING or SPEECH_TO_TEXT_STATUS_PROCESSING.");\r
+\r
+    sttError = stt_cancel(__sttHandle);\r
+    SysTryReturnResult(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] Failed to cancel.");\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+bool\r
+_SpeechToTextImpl::IsLocaleSupported(const Locale& locale) const\r
+{\r
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, false, E_INVALID_STATE,\r
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    SetLastResult(E_SUCCESS);\r
+    return __pSupportedLocaleList->Contains(locale);\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::SetLocale(const Locale& locale)\r
+{\r
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,\r
+            "Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    SysTryReturnResult(NID_UIX_SPEECH, IsLocaleSupported(locale), E_UNSUPPORTED_LOCALE, "This locale is not supported.")\r
+\r
+    *__pCurrentLocale = locale;\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+Tizen::Locales::Locale\r
+_SpeechToTextImpl::GetLocale(void) const\r
+{\r
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, Locale(LANGUAGE_INVALID, COUNTRY_INVALID), E_INVALID_STATE,\r
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    SetLastResult(E_SUCCESS);\r
+    return *__pCurrentLocale;\r
+}\r
+\r
+const IList*\r
+_SpeechToTextImpl::GetSupportedLocales(void) const\r
+{\r
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, null, E_INVALID_STATE,\r
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    SetLastResult(E_SUCCESS);\r
+    return __pSupportedLocaleList;\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::SetGrammar(SpeechToTextGrammar grammar)\r
+{\r
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,\r
+            "Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    __grammar = grammar;\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+SpeechToTextGrammar\r
+_SpeechToTextImpl::GetGrammar(void) const\r
+{\r
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, SPEECH_TO_TEXT_GRAMMAR_FREE, E_INVALID_STATE,\r
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    SetLastResult(E_SUCCESS);\r
+\r
+    return __grammar;\r
+}\r
+\r
+result\r
+_SpeechToTextImpl::SetSilenceDetectionEnabled(bool enable)\r
+{\r
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,\r
+            "Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    int sttError = stt_set_silence_detection(__sttHandle, ConvertOspSilenceDetectionTypeToEngine(enable));\r
+    SysTryLog(NID_UIX_SPEECH, sttError == STT_ERROR_NONE, "[%s] Failed to set the silence detection.", GetEngineErrorMessage(sttError));\r
+\r
+    __isSilenceDetection = enable;\r
+\r
+    return E_SUCCESS;\r
+}\r
+\r
+bool\r
+_SpeechToTextImpl::IsSilenceDetectionEnabled(void) const\r
+{\r
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, false, E_INVALID_STATE,\r
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    SetLastResult(E_SUCCESS);\r
+    return __isSilenceDetection;\r
+}\r
+\r
+SpeechToTextStatus\r
+_SpeechToTextImpl::GetCurrentStatus(void) const\r
+{\r
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, SPEECH_TO_TEXT_STATUS_NONE, E_INVALID_STATE,\r
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnSpeechToTextInitialized() event.");\r
+\r
+    SetLastResult(E_SUCCESS);\r
+    return __currentStatus;\r
+}\r
+\r
+_SpeechToTextImpl*\r
+_SpeechToTextImpl::GetInstance(SpeechToText& speechToText)\r
+{\r
+    return speechToText.__pSpeechToTextImpl;\r
+}\r
+\r
+const _SpeechToTextImpl*\r
+_SpeechToTextImpl::GetInstance(const SpeechToText& speechToText)\r
+{\r
+    return speechToText.__pSpeechToTextImpl;\r
+}\r
+\r
+const char*\r
+_SpeechToTextImpl::ConvertOspRecognitionTypeToEngine(SpeechToTextGrammar grammar)\r
+{\r
+    switch (grammar)\r
+    {\r
+    case SPEECH_TO_TEXT_GRAMMAR_FREE:\r
+        return STT_RECOGNITION_TYPE_FREE;\r
+\r
+    case SPEECH_TO_TEXT_GRAMMAR_WEB_SEARCH:\r
+        return STT_RECOGNITION_TYPE_WEB_SEARCH;\r
+\r
+    default:\r
+        return null;\r
+    }\r
+}\r
+\r
+stt_option_silence_detection_e\r
+_SpeechToTextImpl::ConvertOspSilenceDetectionTypeToEngine(bool silenceDetectionType)\r
+{\r
+    if (silenceDetectionType)\r
+    {\r
+        return STT_OPTION_SILENCE_DETECTION_TRUE;\r
+    }\r
+    else\r
+    {\r
+        return STT_OPTION_SILENCE_DETECTION_FALSE;\r
+    }\r
+}\r
+\r
+const char*\r
+_SpeechToTextImpl::ConvertOspLocaleToEngineN(const Locale& locale)\r
+{\r
+    String strLanguageCode = Locale::LanguageCodeToTwoLetterLanguageCodeString(locale.GetLanguageCode());\r
+    String strCountryCode = Locale::CountryCodeToString(locale.GetCountryCode());\r
+\r
+    String strLanguage = strLanguageCode + L"_" + strCountryCode;\r
+\r
+    return _StringConverter::CopyToCharArrayN(strLanguage);\r
+}\r
+\r
+const Tizen::Locales::Locale*\r
+_SpeechToTextImpl::ConvertEngineLocaleToOspN(const String& strSource)\r
+{\r
+    String strDelim(L"_");\r
+    String strLanguageCode;\r
+    String strCountryCode;\r
+\r
+    LanguageCode languageCode = LANGUAGE_INVALID;\r
+    CountryCode countryCode = COUNTRY_INVALID;\r
+\r
+    Utility::StringTokenizer toknizer(strSource, strDelim);\r
+    if (toknizer.GetTokenCount() == 2)\r
+    {\r
+        toknizer.GetNextToken(strLanguageCode);\r
+        toknizer.GetNextToken(strCountryCode);\r
+\r
+        languageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(strLanguageCode);\r
+        countryCode = Locale::StringToCountryCode(strCountryCode);\r
+    }\r
+\r
+    return new (std::nothrow) Locale(languageCode, countryCode);\r
+}\r
+\r
+const char*\r
+_SpeechToTextImpl::GetEngineErrorMessage(int error)\r
+{\r
+    switch (error)\r
+    {\r
+    case STT_ERROR_NONE:\r
+        return "STT_ERROR_NONE";\r
+\r
+    case STT_ERROR_OUT_OF_MEMORY:\r
+        return "STT_ERROR_OUT_OF_MEMORY";\r
+\r
+    case STT_ERROR_IO_ERROR:\r
+        return "STT_ERROR_IO_ERROR";\r
+\r
+    case STT_ERROR_INVALID_PARAMETER:\r
+        return "STT_ERROR_INVALID_PARAMETER";\r
+\r
+    case STT_ERROR_INVALID_STATE:\r
+        return "STT_ERROR_INVALID_STATE";\r
+\r
+    case STT_ERROR_INVALID_LANGUAGE:\r
+        return "STT_ERROR_INVALID_LANGUAGE";\r
+\r
+    case STT_ERROR_ENGINE_NOT_FOUND:\r
+        return "STT_ERROR_ENGINE_NOT_FOUND";\r
+\r
+    case STT_ERROR_TIMED_OUT:\r
+        return "STT_ERROR_TIMED_OUT";\r
+\r
+    case STT_ERROR_OPERATION_FAILED:\r
+        return "STT_ERROR_OPERATION_FAILED";\r
+\r
+    case STT_ERROR_RECORDER_BUSY:\r
+        return "STT_ERROR_RECORDER_BUSY";\r
+\r
+    case STT_ERROR_OUT_OF_NETWORK:\r
+        return "STT_ERROR_OUT_OF_NETWORK";\r
+\r
+    default:\r
+        return "STT_ERROR_UNKNOWN";\r
+    }\r
+}\r
+\r
+const char*\r
+_SpeechToTextImpl::GetEngineStateMessage(stt_state_e state)\r
+{\r
+    switch (state)\r
+    {\r
+    case STT_STATE_CREATED:\r
+        return "STT_STATE_CREATED";\r
+\r
+    case STT_STATE_READY:\r
+        return "STT_STATE_READY";\r
+\r
+    case STT_STATE_RECORDING:\r
+        return "STT_STATE_RECORDING";\r
+\r
+    case STT_STATE_PROCESSING:\r
+        return "STT_STATE_PROCESSING";\r
+\r
+    default:\r
+        return "STT_STATE_UNKNOWN";\r
+    }\r
+}\r
+\r
+} } } // Tizen::Uix::Speech\r
diff --git a/src/stt/FUixSpeech_SpeechToTextImpl.h b/src/stt/FUixSpeech_SpeechToTextImpl.h
new file mode 100644 (file)
index 0000000..ce93f03
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeech_SpeechToTextImpl.h
+ * @brief   This is the header file for the %_SpeechToTextImpl class.
+ *
+ * This header file contains the declarations of the %_SpeechToTextImpl class.
+ */
+
+#ifndef _FUIX_SPEECH_INTERNAL_SPEECH_TO_TEXT_IMPL_H_
+#define _FUIX_SPEECH_INTERNAL_SPEECH_TO_TEXT_IMPL_H_
+
+#include <stt.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FUixSpeechSpeechToTextTypes.h>
+#include <FUixSpeechISpeechToTextEventListener.h>
+
+namespace Tizen { namespace Base
+{
+    class String;
+}}
+namespace Tizen { namespace Base { namespace Collection
+{
+    class IList;
+}}}
+namespace Tizen { namespace Locales
+{
+    class Locale;
+}}
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+class SpeechToText;
+
+class _SpeechToTextImpl
+{
+public:
+    _SpeechToTextImpl(void);
+    virtual ~_SpeechToTextImpl(void);
+
+    result Construct(ISpeechToTextEventListener& listener);
+    result Initialize(void);
+
+    result Start(void);
+    result Stop(void);
+    result Cancel(void);
+
+    result SetLocale(const Tizen::Locales::Locale& locale);
+    Tizen::Locales::Locale GetLocale(void) const;
+    bool IsLocaleSupported(const Tizen::Locales::Locale& locale) const;
+    const Tizen::Base::Collection::IList* GetSupportedLocales(void) const;
+
+    result SetGrammar(SpeechToTextGrammar grammar);
+    SpeechToTextGrammar GetGrammar(void) const;
+
+    result SetSilenceDetectionEnabled(bool enable);
+    bool IsSilenceDetectionEnabled(void) const;
+
+    SpeechToTextStatus GetCurrentStatus(void) const;
+
+    static _SpeechToTextImpl* GetInstance(SpeechToText& speechToText);
+    static const _SpeechToTextImpl* GetInstance(const SpeechToText& speechToText);
+
+private:
+    _SpeechToTextImpl(const _SpeechToTextImpl& rhs);
+    _SpeechToTextImpl& operator =(const _SpeechToTextImpl& rhs);
+
+    static void SttResultReceiver(stt_h sttHandle, const char* type, const char* data[], int dataCount, const char* msg, void* pListener);
+    static void SttPartialResultReceiver(stt_h sttHandle, const char* data, void* pListener);
+    static void SttStateChangedReceiver(stt_h sttHandle, stt_state_e previousState, stt_state_e currentState, void* pSttInstance);
+    static void SttErrorReceiver(stt_h sttHandle, stt_error_e error, void* pListener);
+    static bool SttSupportedLocaleListGetter(stt_h sttHandle, const char* language, void* pLocaleList);
+
+    static const char* GetEngineErrorMessage(const int type);
+    static const char* GetEngineStateMessage(const stt_state_e state);
+
+    static const Tizen::Locales::Locale* ConvertEngineLocaleToOspN(const Tizen::Base::String& strSource);
+    static const char* ConvertOspLocaleToEngineN(const Tizen::Locales::Locale& locale);
+
+    static const char* ConvertOspRecognitionTypeToEngine(SpeechToTextGrammar grammar);
+
+    stt_option_silence_detection_e ConvertOspSilenceDetectionTypeToEngine(bool silenceDetectionType);
+
+private:
+    stt_h __sttHandle;
+    ISpeechToTextEventListener* __pSpeechToTextListener;
+
+    Tizen::Locales::Locale* __pCurrentLocale;
+    SpeechToTextGrammar __grammar;
+    Tizen::Base::Collection::IList* __pSupportedLocaleList;
+
+    bool __isInitialized;
+    bool __isSilenceDetection;
+    SpeechToTextStatus __currentStatus;
+
+}; // _SpeechToTextImpl
+
+} } } // Tizen::Uix::Speech
+
+#endif
diff --git a/src/tts/CMakeLists.txt b/src/tts/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..cbeeee3
--- /dev/null
@@ -0,0 +1,32 @@
+SET (this_target osp-speech-tts)
+
+INCLUDE_DIRECTORIES(
+       ./
+       ${COMMON_INCLUDE_DIRS}  
+       )
+
+SET (${this_target}_SOURCE_FILES
+       FUixSpeechTextToSpeech.cpp
+       FUixSpeech_TextToSpeechImpl.cpp
+)
+
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
+
+TARGET_LINK_LIBRARIES(${this_target} "-losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-ltts" )
+
+OSP_STRIP(${this_target})
+
diff --git a/src/tts/FUixSpeechTextToSpeech.cpp b/src/tts/FUixSpeechTextToSpeech.cpp
new file mode 100644 (file)
index 0000000..245e6ee
--- /dev/null
@@ -0,0 +1,147 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeechTextToSpeech.cpp
+ * @brief   This is the implementation file for the TextToSpeech class.
+ *
+ * This files contains implementation of the TextToSpeech class.
+ */
+
+#include <FBaseErrors.h>
+#include <FLclLocale.h>
+#include <FUixSpeechTextToSpeech.h>
+#include <FBaseSysLog.h>
+#include <FUixSpeech_TextToSpeechImpl.h>
+
+using namespace Tizen::Locales;
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+TextToSpeech::TextToSpeech(void)
+       : __pTextToSpeechImpl(null)
+{
+}
+
+TextToSpeech::~TextToSpeech(void)
+{
+    delete __pTextToSpeechImpl;
+}
+
+result
+TextToSpeech::Construct(ITextToSpeechEventListener& listener)
+{
+    SysAssertf(__pTextToSpeechImpl == null,
+            "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+    __pTextToSpeechImpl = new (std::nothrow) _TextToSpeechImpl();
+       SysTryReturn(NID_UIX_SPEECH, __pTextToSpeechImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+       return __pTextToSpeechImpl->Construct(listener);
+}
+
+result
+TextToSpeech::Initialize(void)
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pTextToSpeechImpl->Initialize();
+}
+
+result
+TextToSpeech::Speak(const Tizen::Base::String& text, TextToSpeechRequestMode requestMode)
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pTextToSpeechImpl->Speak(text, requestMode);
+}
+
+result
+TextToSpeech::Stop(void)
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pTextToSpeechImpl->Stop();
+}
+
+result
+TextToSpeech::Pause(void)
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pTextToSpeechImpl->Pause();
+}
+
+result
+TextToSpeech::Resume(void)
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pTextToSpeechImpl->Resume();
+}
+
+result
+TextToSpeech::SetLocale(const Tizen::Locales::Locale& locale)
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+       return __pTextToSpeechImpl->SetLocale(locale);
+}
+
+Tizen::Locales::Locale
+TextToSpeech::GetLocale(void) const
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+       return __pTextToSpeechImpl->GetLocale();
+}
+
+const Tizen::Base::Collection::IList*
+TextToSpeech::GetSupportedLocales(void) const
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+       return __pTextToSpeechImpl->GetSupportedLocales();
+}
+
+bool
+TextToSpeech::IsLocaleSupported(const Tizen::Locales::Locale& locale) const
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pTextToSpeechImpl->IsLocaleSupported(locale);
+}
+
+
+result
+TextToSpeech::SetSpeechRate(TextToSpeechSpeechRate rate)
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+       return __pTextToSpeechImpl->SetSpeechRate(rate);
+}
+
+TextToSpeechStatus
+TextToSpeech::GetCurrentStatus(void) const
+{
+    SysAssertf(__pTextToSpeechImpl != null, "Not yet constructed! Construct() should be called before use.");
+
+    return __pTextToSpeechImpl->GetCurrentStatus();
+}
+
+} } } // Tizen::Uix::Speech
diff --git a/src/tts/FUixSpeech_TextToSpeechImpl.cpp b/src/tts/FUixSpeech_TextToSpeechImpl.cpp
new file mode 100644 (file)
index 0000000..5313326
--- /dev/null
@@ -0,0 +1,656 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeech_TextToSpeechImpl.h
+ * @brief   This is the implementation file for the _TextToSpeechImpl class.
+ *
+ * This files contains implementation of the _TextToSpeechImpl class.
+ */
+
+#include <new>
+#include <FBaseColIList.h>
+#include <FBaseColArrayList.h>
+#include <FBaseString.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FLclLocale.h>
+#include <FUixSpeechTextToSpeech.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FUixSpeech_TextToSpeechImpl.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Locales;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+_OSP_EXPORT_ Tizen::Uix::Speech::_ITextToSpeech*
+_GetInstance_FUixTextToSpeechImpl(void)
+{
+    return new (std::nothrow) Tizen::Uix::Speech::_TextToSpeechImpl();
+}
+
+_OSP_EXPORT_ void
+_ReleaseInstance_FUixTextToSpeechImpl(Tizen::Uix::Speech::_ITextToSpeech* pInstacne)
+{
+    delete pInstacne;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+void
+_TextToSpeechImpl::TtsStateChangedReceiver(tts_h ttsHandle, tts_state_e previousState, tts_state_e currentState, void* pTtsInstance)
+{
+    SysLog(NID_UIX_SPEECH, "The current state is changed to '%s' from '%s'.",
+               GetEngineStateMessage(currentState), GetEngineStateMessage(previousState));
+
+       _TextToSpeechImpl* pInstance = static_cast<_TextToSpeechImpl*>(pTtsInstance);
+    ITextToSpeechEventListener* pListener = pInstance->__pTextToSpeechListener;
+
+    if ((previousState == TTS_STATE_CREATED) && (currentState == TTS_STATE_READY))
+    {
+        char *pDefaultLang = null;
+        tts_voice_type_e defaultVoiceType;
+
+        int ttsError = tts_get_default_voice(ttsHandle, &pDefaultLang, &defaultVoiceType);
+        if (ttsError == TTS_ERROR_NONE)
+        {
+            SysLog(NID_UIX_SPEECH, "The default language is '%s', and voice type is '%d'." , pDefaultLang, defaultVoiceType);
+            const Locale* pDefaultLocale = ConvertEngineLocaleToOspN(pDefaultLang);
+            *pInstance->__pCurrentLocale = *pDefaultLocale;
+
+            delete pDefaultLocale;
+            free(pDefaultLang);
+        }
+
+        ttsError = tts_foreach_supported_voices(ttsHandle, TtsSupportedLocaleListGetter, (void*)(pInstance->__pSupportedLocaleList));
+        SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to get supported voices", GetEngineErrorMessage(ttsError));
+
+        pInstance->__isInitialized = true;
+        pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_READY;
+
+        pListener->OnTextToSpeechInitialized();
+        pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_READY);
+    }
+    else if ((previousState == TTS_STATE_READY || previousState == TTS_STATE_PAUSED) && (currentState == TTS_STATE_PLAYING))
+    {
+        pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_PLAYING;
+        pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_PLAYING);
+    }
+    else if ((previousState == TTS_STATE_PLAYING) && (currentState == TTS_STATE_PAUSED))
+    {
+        pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_PAUSED;
+        pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_PAUSED);
+    }
+    else if ((previousState == TTS_STATE_PLAYING || previousState == TTS_STATE_PAUSED) && (currentState == TTS_STATE_READY))
+    {
+        pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_READY;
+        pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_READY);
+    }
+    else
+    {
+        SysLog(NID_UIX_SPEECH, "The unknown state is changed to '%s' from '%s'.",
+                       GetEngineStateMessage(currentState), GetEngineStateMessage(previousState));
+    }
+}
+
+void
+_TextToSpeechImpl::TtsStartedReceiver(tts_h ttsHandle, int utteranceId, void* pListener)
+{
+       SysLog(NID_UIX_SPEECH, "The utterance(%d) has started.", utteranceId);
+}
+
+void
+_TextToSpeechImpl::TtsCompletedReceiver(tts_h ttsHandle, int utteranceId, void* pTtsInstance)
+{
+    _TextToSpeechImpl* pInstance = static_cast<_TextToSpeechImpl*>(pTtsInstance);
+    ITextToSpeechEventListener* pListener = pInstance->__pTextToSpeechListener;
+
+    SysLog(NID_UIX_SPEECH, "The utterance id is '%d' and the request count is '%d'.",
+               utteranceId, pInstance->__appendRequsetCount);
+
+    if ((--(pInstance->__appendRequsetCount) == 0) || (pInstance->__currentRequestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE))
+    {
+        SysLog(NID_UIX_SPEECH, "Automatically, Stop() method was called.");
+        int ttsError = tts_stop(ttsHandle);
+        SysTryReturnVoidResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM,
+                       "[%s] Failed to stop.", GetEngineErrorMessage(ttsError));
+    }
+
+       static_cast <ITextToSpeechEventListener*>(pListener)->OnTextToSpeechCompleted();
+}
+
+void
+_TextToSpeechImpl::TtsErrorReceiver(tts_h ttsHandle, int ttsUtteranceId, tts_error_e error, void* pListener)
+{
+       SysLog(NID_UIX_SPEECH, "[%s] Error occurred.", GetEngineErrorMessage(error));
+
+       TextToSpeechError ttsError;
+
+       switch (error)
+       {
+       case TTS_ERROR_OUT_OF_MEMORY:
+        ttsError = TEXT_TO_SPEECH_ERROR_OUT_OF_MEMORY;
+        break;
+       case TTS_ERROR_IO_ERROR:
+           ttsError = TEXT_TO_SPEECH_ERROR_IO_ERROR;
+        break;
+       case TTS_ERROR_OUT_OF_NETWORK:
+           ttsError = TEXT_TO_SPEECH_ERROR_NETWORK_ERROR;
+           break;
+       case TTS_ERROR_ENGINE_NOT_FOUND:
+           ttsError = TEXT_TO_SPEECH_ERROR_UNSUPPORTED_SERVICE;
+        break;
+       case TTS_ERROR_TIMED_OUT:
+           ttsError = TEXT_TO_SPEECH_ERROR_TIME_OUT;
+        break;
+       default:
+           ttsError = TEXT_TO_SPEECH_ERROR_SYSTEM_ERROR;
+        break;
+
+       }
+       static_cast <ITextToSpeechEventListener*>(pListener)->OnTextToSpeechErrorOccurred(ttsError);
+}
+
+bool
+_TextToSpeechImpl::TtsSupportedLocaleListGetter(tts_h ttsHandle, const char* pLanguage, tts_voice_type_e voiceType, void* pLocaleList)
+{
+       SysLog(NID_UIX_SPEECH, "The language is '%s' and the voice type is '%s'.",
+                       pLanguage, GetEngineVoiceTypeMessage(voiceType));
+
+       const Locale* pLocale = ConvertEngineLocaleToOspN(String(pLanguage));
+       if (pLocale == null)
+       {
+               static_cast <ArrayList*>(pLocaleList)->RemoveAll(true);
+               return false; // escape call back loop
+       }
+
+       if (pLocale->GetLanguageCode() == LANGUAGE_INVALID)
+       {
+           SysLog(NID_UIX_SPEECH, "The '%s' language is not supported.", pLanguage);
+           delete pLocale;
+       }
+       else
+       {
+        result r = static_cast<ArrayList*>(pLocaleList)->Add(*pLocale);
+        if (IsFailed(r))
+        {
+            static_cast<ArrayList*>(pLocaleList)->RemoveAll(true);
+            return false;   // escape call back loop
+        }
+       }
+
+       return true; // continue call back loop
+}
+
+_TextToSpeechImpl::_TextToSpeechImpl(void)
+       : __ttsHandle(null)
+       , __isInitialized(false)
+    , __currentRequestMode(TEXT_TO_SPEECH_REQUEST_MODE_APPEND)
+    , __appendRequsetCount(0)
+    , __pCurrentLocale(null)
+    , __pSupportedLocaleList(null)
+    , __pTextToSpeechListener(null)
+    , __currentStatus(TEXT_TO_SPEECH_STATUS_NONE)
+    , __speechRate(TEXT_TO_SPEECH_SPEECH_RATE_SYSTEM_SETTING)
+{
+}
+
+_TextToSpeechImpl::~_TextToSpeechImpl(void)
+{
+    tts_state_e ttsState = TTS_STATE_READY;
+
+    int ttsError = tts_get_state(__ttsHandle, &ttsState);
+    SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to get the current state.", GetEngineErrorMessage(ttsError));
+
+    if (ttsState == TTS_STATE_PLAYING || ttsState == TTS_STATE_PAUSED)
+    {
+        ttsError = tts_stop(__ttsHandle);
+        SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to stop.", GetEngineErrorMessage(ttsError));
+    }
+
+    if (__isInitialized)
+    {
+        ttsError = tts_unprepare(__ttsHandle);
+        SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unprepare.", GetEngineErrorMessage(ttsError));
+
+        ttsError = tts_unset_utterance_completed_cb(__ttsHandle);
+        SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the utterance completed callback.", GetEngineErrorMessage(ttsError));
+
+        ttsError = tts_unset_utterance_started_cb(__ttsHandle);
+        SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the utterance started callback.", GetEngineErrorMessage(ttsError));
+
+        ttsError = tts_unset_state_changed_cb(__ttsHandle);
+        SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the state changed callback.", GetEngineErrorMessage(ttsError));
+
+        ttsError = tts_unset_error_cb(__ttsHandle);
+        SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the error callback.", GetEngineErrorMessage(ttsError));
+    }
+
+    ttsError = tts_destroy(__ttsHandle);
+    SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to destroy.", GetEngineErrorMessage(ttsError));
+
+    delete __pCurrentLocale;
+
+    if (__pSupportedLocaleList != null)
+    {
+        __pSupportedLocaleList->RemoveAll(true);
+        delete __pSupportedLocaleList;
+    }
+}
+
+result
+_TextToSpeechImpl::Construct(ITextToSpeechEventListener& listener)
+{
+       int ttsError = tts_create(&__ttsHandle);
+       SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to create", GetEngineErrorMessage(ttsError));
+       SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to create.");
+
+    Locale *pLocale = new (std::nothrow) Locale(LANGUAGE_INVALID, COUNTRY_INVALID);
+    SysTryReturnResult(NID_UIX_SPEECH, pLocale != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    ArrayList* pLocaleList = new (std::nothrow) ArrayList();
+    SysTryReturnResult(NID_UIX_SPEECH, pLocaleList != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    result r = pLocaleList->Construct();
+    SysTryReturnResult(NID_UIX_SPEECH, r == E_SUCCESS, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    __pCurrentLocale = pLocale;
+    __pSupportedLocaleList = pLocaleList;
+       __pTextToSpeechListener = &listener;
+
+       return E_SUCCESS;
+}
+
+result
+_TextToSpeechImpl::Initialize(void)
+{
+    SysAssertf(__isInitialized != true,
+                "Already calling Initialize() twice or more on a same instance is not allowed for this class.");
+
+    int ttsError = tts_set_error_cb(__ttsHandle, TtsErrorReceiver, (void*)(__pTextToSpeechListener));
+    SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the error callback.", GetEngineErrorMessage(ttsError));
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    ttsError = tts_set_state_changed_cb(__ttsHandle, TtsStateChangedReceiver, (void*)(this));
+    SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the state changed callback.", GetEngineErrorMessage(ttsError));
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    ttsError = tts_set_utterance_started_cb(__ttsHandle, TtsStartedReceiver, (void*)(__pTextToSpeechListener));
+    SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the utterance started callback.", GetEngineErrorMessage(ttsError));
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    ttsError = tts_set_utterance_completed_cb(__ttsHandle, TtsCompletedReceiver, (void*)(this));
+    SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the utterance completed callback.", GetEngineErrorMessage(ttsError));
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    ttsError = tts_prepare(__ttsHandle);
+    SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to prepare", GetEngineErrorMessage(ttsError));
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    return E_SUCCESS;
+}
+
+result
+_TextToSpeechImpl::Speak(const String& text, TextToSpeechRequestMode requestMode)
+{
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
+            "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+    result r = E_SUCCESS;
+    tts_state_e ttsState = TTS_STATE_READY;
+
+    int ttsError = tts_get_state(__ttsHandle, &ttsState);
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
+
+    const char* pLanguage = ConvertOspLocaleToEngineN(*__pCurrentLocale);
+    SysTryReturnResult(NID_UIX_SPEECH, pLanguage != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+    if (requestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE && ttsState != TTS_STATE_READY)
+    {
+        Stop();
+    }
+
+    const char* pTextN = _StringConverter::CopyToCharArrayN(text);
+    tts_speed_e ttsSpeed = ConvertOspSpeedToEngine(__speechRate);
+    int ttsUtteranceId = 0;
+
+    SysTryCatchLabel(NID_UIX_SPEECH, pTextN != null, r = E_OUT_OF_MEMORY, CATCH_LANG, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+    ttsError = tts_add_text(__ttsHandle, pTextN, pLanguage, TTS_VOICE_TYPE_AUTO, ttsSpeed, &ttsUtteranceId);
+    SysTryCatch(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, r = E_OUT_OF_MEMORY, E_SYSTEM, "[E_SYSTEM] Failed to add a text.");
+
+    if (requestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE || __appendRequsetCount == 0)
+    {
+        __appendRequsetCount = 0;
+
+        ttsError = tts_play(__ttsHandle);
+        SysTryCatch(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to play.", GetEngineErrorMessage(ttsError));
+    }
+
+    __appendRequsetCount++;
+    __currentRequestMode = requestMode;
+
+    if (__appendRequsetCount == 1)
+    {
+        __pTextToSpeechListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_SYNTHESIZING);
+    }
+
+    SysLog(NID_UIX_SPEECH, "The utterance id is '%d', the request count is '%d' and the request mode is '%s'.",
+               ttsUtteranceId, __appendRequsetCount, (requestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE ? "Replace" : "Append"));
+
+CATCH:
+    delete[] pTextN;
+
+CATCH_LANG:
+    delete[] pLanguage;
+
+    return r;
+}
+
+result
+_TextToSpeechImpl::Stop(void)
+{
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
+                "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+    tts_state_e ttsState = TTS_STATE_READY;
+
+    int ttsError = tts_get_state(__ttsHandle, &ttsState);
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
+    SysTryReturnResult(NID_UIX_SPEECH, ttsState != TTS_STATE_READY, E_INVALID_OPERATION,
+            "The TTS state should be TTS_STATUS_PLAYING or TTS_STATUS_PAUSED.");
+
+    ttsError = tts_stop(__ttsHandle);
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to stop.");
+    __appendRequsetCount = 0;
+
+    return E_SUCCESS;
+}
+
+result
+_TextToSpeechImpl::Pause(void)
+{
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
+                "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.")
+
+    tts_state_e ttsState = TTS_STATE_READY;
+
+    int ttsError = tts_get_state(__ttsHandle, &ttsState);
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
+    SysTryReturnResult(NID_UIX_SPEECH, ttsState == TTS_STATE_PLAYING, E_INVALID_OPERATION, "The TTS state should be TTS_STATUS_PLAYING.");
+
+    ttsError = tts_pause(__ttsHandle);
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to pause.");
+
+    return E_SUCCESS;
+}
+
+result
+_TextToSpeechImpl::Resume(void)
+{
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
+                "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+    tts_state_e ttsState = TTS_STATE_READY;
+
+    int ttsError = tts_get_state(__ttsHandle, &ttsState);
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
+    SysTryReturnResult(NID_UIX_SPEECH, ttsState == TTS_STATE_PAUSED, E_INVALID_OPERATION, "The TTS state should be TTS_STATUS_PAUSED.");
+
+    ttsError = tts_play(__ttsHandle);
+    SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to resume.");
+
+    return E_SUCCESS;
+}
+
+result
+_TextToSpeechImpl::SetLocale(const Locale& locale)
+{
+    SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
+            "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.")
+    SysTryReturnResult(NID_UIX_SPEECH, __pSupportedLocaleList->Contains(locale), E_UNSUPPORTED_LOCALE, "This locale is not supported.");
+
+       *__pCurrentLocale = locale;
+       return E_SUCCESS;
+}
+
+Tizen::Locales::Locale
+_TextToSpeechImpl::GetLocale(void) const
+{
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, Locale(LANGUAGE_INVALID, COUNTRY_INVALID), E_INVALID_STATE,
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+    SetLastResult(E_SUCCESS);
+    return *__pCurrentLocale;
+}
+
+const Tizen::Base::Collection::IList*
+_TextToSpeechImpl::GetSupportedLocales(void) const
+{
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, null, E_INVALID_STATE,
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+    SetLastResult(E_SUCCESS);
+    return __pSupportedLocaleList->GetCount() > 0 ? __pSupportedLocaleList : null;
+}
+
+bool
+_TextToSpeechImpl::IsLocaleSupported(const Tizen::Locales::Locale& locale) const
+{
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, false, E_INVALID_STATE,
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+    SetLastResult(E_SUCCESS);
+    return __pSupportedLocaleList->Contains(locale);
+}
+
+result
+_TextToSpeechImpl::SetSpeechRate(TextToSpeechSpeechRate speechRate)
+{
+       SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
+            "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+       __speechRate = speechRate;
+
+       return E_SUCCESS;
+}
+
+TextToSpeechStatus
+_TextToSpeechImpl::GetCurrentStatus(void) const
+{
+       SysTryReturn(NID_UIX_SPEECH, __isInitialized, TEXT_TO_SPEECH_STATUS_NONE, E_INVALID_STATE,
+            "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
+
+    SetLastResult(E_SUCCESS);
+    return __currentStatus;
+}
+
+_TextToSpeechImpl*
+_TextToSpeechImpl::GetInstance(TextToSpeech& textToSpeech)
+{
+    return textToSpeech.__pTextToSpeechImpl;
+}
+
+const _TextToSpeechImpl*
+_TextToSpeechImpl::GetInstance(const TextToSpeech& textToSpeech)
+{
+    return textToSpeech.__pTextToSpeechImpl;
+}
+
+const char*
+_TextToSpeechImpl::GetEngineErrorMessage(const int errorType)
+{
+    switch (errorType)
+    {
+    case TTS_ERROR_NONE:
+        return "TTS_ERROR_NONE";
+
+    case TTS_ERROR_OUT_OF_MEMORY:
+        return "TTS_ERROR_OUT_OF_MEMORY";
+
+    case TTS_ERROR_IO_ERROR:
+        return "TTS_ERROR_IO_ERROR";
+
+    case TTS_ERROR_INVALID_PARAMETER:
+        return "TTS_ERROR_INVALID_PARAMETER";
+
+    case TTS_ERROR_INVALID_STATE:
+        return "TTS_ERROR_INVALID_STATE";
+
+    case TTS_ERROR_INVALID_VOICE:
+        return "TTS_ERROR_INVALID_VOICE";
+
+    case TTS_ERROR_ENGINE_NOT_FOUND:
+        return "TTS_ERROR_ENGINE_NOT_FOUND";
+
+    case TTS_ERROR_TIMED_OUT:
+        return "TTS_ERROR_TIMED_OUT";
+
+    case TTS_ERROR_OPERATION_FAILED:
+        return "TTS_ERROR_OPERATION_FAILED";
+
+    default:
+        return "TTS_ERROR_UNKNOWN_ERROR";
+    }
+}
+
+const char*
+_TextToSpeechImpl::GetEngineStateMessage(const tts_state_e state)
+{
+    switch (state)
+    {
+       case TTS_STATE_CREATED:
+               return "CREATED";
+
+    case TTS_STATE_READY:
+        return "READY";
+
+    case TTS_STATE_PLAYING:
+        return "PLAYING";
+
+    case TTS_STATE_PAUSED:
+        return "PAUSED";
+
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char*
+_TextToSpeechImpl::GetEngineVoiceTypeMessage(const tts_voice_type_e voiceType)
+{
+    switch (voiceType)
+    {
+    case TTS_VOICE_TYPE_AUTO:
+        return "TTS_VOICE_TYPE_AUTO";
+
+    case TTS_VOICE_TYPE_MALE:
+        return "TTS_VOICE_TYPE_MALE";
+
+    case TTS_VOICE_TYPE_FEMALE:
+        return "TTS_VOICE_TYPE_FEMALE";
+
+    case TTS_VOICE_TYPE_CHILD:
+        return "TTS_VOICE_TYPE_CHILD";
+
+    case TTS_VOICE_TYPE_USER1:
+        return "TTS_VOICE_TYPE_USER1";
+
+    case TTS_VOICE_TYPE_USER2:
+        return "TTS_VOICE_TYPE_USER2";
+
+    case TTS_VOICE_TYPE_USER3:
+        return "TTS_VOICE_TYPE_USER3";
+
+    default:
+        return "TTS_VOICE_TYPE_UNKNOWN";
+    }
+}
+
+tts_speed_e
+_TextToSpeechImpl::ConvertOspSpeedToEngine(const TextToSpeechSpeechRate& speechRate) const
+{
+    switch (speechRate)
+    {
+    case TEXT_TO_SPEECH_SPEECH_RATE_SYSTEM_SETTING:
+        return TTS_SPEED_AUTO;
+
+    case TEXT_TO_SPEECH_SPEECH_RATE_VERY_SLOW:
+        return TTS_SPEED_VERY_SLOW;
+
+    case TEXT_TO_SPEECH_SPEECH_RATE_SLOW:
+        return TTS_SPEED_SLOW;
+
+    case TEXT_TO_SPEECH_SPEECH_RATE_NORMAL:
+        return TTS_SPEED_NORMAL;
+
+    case TEXT_TO_SPEECH_SPEECH_RATE_FAST:
+        return TTS_SPEED_FAST;
+
+    case TEXT_TO_SPEECH_SPEECH_RATE_VERY_FAST:
+        return TTS_SPEED_VERY_FAST;
+
+    default:
+        return TTS_SPEED_AUTO;
+    }
+}
+
+const char*
+_TextToSpeechImpl::ConvertOspLocaleToEngineN(const Tizen::Locales::Locale& locale)
+{
+    String strLanguageCode = Locale::LanguageCodeToTwoLetterLanguageCodeString(locale.GetLanguageCode());
+    String strCountryCode = Locale::CountryCodeToString(locale.GetCountryCode());
+
+    String strLanguage = strLanguageCode + L"_" + strCountryCode;
+
+    return _StringConverter::CopyToCharArrayN(strLanguage);
+}
+
+const Tizen::Locales::Locale*
+_TextToSpeechImpl::ConvertEngineLocaleToOspN(const Tizen::Base::String& strSource)
+{
+    String strDelim(L"_");
+    String strLanguageCode;
+    String strCountryCode;
+
+    LanguageCode languageCode = LANGUAGE_INVALID;
+    CountryCode countryCode = COUNTRY_INVALID;
+
+    Utility::StringTokenizer toknizer(strSource, strDelim);
+    if (toknizer.GetTokenCount() == 2)
+    {
+        toknizer.GetNextToken(strLanguageCode);
+        toknizer.GetNextToken(strCountryCode);
+
+        languageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(strLanguageCode);
+        countryCode = Locale::StringToCountryCode(strCountryCode);
+    }
+
+    return new (std::nothrow) Locale(languageCode, countryCode);
+}
+
+} } } // Tizen::Uix::Speech
diff --git a/src/tts/FUixSpeech_TextToSpeechImpl.h b/src/tts/FUixSpeech_TextToSpeechImpl.h
new file mode 100644 (file)
index 0000000..62ff8d8
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+//
+
+/**
+ * @file    FUixSpeech_TextToSpeechImpl.h
+ * @brief   This is the header file for the %_TextToSpeechImpl class.
+ *
+ * This header file contains the declarations of the %_TextToSpeechImpl class.
+ */
+
+#ifndef _FUIX_SPEECH_INTERNAL_TEXT_TO_SPEECH_IMPL_H_
+#define _FUIX_SPEECH_INTERNAL_TEXT_TO_SPEECH_IMPL_H_
+
+#include <tts.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FUixSpeechTextToSpeechTypes.h>
+#include <FUixSpeechITextToSpeechEventListener.h>
+#include <FUixSpeech_ITextToSpeech.h>
+
+namespace Tizen { namespace Base { namespace Collection {
+    class IList;
+}}}
+namespace Tizen { namespace Locales {
+    class Locale;
+}}
+
+namespace Tizen { namespace Uix { namespace Speech
+{
+
+class TextToSpeech;
+
+class _TextToSpeechImpl
+    : public Tizen::Base::Object
+    , public Tizen::Uix::Speech::_ITextToSpeech
+{
+public:
+    static _TextToSpeechImpl* GetInstance(void);
+    static void ReleaseInstance();
+
+public:
+    virtual result Construct(ITextToSpeechEventListener& listener);
+    virtual result Initialize(void);
+
+    _TextToSpeechImpl(void);
+    virtual ~_TextToSpeechImpl(void);
+
+    virtual result Speak(const Tizen::Base::String& text, TextToSpeechRequestMode requestMode);
+    virtual result Stop(void);
+    virtual result Pause(void);
+    virtual result Resume(void);
+
+    virtual result SetLocale(const Tizen::Locales::Locale& locale);
+    virtual Tizen::Locales::Locale GetLocale(void) const;
+    virtual const Tizen::Base::Collection::IList* GetSupportedLocales(void) const;
+    virtual bool IsLocaleSupported(const Tizen::Locales::Locale& locale) const;
+
+    virtual result SetSpeechRate(TextToSpeechSpeechRate speechRate);
+
+    TextToSpeechStatus GetCurrentStatus(void) const;
+
+    static _TextToSpeechImpl* GetInstance(TextToSpeech& pTextToSpeech);
+    static const _TextToSpeechImpl* GetInstance(const TextToSpeech& pTextToSpeech);
+
+private:
+    static const char* GetEngineErrorMessage(const int type);
+    static const char* GetEngineStateMessage(const tts_state_e state);
+    static const char* GetEngineVoiceTypeMessage(const tts_voice_type_e voiceType);
+
+       static void TtsStateChangedReceiver(tts_h ttsHandle, tts_state_e previousState, tts_state_e currentState, void* pTtsInstance);
+    static void TtsStartedReceiver(tts_h ttsHandle, int utteranceId, void* pListener);
+    static void TtsCompletedReceiver(tts_h ttsHandle, int utteranceId, void* pTtsInstance);
+    static void TtsErrorReceiver(tts_h ttsHandle, int ttsUtteranceId, tts_error_e error, void* pListener);
+    static bool TtsSupportedLocaleListGetter(tts_h ttsHandle, const char* pLanguage, tts_voice_type_e voiceType, void* pLocaleList);
+
+    static const char* ConvertOspLocaleToEngineN(const Tizen::Locales::Locale& locale);
+    static const Tizen::Locales::Locale* ConvertEngineLocaleToOspN(const Tizen::Base::String& strSource);
+
+    tts_speed_e ConvertOspSpeedToEngine(const TextToSpeechSpeechRate& speechRate) const;
+
+private:
+    _TextToSpeechImpl(const _TextToSpeechImpl& rhs);
+    _TextToSpeechImpl& operator =(const _TextToSpeechImpl& rhs);
+
+private:
+    tts_h __ttsHandle;
+    bool __isInitialized;
+    TextToSpeechRequestMode __currentRequestMode;
+    int __appendRequsetCount;
+
+    Tizen::Locales::Locale* __pCurrentLocale;
+    Tizen::Base::Collection::IList* __pSupportedLocaleList;
+    ITextToSpeechEventListener* __pTextToSpeechListener;
+
+    TextToSpeechStatus __currentStatus;
+    TextToSpeechSpeechRate __speechRate;
+
+}; // _TextToSpeechImpl
+
+} } } // Tizen::Uix::Speech
+#endif