#include <fcntl.h>
#include <unistd.h>
#include <Elementary.h>
+#include <dlog.h>
#include "assert.h"
static stt_state_e g_current_state;
static stt_state_e g_temp_current_state;
static bool g_stt_supported = false;
-
+static stt_error_e g_error;
static void __stt_state_changed_cb(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data);
+static void __stt_error_cb(stt_h stt, stt_error_e reason, void *user_data);
void utc_stt_startup(void)
{
system_info_get_platform_bool("http://tizen.org/feature/speech.recognition", &g_stt_supported);
elm_init(0,NULL);
g_current_state = 0;
+ g_error = TIZEN_ERROR_NONE;
if (g_stt_supported) {
g_stt = NULL;
ret = stt_create(&g_stt);
stt_set_state_changed_cb(g_stt, __stt_state_changed_cb, NULL);
+ stt_set_error_cb(g_stt, __stt_error_cb, NULL);
}
}
/* end of TC */
if (true == g_stt_supported) {
stt_unset_state_changed_cb(g_stt);
+ stt_unset_error_cb(g_stt);
stt_destroy(g_stt);
}
g_stt = NULL;
static void __stt_error_cb(stt_h stt, stt_error_e reason, void *user_data)
{
+ g_error = reason;
+ dlog_print(DLOG_ERROR, "NativeTCT", "ERROR(%d)", g_error);
+
+ return;
}
static void __stt_recognition_result_cb(stt_h stt, stt_result_event_e event, const char** data, int data_count, const char* msg, void *user_data)
assert_eq(ret, STT_ERROR_NOT_SUPPORTED);
} else {
assert_neq(g_stt, NULL);
+
ret = stt_prepare(g_stt);
assert_eq(ret, STT_ERROR_NONE);
g_language = NULL;
}
- while (STT_STATE_RECORDING != g_current_state){
- ecore_main_loop_iterate();
- }
+ while (STT_STATE_RECORDING != g_current_state && STT_ERROR_OUT_OF_NETWORK != g_error){
+ ecore_main_loop_iterate();
+ }
+
+ dlog_print(DLOG_INFO, "NativeTCT", "State(%d)", g_current_state);
int count = 0;
- while (STT_STATE_PROCESSING != g_current_state){
+ while (STT_STATE_PROCESSING != g_current_state && STT_ERROR_OUT_OF_NETWORK != g_error){
ecore_main_loop_iterate();
usleep(100000);
count++;
assert_eq(ret, STT_ERROR_NOT_SUPPORTED);
} else {
assert_neq(g_stt, NULL);
+
ret = stt_prepare(g_stt);
assert_eq(ret, STT_ERROR_NONE);
ret = stt_start(g_stt, NULL, STT_RECOGNITION_TYPE_FREE);
assert_eq(ret, STT_ERROR_NONE);
- while (STT_STATE_RECORDING != g_current_state){
+ int count = 0;
+ while (STT_STATE_RECORDING != g_current_state && STT_ERROR_OUT_OF_NETWORK != g_error){
ecore_main_loop_iterate();
}
- int count = 0;
- while (STT_STATE_PROCESSING != g_current_state){
+ count = 0;
+ while (STT_STATE_PROCESSING != g_current_state && STT_ERROR_OUT_OF_NETWORK != g_error){
ecore_main_loop_iterate();
usleep(100000);
count++;
ret = stt_start(g_stt, NULL, STT_RECOGNITION_TYPE_FREE);
assert_eq(ret, STT_ERROR_NONE);
- while (STT_STATE_RECORDING != g_current_state){
+ while (STT_STATE_RECORDING != g_current_state && STT_ERROR_OUT_OF_NETWORK != g_error){
ecore_main_loop_iterate();
}
int i = 0;
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 10 && STT_ERROR_OUT_OF_NETWORK != g_error; i++) {
ecore_main_loop_iterate();
}
assert_eq(ret, STT_ERROR_NOT_SUPPORTED);
} else {
assert_neq(g_stt, NULL);
+
ret = stt_prepare(g_stt);
assert_eq(ret, STT_ERROR_NONE);
ret = stt_start(g_stt, NULL, STT_RECOGNITION_TYPE_FREE);
assert_eq(ret, STT_ERROR_NONE);
- while (STT_STATE_RECORDING != g_current_state){
+ while (STT_STATE_RECORDING != g_current_state && STT_ERROR_OUT_OF_NETWORK != g_error){
ecore_main_loop_iterate();
}
int i = 0;
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 10 && STT_ERROR_OUT_OF_NETWORK != g_error; i++) {
ecore_main_loop_iterate();
}
- ret = stt_get_recording_volume(g_stt, &vol);
- assert_eq(ret, STT_ERROR_NONE);
+ if (STT_ERROR_OUT_OF_NETWORK != g_error) {
+ ret = stt_get_recording_volume(g_stt, &vol);
+ assert_eq(ret, STT_ERROR_NONE);
- ecore_main_loop_iterate();
+ ecore_main_loop_iterate();
- ret = stt_cancel(g_stt);
- assert_eq(ret, STT_ERROR_NONE);
+ ret = stt_cancel(g_stt);
+ assert_eq(ret, STT_ERROR_NONE);
+ }
while (STT_STATE_READY != g_current_state){
ecore_main_loop_iterate();