提交 e0b5df10 authored 作者: Chris Rienzo's avatar Chris Rienzo

FS-11453 [mod_rayo] allow text/plain grammar for non-mrcp speech recognizers. …

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.
上级 6eb2276c
/* /*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * 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 * Version: MPL 1.1
* *
...@@ -42,7 +42,6 @@ ELEMENT(RAYO_INPUT) ...@@ -42,7 +42,6 @@ ELEMENT(RAYO_INPUT)
ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one) ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one)
ATTRIB(min-confidence, 0, decimal_between_zero_and_one) ATTRIB(min-confidence, 0, decimal_between_zero_and_one)
ATTRIB(max-silence, -1, positive_or_neg_one) ATTRIB(max-silence, -1, positive_or_neg_one)
/* for now, only NLSML */
STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml") STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml")
/* internal attribs for prompt support */ /* internal attribs for prompt support */
ATTRIB(barge-event, false, bool) ATTRIB(barge-event, false, bool)
...@@ -72,6 +71,7 @@ ELEMENT(RAYO_OUTPUT) ...@@ -72,6 +71,7 @@ ELEMENT(RAYO_OUTPUT)
ATTRIB(max-time, -1, positive_or_neg_one) ATTRIB(max-time, -1, positive_or_neg_one)
ATTRIB(renderer,, any) ATTRIB(renderer,, any)
ATTRIB(voice,, any) ATTRIB(voice,, any)
STRING_ATTRIB(direction, out, "out,in")
ELEMENT_END ELEMENT_END
/** /**
......
...@@ -415,7 +415,7 @@ static int validate_call_input(iks *input, const char **error) ...@@ -415,7 +415,7 @@ static int validate_call_input(iks *input, const char **error)
if (!zstr(iks_find_attrib(grammar, "url"))) { if (!zstr(iks_find_attrib(grammar, "url"))) {
*error = "url not allowed with content-type"; *error = "url not allowed with content-type";
return 0; 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"; *error = "Unsupported content type";
return 0; return 0;
} }
...@@ -891,7 +891,7 @@ static const char *get_detected_speech_result_text(cJSON *result_json, double *c ...@@ -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) { if (json_confidence && json_confidence->valuedouble > 0.0) {
*confidence = json_confidence->valuedouble; *confidence = json_confidence->valuedouble;
} else { } else {
*confidence = 100.0; *confidence = 0.99;
} }
result_text = text; result_text = text;
} else if (error_text) { } else if (error_text) {
...@@ -940,7 +940,7 @@ static void on_detected_speech_event(switch_event_t *event) ...@@ -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); result_text = get_detected_speech_result_text(json_result, &confidence, &error_text);
if (!zstr(result_text)) { if (!zstr(result_text)) {
// got result... send as NLSML // 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 */ /* notify of match */
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "MATCH = %s\n", result_text); switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "MATCH = %s\n", result_text);
send_match_event(RAYO_COMPONENT(component), result); send_match_event(RAYO_COMPONENT(component), result);
......
/* /*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * 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 * Version: MPL 1.1
* *
...@@ -53,6 +53,8 @@ struct output_component { ...@@ -53,6 +53,8 @@ struct output_component {
const char *renderer; const char *renderer;
/** optional headers to pass to renderer */ /** optional headers to pass to renderer */
const char *headers; const char *headers;
/** audio direction */
const char *direction;
}; };
#define OUTPUT_FINISH "finish", RAYO_OUTPUT_COMPLETE_NS #define OUTPUT_FINISH "finish", RAYO_OUTPUT_COMPLETE_NS
...@@ -79,6 +81,7 @@ static struct rayo_component *create_output_component(struct rayo_actor *actor, ...@@ -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->max_time_ms = iks_find_int_attrib(output, "max-time");
output_component->start_paused = iks_find_bool_attrib(output, "start-paused"); 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->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; output_component->headers = NULL;
/* get custom headers */ /* get custom headers */
{ {
...@@ -136,7 +139,7 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess ...@@ -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)); 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); RAYO_RELEASE(component);
} else { } else {
if (component->complete) { if (component->complete) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论