FS-11453 [mod_rayo] allow text/plain grammar for non-mrcp speech recognizers. Added direction to output component to assist with testing. Fix confidence conversion to NLSML.

This commit is contained in:
Chris Rienzo 2018-10-12 00:45:03 +00:00
parent 6eb2276cd6
commit e0b5df10d6
3 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,6 @@
/*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013, Grasshopper
* Copyright (C) 2013-2018, Grasshopper
*
* Version: MPL 1.1
*
@ -42,7 +42,6 @@ ELEMENT(RAYO_INPUT)
ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one)
ATTRIB(min-confidence, 0, decimal_between_zero_and_one)
ATTRIB(max-silence, -1, positive_or_neg_one)
/* for now, only NLSML */
STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml")
/* internal attribs for prompt support */
ATTRIB(barge-event, false, bool)
@ -72,6 +71,7 @@ ELEMENT(RAYO_OUTPUT)
ATTRIB(max-time, -1, positive_or_neg_one)
ATTRIB(renderer,, any)
ATTRIB(voice,, any)
STRING_ATTRIB(direction, out, "out,in")
ELEMENT_END
/**

View File

@ -415,7 +415,7 @@ static int validate_call_input(iks *input, const char **error)
if (!zstr(iks_find_attrib(grammar, "url"))) {
*error = "url not allowed with content-type";
return 0;
} else if (strcmp("application/srgs+xml", content_type)) {
} else if (strcmp("application/srgs+xml", content_type) && strcmp("text/plain", content_type)) {
*error = "Unsupported content type";
return 0;
}
@ -891,7 +891,7 @@ static const char *get_detected_speech_result_text(cJSON *result_json, double *c
if (json_confidence && json_confidence->valuedouble > 0.0) {
*confidence = json_confidence->valuedouble;
} else {
*confidence = 100.0;
*confidence = 0.99;
}
result_text = text;
} else if (error_text) {
@ -940,7 +940,7 @@ static void on_detected_speech_event(switch_event_t *event)
result_text = get_detected_speech_result_text(json_result, &confidence, &error_text);
if (!zstr(result_text)) {
// got result... send as NLSML
iks *result = nlsml_create_match(result_text, NULL, "speech", (int)confidence);
iks *result = nlsml_create_match(result_text, NULL, "speech", (int)(confidence * 100.0));
/* notify of match */
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "MATCH = %s\n", result_text);
send_match_event(RAYO_COMPONENT(component), result);

View File

@ -1,6 +1,6 @@
/*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2016, Grasshopper
* Copyright (C) 2013-2018, Grasshopper
*
* Version: MPL 1.1
*
@ -53,6 +53,8 @@ struct output_component {
const char *renderer;
/** optional headers to pass to renderer */
const char *headers;
/** audio direction */
const char *direction;
};
#define OUTPUT_FINISH "finish", RAYO_OUTPUT_COMPLETE_NS
@ -79,6 +81,7 @@ static struct rayo_component *create_output_component(struct rayo_actor *actor,
output_component->max_time_ms = iks_find_int_attrib(output, "max-time");
output_component->start_paused = iks_find_bool_attrib(output, "start-paused");
output_component->renderer = switch_core_strdup(RAYO_POOL(output_component), iks_find_attrib_soft(output, "renderer"));
output_component->direction = strcmp(iks_find_attrib_soft(output, "direction"), "in") ? "m" : "mr";
output_component->headers = NULL;
/* get custom headers */
{
@ -136,7 +139,7 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess
}
stream.write_function(&stream, "}fileman://rayo://%s", RAYO_JID(component));
if (switch_ivr_displace_session(session, stream.data, 0, "m") == SWITCH_STATUS_SUCCESS) {
if (switch_ivr_displace_session(session, stream.data, 0, OUTPUT_COMPONENT(component)->direction) == SWITCH_STATUS_SUCCESS) {
RAYO_RELEASE(component);
} else {
if (component->complete) {