Add critical section to avoid thread safety issue
[platform/core/uifw/stt.git] / include / stt_internal.h
index d0b0e70..bebf85b 100644 (file)
@@ -18,6 +18,7 @@
 #define __STT_INTERNAL_H__
 
 #include <tizen.h>
+#include <stt.h>
 
 /**
  * @file stt_internal.h
@@ -31,6 +32,14 @@ extern "C"
 #define STT_SPEECH_STATUS_BEGINNING_POINT_DETECTED     0
 
 /**
+* @brief Enumerations of audio type.
+*/
+typedef enum {
+       STT_AUDIO_TYPE_RAW_S16 = 0,     /**< Signed 16-bit audio sample */
+       STT_AUDIO_TYPE_RAW_U8,          /**< Unsigned 8-bit audio sample */
+} stt_audio_type_e;
+
+/**
  * @brief Called when user speaking is detected.
  *
  * @param[in] stt The STT handle
@@ -88,6 +97,97 @@ int stt_set_speech_status_cb(stt_h stt, stt_speech_status_cb callback, void* use
 */
 int stt_unset_speech_status_cb(stt_h stt);
 
+/**
+ * @brief Sets server STT.
+ * @details Using this API, the application can set server STT with a @a key as a @a user_data
+ *     The key is a private data to set STT server.
+ *     There are 3 types of keys; "server", "rampcode" and "epd".
+ *             "server": STT server address
+ *             "rampcode": ASR ramp code
+ *             "epd": A threshold for end-point detection
+ *
+ *     The application can input the @a user_data corresponding to the @a key.
+ *             "server": "qa", "sbx"
+ *             "rampcode": "dash_dict", "dash_da"
+ *             "epd": "100", "750", etc
+ *
+ *  If the application sets those keys, it will be able to use corresponding STT engines and options.
+ *
+ * @since_tizen 3.0
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ * @param[in] key The key
+ * @param[in] user_data The user data corresponding to the key
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ * @retval #STT_ERROR_OUT_OF_MEMORY STT Out of memory
+ * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The state should be #STT_STATE_READY.
+ */
+int stt_set_server_stt(stt_h stt, const char* key, char* user_data);
+
+/**
+ * @brief Starts file recognition asynchronously.
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ * @remarks This function starts sending recorded data from file to engine.
+ * @param[in] stt The STT handle
+ * @param[in] language The language selected from stt_foreach_supported_languages()
+ * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
+ * @param[in] filepath PCM filepath for recognition
+ * @param[in] audio_type audio type of file
+ * @param[in] sample_rate sample rate of file
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
+ * @pre The state should be #STT_STATE_READY.
+ * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
+ *       If this function succeeds, the STT state will be #STT_STATE_RECORDING.
+ *       If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_RECORDING.
+ * @see stt_cancel_file()
+ * @see stt_state_changed_cb()
+*/
+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);
+
+/**
+ * @brief Cancels processing file recognition asynchronously.
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ * @remarks This function cancels recording and engine cancels recognition processing.
+ *         After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
+ * @param[in] stt The STT handle
+ * @return @c 0 on success,
+ *        otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished
+ * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
+ * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished
+ * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
+ * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
+ *      If this function succeeds, the STT state will be #STT_STATE_READY.
+ *      If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_READY.
+ * @see stt_start_file()
+ * @see stt_state_changed_cb()
+*/
+int stt_cancel_file(stt_h stt);
+
 #ifdef __cplusplus
 }
 #endif