return STT_ERROR_NONE;
}
+int stt_get_audio_format(stt_h stt, stt_audio_type_e* type, int* rate, int* num_of_channels)
+{
+ stt_client_s* client = NULL;
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
+ return temp;
+
+ RETVM_IF(NULL == type || NULL == rate || NULL == num_of_channels, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(client->current_state == STT_STATE_CREATED, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is CREATED", client->current_state);
+
+ int ret = STT_ERROR_OPERATION_FAILED;
+ int count = 0;
+ while (STT_ERROR_NONE != ret) {
+ ret = stt_dbus_request_get_audio_format(client->uid, type, rate, num_of_channels);
+ if (STT_ERROR_NONE != ret) {
+ //LCOV_EXCL_START
+ if (false == __stt_is_necessary_to_retry_dbus_request(count, ret)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get audio format : %d/%s", ret, get_error_message(ret));
+ return ret;
+ }
+ count++;
+ //LCOV_EXCL_STOP
+ } else {
+ SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Audio format: type(%d), rate(%d), number of channels(%d)",
+ *type, *rate, *num_of_channels);
+ break;
+ }
+ }
+
+ return STT_ERROR_NONE;
+}
+
int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
{
stt_client_s* client = NULL;
if (STT_ERROR_NONE != tmp)
return tmp;
- RETVM_IF(STT_INTERNAL_STATE_NONE != client->internal_state, STT_ERROR_IN_PROGRESS_TO_RECORDING, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+ RETVM_IF(STT_INTERNAL_STATE_NONE != client->internal_state, STT_ERROR_IN_PROGRESS_TO_RECORDING, "[ERROR] Invalid State : Internal state is NOT none : %d", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "===== STT START");
int ret = -1;
client->internal_state = STT_INTERNAL_STATE_NONE;
} else {
SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Start is successful but not done");
+ client->is_streaming = false;
}
free(temp);
return STT_ERROR_IN_PROGRESS_TO_PROCESSING;
}
+ if (client->is_streaming) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Audio streaming is activated.");
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
client->internal_state = STT_INTERNAL_STATE_STOPPING;
int ret = stt_dbus_request_stop(client->uid);
if (0 != ret) {
return ret;
}
+int stt_start_audio_streaming(stt_h stt, const char* language, const char* type)
+{
+ stt_client_s* client = NULL;
+ int tmp = __stt_check_precondition_with_state(stt, &client, STT_STATE_READY);
+ if (STT_ERROR_NONE != tmp)
+ return tmp;
+
+ RETVM_IF(STT_INTERNAL_STATE_NONE != client->internal_state, STT_ERROR_IN_PROGRESS_TO_RECORDING, "[ERROR] Invalid State : Internal state is NOT none : %d", client->current_state);
+ SLOG(LOG_INFO, TAG_STTC, "===== STT START AUDIO STREAMING");
+
+ int ret = STT_ERROR_NONE;
+ char appid[1024] = {0, };
+ ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1);
+
+ if ((AUL_R_OK != ret) || (0 == strlen(appid))) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get application ID"); //LCOV_EXCL_LINE
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] Current app id is %s", appid);
+ }
+
+ const char* language_param = NULL == language ? "default" : language;
+ if (true == client->credential_needed && NULL == client->credential) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Do not have app credential for this engine(%s)", client->current_engine_id); //LCOV_EXCL_LINE
+ return STT_ERROR_PERMISSION_DENIED;
+ }
+
+ client->internal_state = STT_INTERNAL_STATE_STARTING;
+ ret = stt_dbus_request_start_audio_streaming(client->uid, language_param, type, client->silence, appid, client->credential, client->audio_id);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : ret(%d/%s)", ret, get_error_message(ret)); //LCOV_EXCL_LINE
+ client->internal_state = STT_INTERNAL_STATE_NONE;
+ return ret;
+ }
+
+ client->is_streaming = true;
+ SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Start audio streaming is successful but not done");
+ SLOG(LOG_INFO, TAG_STTC, "=====");
+ return STT_ERROR_NONE;
+}
+
+int stt_send_audio_streaming(stt_h stt, const char* data, size_t data_size)
+{
+ stt_client_s* client = NULL;
+ int tmp = __stt_check_precondition_with_state(stt, &client, STT_STATE_RECORDING);
+ if (STT_ERROR_NONE != tmp)
+ return tmp;
+
+ SLOG(LOG_INFO, TAG_STTC, "===== STT SEND AUDIO STREAMING");
+
+ if (STT_INTERNAL_STATE_STARTING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STARTING : %d", client->internal_state); //LCOV_EXCL_LINE
+ return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+ } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is CANCELING : %d", client->internal_state); //LCOV_EXCL_LINE
+ return STT_ERROR_IN_PROGRESS_TO_READY;
+ } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STOPPING : %d", client->internal_state); //LCOV_EXCL_LINE
+ return STT_ERROR_IN_PROGRESS_TO_PROCESSING;
+ }
+
+ if (false == client->is_streaming) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Audio streaming is not activated.");
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ int ret = stt_dbus_request_send_audio_streaming(client->uid, data, data_size);
+ if (STT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : ret(%d/%s)", ret, get_error_message(ret)); //LCOV_EXCL_LINE
+ return ret;
+ }
+
+ SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Send audio streaming is successful");
+ SLOG(LOG_INFO, TAG_STTC, "=====");
+ return STT_ERROR_NONE;
+}
+
+int stt_stop_audio_streaming(stt_h stt)
+{
+ stt_client_s* client = NULL;
+ int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_RECORDING);
+ if (STT_ERROR_NONE != temp)
+ return temp;
+
+ SLOG(LOG_INFO, TAG_STTC, "===== STT STOP AUDIO STREAMING");
+
+ if (STT_INTERNAL_STATE_STARTING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STARTING : %d", client->internal_state); //LCOV_EXCL_LINE
+ return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+ } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is CANCELING : %d", client->internal_state); //LCOV_EXCL_LINE
+ return STT_ERROR_IN_PROGRESS_TO_READY;
+ } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STOPPING : %d", client->internal_state); //LCOV_EXCL_LINE
+ return STT_ERROR_IN_PROGRESS_TO_PROCESSING;
+ }
+
+ if (false == client->is_streaming) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Audio streaming is not activated.");
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ client->internal_state = STT_INTERNAL_STATE_STOPPING;
+ int ret = stt_dbus_request_stop_audio_streaming(client->uid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to stop : ret(%d/%s)", ret, get_error_message(ret)); //LCOV_EXCL_LINE
+ client->internal_state = STT_INTERNAL_STATE_NONE;
+ return ret;
+ }
+
+ SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Stop is successful but not done");
+ SLOG(LOG_DEBUG, TAG_STTC, "=====");
+ return STT_ERROR_NONE;
+}
int stt_cancel(stt_h stt)
{