Skip to content

Commit

Permalink
Merge pull request #7 from seven1240/asr-partial
Browse files Browse the repository at this point in the history
[core] support partial speech events
  • Loading branch information
andywolk committed Oct 12, 2019
2 parents c51c09d + 95b7d84 commit e145fe8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/switch_ivr_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit e145fe8

Please sign in to comment.