mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 22:54:18 +00:00
FS-7720 improve play_and_detect_speech to set current_application_response channel variable as follows:
"USAGE ERROR": bad application arguments
"GRAMMAR ERROR": speech recognizer failed to load grammar
"ASR INIT ERROR": speech recognizer failed to allocate a session
"ERROR": any other errors
This is useful for determining that play_and_detect_speech failed because the recognizer is out of licenses
giving the developer a chance to fall back to traditional DTMF menu navigation.
This commit is contained in:
1 parent
e401b1469f
commit
06f7040e21
2 files changed
+29
-13
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -514,9 +514,17 @@ SWITCH_STANDARD_APP(play_and_detect_speech_function)
|
||||
char *engine = argv[0];
|
||||
char *grammar = argv[1];
|
||||
char *result = NULL;
|
||||
switch_ivr_play_and_detect_speech(session, file, engine, grammar, &result, 0, NULL);
|
||||
if (!zstr(result)) {
|
||||
switch_channel_set_variable(channel, "detect_speech_result", result);
|
||||
switch_status_t status = switch_ivr_play_and_detect_speech(session, file, engine, grammar, &result, 0, NULL);
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
if (!zstr(result)) {
|
||||
switch_channel_set_variable(channel, "detect_speech_result", result);
|
||||
}
|
||||
} else if (status == SWITCH_STATUS_GENERR) {
|
||||
response = "GRAMMAR ERROR";
|
||||
} else if (status == SWITCH_STATUS_NOT_INITALIZED) {
|
||||
response = "ASR INIT ERROR";
|
||||
} else {
|
||||
response = "ERROR";
|
||||
}
|
||||
} else {
|
||||
/* bad input */
|
||||
|
||||
Reference in new issue
Block a user