2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
15 #ifndef __TTS_SETTING_H__
16 #define __TTS_SETTING_H__
22 * @addtogroup TTS_SETTING_MODULE
31 * @brief Enumerations of error codes.
34 TTS_SETTING_ERROR_NONE = 0, /**< Success, No error */
35 TTS_SETTING_ERROR_OUT_OF_MEMORY = -ENOMEM, /**< Out of Memory */
36 TTS_SETTING_ERROR_IO_ERROR = -EIO, /**< I/O error */
37 TTS_SETTING_ERROR_INVALID_PARAMETER = -EINVAL, /**< Invalid parameter */
38 TTS_SETTING_ERROR_INVALID_STATE = -0x0100021, /**< Invalid state */
39 TTS_SETTING_ERROR_INVALID_VOICE = -0x0100022, /**< Invalid voice */
40 TTS_SETTING_ERROR_ENGINE_NOT_FOUND = -0x0100023, /**< No available TTS-engine */
41 TTS_SETTING_ERROR_TIMED_OUT = -0x0100024, /**< No answer from TTS daemon */
42 TTS_SETTING_ERROR_OPERATION_FAILED = -0x0100025, /**< TTS daemon failed */
43 } tts_setting_error_e;
46 * @brief Enumerations of speaking speed.
49 TTS_SETTING_SPEED_AUTO = 0, /**< Speed from settings */
50 TTS_SETTING_SPEED_VERY_SLOW, /**< Very slow */
51 TTS_SETTING_SPEED_SLOW, /**< Slow */
52 TTS_SETTING_SPEED_NORMAL, /**< Normal */
53 TTS_SETTING_SPEED_FAST, /**< Fast */
54 TTS_SETTING_SPEED_VERY_FAST /**< Very fast */
55 } tts_setting_speed_e;
58 * @brief Enumerations of voice type.
61 TTS_SETTING_VOICE_TYPE_AUTO = 0, /**< Voice type from settings or auto selection based language*/
62 TTS_SETTING_VOICE_TYPE_MALE, /**< Male */
63 TTS_SETTING_VOICE_TYPE_FEMALE, /**< Female */
64 TTS_SETTING_VOICE_TYPE_CHILD, /**< Child */
65 TTS_SETTING_VOICE_TYPE_USER1, /**< Engine defined */
66 TTS_SETTING_VOICE_TYPE_USER2, /**< Engine defined */
67 TTS_SETTING_VOICE_TYPE_USER3 /**< Engine defined */
68 } tts_setting_voice_type_e;
71 * @brief Enumerations of setting state.
74 TTS_SETTING_STATE_NONE = 0,
75 TTS_SETTING_STATE_READY
76 } tts_setting_state_e;
79 * @brief Called to get a engine information.
81 * @param[in] engine_id Engine id.
82 * @param[in] engine_name engine name.
83 * @param[in] setting_path gadget path of engine specific setting.
84 * @param[in] user_data User data passed from the tts_setting_foreach_supported_engines().
86 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
87 * @pre tts_setting_foreach_supported_engines() will invoke this callback.
89 * @see tts_setting_foreach_supported_engines()
91 typedef bool(*tts_setting_supported_engine_cb)(const char* engine_id, const char* engine_name, const char* setting_path, void* user_data);
94 * @brief Called to get a voice.
96 * @param[in] engine_id Engine id.
97 * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code
98 * followed by ISO 639-1 for the two-letter language code.
99 * For example, "ko_KR" for Korean, "en_US" for American English..
100 * @param[in] voice_type Voice type.
101 * @param[in] user_data User data passed from the tts_setting_foreach_surpported_voices().
103 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
104 * @pre tts_setting_foreach_surpported_voices() will invoke this callback.
106 * @see tts_setting_foreach_surpported_voices()
108 typedef bool(*tts_setting_supported_voice_cb)(const char* engine_id, const char* language, tts_setting_voice_type_e voice_type, void* user_data);
111 * @brief Called to get a engine setting.
113 * @param[in] engine_id Engine id.
114 * @param[in] key Key.
115 * @param[in] value Value.
116 * @param[in] user_data User data passed from the tts_setting_foreach_engine_settings().
118 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
119 * @pre tts_setting_foreach_engine_settings() will invoke this callback.
121 * @see tts_setting_foreach_engine_settings()
123 typedef bool(*tts_setting_engine_setting_cb)(const char* engine_id, const char* key, const char* value, void* user_data);
126 * @brief Called to initialize setting.
128 * @param[in] state Current state.
129 * @param[in] reason Error reason.
130 * @param[in] user_data User data passed from the tts_setting_initialize_async().
132 * @pre tts_setting_initialize_async() will invoke this callback.
134 * @see tts_setting_initialize_async()
136 typedef void(*tts_setting_initialized_cb)(tts_setting_state_e state, tts_setting_error_e reason, void* user_data);
139 * @brief Initialize TTS setting and connect to tts-daemon asynchronously.
141 * @return 0 on success, otherwise a negative error value.
142 * @retval #TTS_SETTING_ERROR_NONE Success.
143 * @retval #TTS_SETTING_ERROR_TIMED_OUT tts daemon is blocked or tts daemon do not exist.
144 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS setting has Already been initialized.
145 * @retval #TTS_SETTING_ERROR_ENGINE_NOT_FOUND No available tts-engine. Engine should be installed.
147 * @see tts_setting_finalize()
149 int tts_setting_initialize();
151 int tts_setting_initialize_async(tts_setting_initialized_cb callback, void* user_data);
154 * @brief finalize tts setting and disconnect to tts-daemon.
156 * @return 0 on success, otherwise a negative error value.
157 * @retval #TTS_SETTING_ERROR_NONE Success.
158 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
159 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
161 * @see tts_setting_initialize()
163 int tts_setting_finalize(void);
166 * @brief Retrieve supported engine informations using callback function.
168 * @param[in] callback callback function
169 * @param[in] user_data User data to be passed to the callback function.
171 * @return 0 on success, otherwise a negative error value.
172 * @retval #TTS_SETTING_ERROR_NONE Success.
173 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
174 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
175 * @post This function invokes tts_setting_supported_engine_cb() repeatedly for getting engine information.
177 * @see tts_setting_supported_engine_cb()
179 int tts_setting_foreach_supported_engines(tts_setting_supported_engine_cb callback, void* user_data);
182 * @brief Get current engine id.
184 * @remark If the function is success, @a engine_id must be released with free() by you.
186 * @param[out] engine_id engine id.
188 * @return 0 on success, otherwise a negative error value.
189 * @retval #TTS_SETTING_ERROR_NONE Success.
190 * @retval #TTS_SETTING_ERROR_OUT_OF_MEMORY Out of memory.
191 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
192 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
193 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
195 * @see tts_setting_set_engine()
197 int tts_setting_get_engine(char** engine_id);
200 * @brief Set current engine id.
202 * @param[in] engine_id engine id.
204 * @return 0 on success, otherwise a negative error value.
205 * @retval #TTS_SETTING_ERROR_NONE Success.
206 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
207 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
208 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
210 * @see tts_setting_get_engine()
212 int tts_setting_set_engine(const char* engine_id);
215 * @brief Get supported voices of current engine.
217 * @param[in] callback callback function.
218 * @param[in] user_data User data to be passed to the callback function.
220 * @return 0 on success, otherwise a negative error value.
221 * @retval #TTS_SETTING_ERROR_NONE Success.
222 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
223 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
224 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
226 * @post This function invokes tts_setting_supported_voice_cb() repeatedly for getting supported voices.
228 * @see tts_setting_supported_voice_cb()
230 int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callback, void* user_data);
233 * @brief Get a default voice of current engine.
235 * @remark If the function is success, @a language must be released with free() by you.
237 * @param[out] language current language
238 * @param[out] voice_type current voice type
240 * @return 0 on success, otherwise a negative error value.
241 * @retval #TTS_SETTING_ERROR_NONE Success.
242 * @retval #TTS_SETTING_ERROR_OUT_OF_MEMORY Out of memory.
243 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
244 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
245 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
247 * @see tts_setting_set_default_voice()
249 int tts_setting_get_default_voice(char** language, tts_setting_voice_type_e* voice_type);
252 * @brief Set a default voice of current engine.
254 * @param[in] language language
255 * @param[in] voice_type voice type.
257 * @return 0 on success, otherwise a negative error value.
258 * @retval #TTS_SETTING_ERROR_NONE Success.
259 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
260 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
261 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
263 * @see tts_setting_get_default_voice()
265 int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e voice_type);
268 * @brief Get default speed.
270 * @param[out] speed voice speed.
272 * @return 0 on success, otherwise a negative error value.
273 * @retval #TTS_SETTING_ERROR_NONE Success.
274 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
275 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
276 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
278 * @see tts_setting_set_default_speed()
280 int tts_setting_get_default_speed(tts_setting_speed_e* speed);
283 * @brief Set a default speed.
285 * @param[in] speed voice speed
287 * @return 0 on success, otherwise a negative error value.
288 * @retval #TTS_SETTING_ERROR_NONE Success.
289 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
290 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
291 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
293 * @see tts_setting_get_default_speed()
295 int tts_setting_set_default_speed(tts_setting_speed_e speed);
298 * @brief Get setting information of current engine.
300 * @param[in] callback callback function
301 * @param[in] user_data User data to be passed to the callback function.
303 * @return 0 on success, otherwise a negative error value.
304 * @retval #TTS_SETTING_ERROR_NONE Success.
305 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
306 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
307 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
309 * @post This function invokes tts_setting_engine_setting_cb() repeatedly for getting engine settings.
311 * @see tts_setting_engine_setting_cb()
313 int tts_setting_foreach_engine_settings(tts_setting_engine_setting_cb callback, void* user_data);
316 * @brief Set setting information.
318 * @param[in] key Key.
319 * @param[in] value Value.
321 * @return 0 on success, otherwise a negative error value.
322 * @retval #TTS_SETTING_ERROR_NONE Success.
323 * @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
324 * @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized.
325 * @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
327 * @see tts_setting_foreach_engine_settings()
329 int tts_setting_set_engine_setting(const char* key, const char* value);
339 #endif /* __TTS_SETTING_H__ */