]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11453 [mod_rayo] allow text/plain grammar for non-mrcp speech recognizers. Added...
authorChris Rienzo <chris@signalwire.com>
Fri, 12 Oct 2018 00:45:03 +0000 (00:45 +0000)
committerChris Rienzo <chris@signalwire.com>
Thu, 20 Dec 2018 15:18:06 +0000 (10:18 -0500)
src/mod/event_handlers/mod_rayo/rayo_elements.c
src/mod/event_handlers/mod_rayo/rayo_input_component.c
src/mod/event_handlers/mod_rayo/rayo_output_component.c

index d0892dca80b568a9bc9c9217617e728155b6e68c..14e9c61c5568239f5a3433e7bc18b852f10f72ab 100644 (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
 
 /**
index 13311d544428fa7cdfb3b0a23b986deac193b41e..84a8e745cc9d5bb370e1a2bc2baa6d93c90ce838 100644 (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);
index f94921fd91a17be774ae76d645257afa8e13b2ad..6ea607e33b1ec66a08d1f494e231e2c59730982b 100644 (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) {