[ACR-1449] Add to set speech status callback
[platform/core/uifw/stt.git] / include / stt_internal.h
1 /*
2  * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __STT_INTERNAL_H__
18 #define __STT_INTERNAL_H__
19
20 #include <tizen.h>
21 #include <stt.h>
22
23 /**
24  * @file stt_internal.h
25  */
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32
33 /**
34 * @brief Enumerations of audio type.
35 */
36 typedef enum {
37         STT_AUDIO_TYPE_RAW_S16 = 0,     /**< Signed 16-bit audio sample */
38         STT_AUDIO_TYPE_RAW_U8,          /**< Unsigned 8-bit audio sample */
39 } stt_audio_type_e;
40
41 /**
42  * @brief Sets server STT.
43  * @details Using this API, the application can set server STT with a @a key as a @a user_data
44  *      The key is a private data to set STT server.
45  *      There are 3 types of keys; "server", "rampcode" and "epd".
46  *              "server": STT server address
47  *              "rampcode": ASR ramp code
48  *              "epd": A threshold for end-point detection
49  *
50  *      The application can input the @a user_data corresponding to the @a key.
51  *              "server": "qa", "sbx"
52  *              "rampcode": "dash_dict", "dash_da"
53  *              "epd": "100", "750", etc
54  *
55  *  If the application sets those keys, it will be able to use corresponding STT engines and options.
56  *
57  * @since_tizen 3.0
58  * @privilege %http://tizen.org/privilege/recorder
59  *
60  * @param[in] stt The STT handle
61  * @param[in] key The key
62  * @param[in] user_data The user data corresponding to the key
63  *
64  * @return 0 on success, otherwise a negative error value
65  * @retval #STT_ERROR_NONE Successful
66  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
67  * @retval #STT_ERROR_INVALID_STATE Invalid state
68  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
69  * @retval #STT_ERROR_OUT_OF_MEMORY STT Out of memory
70  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
71  *
72  * @pre The state should be #STT_STATE_READY.
73  */
74 int stt_set_server_stt(stt_h stt, const char* key, char* user_data);
75
76 /**
77  * @brief Starts file recognition asynchronously.
78  * @privlevel public
79  * @privilege %http://tizen.org/privilege/recorder
80  * @remarks This function starts sending recorded data from file to engine.
81  * @param[in] stt The STT handle
82  * @param[in] language The language selected from stt_foreach_supported_languages()
83  * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
84  * @param[in] filepath PCM filepath for recognition
85  * @param[in] audio_type audio type of file
86  * @param[in] sample_rate sample rate of file
87  * @return @c 0 on success,
88  *         otherwise a negative error value
89  * @retval #STT_ERROR_NONE Successful
90  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
91  * @retval #STT_ERROR_INVALID_STATE Invalid state
92  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
93  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
94  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
95  * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
96  * @pre The state should be #STT_STATE_READY.
97  * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
98  *       If this function succeeds, the STT state will be #STT_STATE_RECORDING.
99  *       If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_RECORDING.
100  * @see stt_cancel_file()
101  * @see stt_state_changed_cb()
102 */
103 int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath, stt_audio_type_e audio_type, int sample_rate);
104
105 /**
106  * @brief Cancels processing file recognition asynchronously.
107  * @privlevel public
108  * @privilege %http://tizen.org/privilege/recorder
109  * @remarks This function cancels recording and engine cancels recognition processing.
110  *          After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
111  * @param[in] stt The STT handle
112  * @return @c 0 on success,
113  *         otherwise a negative error value
114  * @retval #STT_ERROR_NONE Successful
115  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
116  * @retval #STT_ERROR_INVALID_STATE Invalid state
117  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
118  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
119  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
120  * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished
121  * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
122  * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished
123  * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
124  * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
125  *       If this function succeeds, the STT state will be #STT_STATE_READY.
126  *       If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_READY.
127  * @see stt_start_file()
128  * @see stt_state_changed_cb()
129 */
130 int stt_cancel_file(stt_h stt);
131
132 #ifdef __cplusplus
133 }
134 #endif
135
136 /**
137  * @}
138  */
139
140 #endif /* __STT_INTERNAL_H__ */
141