1 #ifndef DALI_TTS_PLAYER_H
2 #define DALI_TTS_PLAYER_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
26 #include <dali/public-api/dali-adaptor-common.h>
31 * @addtogroup dali_adaptor_framework
35 namespace Internal DALI_INTERNAL
44 * @brief The Text-to-speech (TTS) Player.
47 class DALI_ADAPTOR_API TtsPlayer : public BaseHandle
52 * @brief Enumeration for the instance of TTS mode.
57 DEFAULT = 0, ///< Default mode for normal application @SINCE_1_0.0
58 NOTIFICATION, ///< Notification mode, such as playing utterance is started or completed @SINCE_1_0.0
59 SCREEN_READER, ///< Screen reader mode. To help visually impaired users interact with their devices, screen reader reads text or graphic elements on the screen using the TTS engine. @SINCE_1_0.0
64 * @brief Enumeration for the instance of TTS state.
69 UNAVAILABLE = 0, ///< Player is not available @SINCE_1_0.0
70 READY, ///< Player is ready to play @SINCE_1_0.0
71 PLAYING, ///< Player is playing @SINCE_1_0.0
72 PAUSED ///< Player is paused @SINCE_1_0.0
78 * @brief Type of signal emitted when the TTS state changes.
81 typedef Signal< void ( const Dali::TtsPlayer::State, const Dali::TtsPlayer::State ) > StateChangedSignalType;
86 * @brief Creates an uninitialized handle.
88 * This can be initialized by calling TtsPlayer::Get().
94 * @brief Gets the singleton of the TtsPlayer for the given mode.
97 * @param mode The mode of tts-player
98 * @return A handle of the Ttsplayer for the given mode
100 static TtsPlayer Get(Dali::TtsPlayer::Mode mode = Dali::TtsPlayer::DEFAULT);
105 * This is non-virtual since derived Handle types must not contain data or virtual methods.
111 * @brief This copy constructor is required for (smart) pointer semantics.
114 * @param [in] handle A reference to the copied handle
116 TtsPlayer(const TtsPlayer& handle);
119 * @brief This assignment operator is required for (smart) pointer semantics.
122 * @param [in] rhs A reference to the copied handle
123 * @return A reference to this
125 TtsPlayer& operator=(const TtsPlayer& rhs);
128 * @brief Starts playing the audio data synthesized from the specified text.
131 * @param[in] text The text to play
132 * @pre The TtsPlayer needs to be initialized.
134 void Play(const std::string& text);
137 * @brief Stops playing the utterance.
139 * @pre The TtsPlayer needs to be initialized.
144 * @brief Pauses the currently playing utterance.
146 * @pre The TtsPlayer needs to be initialized.
151 * @brief Resumes the previously paused utterance.
153 * @pre The TtsPlayer needs to be initialized.
158 * @brief Gets the current state of the player.
160 * @return The current TTS state
161 * @pre The TtsPlayer needs to be initialized.
166 * @brief Allows connection TTS state change signal.
168 * @return A reference to the signal for connection
169 * @note Only supported by some adaptor types.
171 Dali::TtsPlayer::StateChangedSignalType& StateChangedSignal();
173 public: // Not intended for application developers
177 * @brief This constructor is used by TtsPlayer::Get().
179 * @param[in] ttsPlayer A pointer to the TTS player
181 explicit DALI_INTERNAL TtsPlayer( Internal::Adaptor::TtsPlayer* ttsPlayer );
190 #endif // DALI_TTS_PLAYER_H