static stt_engine_result_cb g_result_cb = NULL;
static stte_private_data_set_cb g_set_private_data_cb = NULL;
static stte_private_data_requested_cb g_get_private_data_cb = NULL;
+static stte_audio_type_cb g_set_audio_type_cb = NULL;
+static void* g_set_audio_type_user_data = NULL;
static int __stt_set_engine_from(bool is_from_lib)
return ret;
}
-int stt_engine_get_audio_type(stte_audio_type_e* types, int* rate, int* channels)
+int stt_engine_get_audio_format(stte_audio_type_e* types, int* rate, int* channels)
{
if (NULL == types || NULL == rate || NULL == channels) {
SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter");
return 0;
}
+
+int stt_engine_set_audio_type(const char* audio_type)
+{
+ if (NULL == audio_type) {
+ SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter");
+ return STTE_ERROR_INVALID_PARAMETER;
+ }
+
+ SLOG(LOG_INFO, stt_tag(), "[Engine Info] set audio type (%s)", audio_type);
+
+ int ret = STTE_ERROR_NONE;
+ if (NULL != g_set_audio_type_cb) {
+ ret = g_set_audio_type_cb(audio_type, g_set_audio_type_user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set audio type, ret(%d)", ret);
+ }
+ } else {
+ SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] There's no set audio function)");
+ }
+
+ return ret;
+}
+
+int stt_engine_set_audio_type_set_cb(stte_audio_type_cb audio_type_set_cb, void* user_data)
+{
+ if (NULL == audio_type_set_cb) {
+ SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter");
+ return STTE_ERROR_INVALID_PARAMETER;
+ }
+
+ g_set_audio_type_cb = audio_type_set_cb;
+ g_set_audio_type_user_data = user_data;
+
+ return 0;
+}
\ No newline at end of file
int stt_engine_support_recognition_type(const char* type, bool* support);
-int stt_engine_get_audio_type(stte_audio_type_e* types, int* rate, int* channels);
+int stt_engine_get_audio_format(stte_audio_type_e* types, int* rate, int* channels);
/* Set option */
int stt_engine_set_silence_detection(bool value);
int stt_engine_set_private_data_requested_cb(stte_private_data_requested_cb private_data_requested_cb, void* user_data);
+int stt_engine_set_audio_type(const char* audio_type);
+
+int stt_engine_set_audio_type_set_cb(stte_audio_type_cb audio_type_set_cb, void* user_data);
#ifdef __cplusplus
}
/**
+ * @brief Definition of audio ID that means audio source from bluetooth.
+ * @since_tizen 5.5
+ */
+#define STTE_AUDIO_ID_BLUETOOTH "STT_AUDIO_ID_BLUETOOTH"
+
+
+/**
+ * @brief Definition of audio ID that means audio source from wifi.
+ * @since_tizen 5.5
+ */
+#define STTE_AUDIO_ID_WIFI "STT_AUDIO_ID_WIFI"
+
+
+/**
* @brief Called when STT engine provides the time stamp of result to the engine service user.
* @details This callback function is implemented by the engine service user. Therefore, the engine developer does NOT have to implement this callback function.
* @since_tizen 3.0
/**
+ * @brief Called when the engine service user sets audio recording type.
+ * @since_tizen 5.5
+ * @remarks The @a audio_type can be used only in the callback. To use outside, make a copy.
+ * @param[in] audio_type Current audio type (e.g. #STTE_AUDIO_ID_BLUETOOTH or #STTE_AUDIO_ID_WIFI)
+ * @param[in] user_data user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #VCE_ERROR_NONE Successful.
+ * @retval #STTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STTE_ERROR_OPERATION_FAILED Operation failure
+ */
+typedef int (*stte_audio_type_cb)(const char* audio_type, void* user_data);
+
+
+/**
* @brief A structure for the STT engine functions.
* @details This structure contains essential callback functions for operating STT engine.
* @since_tizen 3.0
int stte_set_private_data_requested_cb(stte_private_data_requested_cb callback_func);
+/**
+* @brief Sets a callback function for setting the audio type.
+* @since_tizen 5.5
+* @remarks The stte_audio_type_cb() function is called when STT framework sets audio type to the STT engine.
+* @param[in] callback_func stte_audio_type_set event callback function
+* @param[in] user_data The user data passed to the callback function
+* @return @c 0 on success,
+* otherwise a negative error value
+* @retval #STTE_ERROR_NONE Successful
+* @retval #STTE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STTE_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTE_ERROR_OPERATION_FAILED Operation failure
+* @pre The stte_main() function should be invoked before this function is called.
+* @see stte_audio_type_cb()
+* @see stte_unset_audio_type_set_cb()
+*/
+int stte_set_audio_type_set_cb(stte_audio_type_cb callback_func, void* user_data);
+
+
+/**
+* @brief Unsets a callback function for setting the audio type.
+* @since_tizen 5.5
+* @return @c 0 on success,
+* otherwise a negative error value
+* @retval #STTE_ERROR_NONE Successful
+* @retval #STTE_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTE_ERROR_OPERATION_FAILED Operation failure
+* @pre The stte_main() function should be invoked before this function is called.
+* @see stte_set_audio_type_set_cb()
+*/
+int stte_unset_audio_type_set_cb(void);
+
+
#ifdef __cplusplus
}
#endif
int rate;
int channels;
- ret = stt_engine_get_audio_type(&atype, &rate, &channels);
+ ret = stt_engine_get_audio_format(&atype, &rate, &channels);
if (0 != ret) {
SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get audio type : %d %s", g_engine_info->engine_name);
return ret;
int rate;
int channels;
- ret = stt_engine_get_audio_type(&atype, &rate, &channels);
+ ret = stt_engine_get_audio_format(&atype, &rate, &channels);
if (0 != ret) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get audio type : %s", g_engine_info->engine_name);
+ SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get audio format : %s", g_engine_info->engine_name);
return ret;
}
ret = sttd_recorder_create(atype, channels, rate);
if (0 != ret) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to create recorder : %s", g_engine_info->engine_name);
+ SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to create format : %s", g_engine_info->engine_name);
return ret;
}
#endif
return 0;
}
+
+int sttd_engine_agent_set_audio_type(const char* audio_type)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ if (NULL == g_engine_info) {
+ SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of is not valid");
+ return STTD_ERROR_INVALID_PARAMETER;
+ }
+
+ if (false == g_engine_info->is_loaded) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_INFO, TAG_STTD, "[Server Info] Set audio type(%s)", audio_type);
+
+ int ret;
+ ret = stt_engine_set_audio_type(audio_type);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set audio type error(%d)", ret);
+ }
+ return ret;
+}
int sttd_engine_agent_send_speech_status(stte_speech_status_e status, void* user_data);
+int sttd_engine_agent_set_audio_type(const char* audio_type);
+
#ifdef __cplusplus
}
#include "sttd_dbus.h"
#include "sttd_recorder.h"
#include "sttd_main.h"
+#include "sttd_engine_agent.h"
+#define STTE_AUDIO_ID_NONE "STT_AUDIO_ID_NONE" /**< None audio id */
+#ifdef TV_FFV_MODE
+#define STTE_AUDIO_ID_FFV "STT_FARFIELD_VOICE_VD"
+#endif
#define FRAME_LENGTH 320
#define BUFFER_LENGTH FRAME_LENGTH * 2
static int g_stream_focus_id;
+static bool g_is_set_audio_type = false;
+
#ifdef TV_FFV_MODE
farfield_voice_h g_farfieldvoice_h = NULL;
#endif
}
if (NULL != g_audio_cb) {
+ if (false == g_is_set_audio_type) {
+ sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_BLUETOOTH);
+ g_is_set_audio_type = true;
+ }
+
if (0 != g_audio_cb((void*)voice_data->audio_buf, (unsigned int)voice_data->length)) {
SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to read audio");
sttd_recorder_stop();
#ifdef TV_FFV_MODE
static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_data)
{
+ if (false == g_is_set_audio_type) {
+ sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_FFV);
+ g_is_set_audio_type = true;
+ }
+
if (0 == g_buffer_count % 50) {
SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] farfield audio function callback is invoked");
SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Enter critical section");
pthread_mutex_lock(&sttd_audio_in_handle_mutex);
+ g_is_set_audio_type = false;
+ sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_NONE);
+
/* Check engine id is valid */
if (NULL == g_recorder) {
SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
int ret = STTE_ERROR_NONE;
ret = stt_engine_set_private_data_set_cb(callback, NULL);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send speech status");
+ SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set private data set callback");
}
return ret;
}
int ret = STTE_ERROR_NONE;
ret = stt_engine_set_private_data_requested_cb(callback, NULL);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send speech status");
+ SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set private data requested callback");
}
return ret;
}
+
+int stte_set_audio_type_set_cb(stte_audio_type_cb callback, void* user_data)
+{
+ SLOG(LOG_INFO, TAG_STTD, "[Server Info] Set audio type set callback");
+
+ int ret = STTE_ERROR_NONE;
+ ret = stt_engine_set_audio_type_set_cb(callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set audio type set");
+ }
+ return ret;
+}
+
+int stte_unset_audio_type_set_cb(void)
+{
+ SLOG(LOG_INFO, TAG_STTD, "[Server Info] Unset audio type set callback");
+
+ int ret = STTE_ERROR_NONE;
+ ret = stt_engine_set_audio_type_set_cb(NULL, NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to unset audio type set");
+ }
+ return ret;
+}
\ No newline at end of file