2 * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __STT_INTERNAL_H__
18 #define __STT_INTERNAL_H__
24 * @file stt_internal.h
32 #define STT_SPEECH_STATUS_BEGINNING_POINT_DETECTED 0
35 * @brief Enumerations of audio type.
38 STT_AUDIO_TYPE_RAW_S16 = 0, /**< Signed 16-bit audio sample */
39 STT_AUDIO_TYPE_RAW_U8, /**< Unsigned 8-bit audio sample */
43 * @brief Called when user speaking is detected.
45 * @param[in] stt The STT handle
46 * @param[in] status The speech status
47 * @param[in] user_data The user data passed from the callback registration function
49 * @pre An application registers callback function using stt_set_speech_status_cb().
51 * @see stt_set_speech_status_cb()
52 * @see stt_unset_speech_status_cb()
54 typedef void (*stt_speech_status_cb)(stt_h stt, int status, void *user_data);
58 * @brief Registers a callback function to detect the speech status is changed.
60 * @privilege %http://tizen.org/privilege/recorder
62 * @param[in] stt The STT handle
63 * @param[in] callback The callback function to register
64 * @param[in] user_data The user data to be passed to the callback function
66 * @return 0 on success, otherwise a negative error value
67 * @retval #STT_ERROR_NONE Successful
68 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
69 * @retval #STT_ERROR_INVALID_STATE Invalid state
70 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
71 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
73 * @pre The state should be #STT_STATE_CREATED.
75 * @see stt_speech_status_cb()
76 * @see stt_unset_speech_status_cb()
78 int stt_set_speech_status_cb(stt_h stt, stt_speech_status_cb callback, void* user_data);
81 * @brief Unregisters the callback function.
83 * @privilege %http://tizen.org/privilege/recorder
85 * @param[in] stt The STT handle
87 * @return 0 on success, otherwise a negative error value
88 * @retval #STT_ERROR_NONE Successful
89 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
90 * @retval #STT_ERROR_INVALID_STATE Invalid state
91 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
92 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
94 * @pre The state should be #STT_STATE_CREATED.
96 * @see stt_set_speech_status_cb()
98 int stt_unset_speech_status_cb(stt_h stt);
101 * @brief Sets server STT.
102 * @details Using this API, the application can set server STT with a @a key as a @a user_data
103 * The key is a private data to set STT server.
104 * There are 3 types of keys; "server", "rampcode" and "epd".
105 * "server": STT server address
106 * "rampcode": ASR ramp code
107 * "epd": A threshold for end-point detection
109 * The application can input the @a user_data corresponding to the @a key.
110 * "server": "qa", "sbx"
111 * "rampcode": "dash_dict", "dash_da"
112 * "epd": "100", "750", etc
114 * If the application sets those keys, it will be able to use corresponding STT engines and options.
117 * @privilege %http://tizen.org/privilege/recorder
119 * @param[in] stt The STT handle
120 * @param[in] key The key
121 * @param[in] user_data The user data corresponding to the key
123 * @return 0 on success, otherwise a negative error value
124 * @retval #STT_ERROR_NONE Successful
125 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
126 * @retval #STT_ERROR_INVALID_STATE Invalid state
127 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
128 * @retval #STT_ERROR_OUT_OF_MEMORY STT Out of memory
129 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
131 * @pre The state should be #STT_STATE_READY.
133 int stt_set_server_stt(stt_h stt, const char* key, char* user_data);
136 * @brief Starts file recognition asynchronously.
138 * @privilege %http://tizen.org/privilege/recorder
139 * @remarks This function starts sending recorded data from file to engine.
140 * @param[in] stt The STT handle
141 * @param[in] language The language selected from stt_foreach_supported_languages()
142 * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
143 * @param[in] filepath PCM filepath for recognition
144 * @param[in] audio_type audio type of file
145 * @param[in] sample_rate sample rate of file
146 * @return @c 0 on success,
147 * otherwise a negative error value
148 * @retval #STT_ERROR_NONE Successful
149 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
150 * @retval #STT_ERROR_INVALID_STATE Invalid state
151 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
152 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
153 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
154 * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
155 * @pre The state should be #STT_STATE_READY.
156 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
157 * If this function succeeds, the STT state will be #STT_STATE_RECORDING.
158 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_RECORDING.
159 * @see stt_cancel_file()
160 * @see stt_state_changed_cb()
162 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);
165 * @brief Cancels processing file recognition asynchronously.
167 * @privilege %http://tizen.org/privilege/recorder
168 * @remarks This function cancels recording and engine cancels recognition processing.
169 * After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
170 * @param[in] stt The STT handle
171 * @return @c 0 on success,
172 * otherwise a negative error value
173 * @retval #STT_ERROR_NONE Successful
174 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
175 * @retval #STT_ERROR_INVALID_STATE Invalid state
176 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
177 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
178 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
179 * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished
180 * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
181 * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished
182 * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
183 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
184 * If this function succeeds, the STT state will be #STT_STATE_READY.
185 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_READY.
186 * @see stt_start_file()
187 * @see stt_state_changed_cb()
189 int stt_cancel_file(stt_h stt);
199 #endif /* __STT_INTERNAL_H__ */