diff --git a/mod_google_transcribe/google_glue_v1.cpp b/mod_google_transcribe/google_glue_v1.cpp index 3216d5e..9b910ed 100644 --- a/mod_google_transcribe/google_glue_v1.cpp +++ b/mod_google_transcribe/google_glue_v1.cpp @@ -339,6 +339,16 @@ static void *SWITCH_THREAD_FUNC grpc_read_thread(switch_thread_t *thread, void * cb->responseHandler(session, "no_audio", cb->bugname); } } + else { + cJSON* json = cJSON_CreateObject(); + cJSON_AddStringToObject(json, "type", "error"); + cJSON_AddItemToObject(json, "error_code", cJSON_CreateNumber(status.error_code())); + cJSON_AddStringToObject(json, "error_message", status.error_message().c_str()); + char* jsonString = cJSON_PrintUnformatted(json); + cb->responseHandler(session, jsonString, cb->bugname); + free(jsonString); + cJSON_Delete(json); + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "grpc_read_thread: finish() status %s (%d)\n", status.error_message().c_str(), status.error_code()) ; switch_core_session_rwunlock(session); } diff --git a/mod_google_transcribe/google_glue_v2.cpp b/mod_google_transcribe/google_glue_v2.cpp index 220af0e..a5f652b 100644 --- a/mod_google_transcribe/google_glue_v2.cpp +++ b/mod_google_transcribe/google_glue_v2.cpp @@ -296,6 +296,16 @@ static void *SWITCH_THREAD_FUNC grpc_read_thread(switch_thread_t *thread, void * cb->responseHandler(session, "no_audio", cb->bugname); } } + else { + cJSON* json = cJSON_CreateObject(); + cJSON_AddStringToObject(json, "type", "error"); + cJSON_AddItemToObject(json, "error_code", cJSON_CreateNumber(status.error_code())); + cJSON_AddStringToObject(json, "error_message", status.error_message().c_str()); + char* jsonString = cJSON_PrintUnformatted(json); + cb->responseHandler(session, jsonString, cb->bugname); + free(jsonString); + cJSON_Delete(json); + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "grpc_read_thread: finish() status %s (%d)\n", status.error_message().c_str(), status.error_code()) ; switch_core_session_rwunlock(session); }