From: Seven Du Date: Fri, 11 Oct 2019 07:32:09 +0000 (+0800) Subject: [core] support partial speech events X-Git-Tag: v1.10.2^2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=00967290b9f3a9e4618630fb7d1a86fcead9da17;p=thirdparty%2Ffreeswitch.git [core] support partial speech events --- diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index bb629e9af2..ee23ccd79c 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -4673,9 +4673,9 @@ static void *SWITCH_THREAD_FUNC speech_thread(switch_thread_t *thread, void *obj status = switch_core_asr_get_results(sth->ah, &xmlstr, &flags); - if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { + if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK && status != SWITCH_STATUS_MORE_DATA) { goto done; - } else if (status == SWITCH_STATUS_SUCCESS) { + } else { /* Try to fetch extra information for this result, the return value doesn't really matter here - it's just optional data. */ switch_core_asr_get_result_headers(sth->ah, &headers, &flags); } @@ -4732,6 +4732,14 @@ static void *SWITCH_THREAD_FUNC speech_thread(switch_thread_t *thread, void *obj switch_event_merge(event, headers); } + switch_event_add_body(event, "%s", xmlstr); + } else if (status == SWITCH_STATUS_MORE_DATA) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Speech-Type", "detected-partial-speech"); + + if (headers) { + switch_event_merge(event, headers); + } + switch_event_add_body(event, "%s", xmlstr); } else { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Speech-Type", "begin-speaking");