public StandardSpeechRecognition(Node node)
        {
            if (node != null)
            {
                
                //<param key="ConfidenceThreshold" type="double" value="0.60"/>
                //<param key="DegreesInRightAngle" type="int" value="90"/>
                //<param key="DisplacementAmount" type="int" value="60"/>
                //<param key="GrammarFileBase" type="string" value="SpeechGrammar"/>
                //<param key="Language" type="string" value="Japanese"/>
                //<param key="Culture" type="string" value="ja-JP"/>
                //<param key="FallbackLanguage" type="string" value="English"/>
                //<param key="FallbackCulture" type="string" value="en-US"/>

                _confidenceThreshold = ParameterUtil.Get(node.param, "ConfidenceThreshold", _confidenceThreshold);
                _degreesInRightAngle = ParameterUtil.Get(node.param, "DegreesInRightAngle", _degreesInRightAngle);
                _displacementAmount = ParameterUtil.Get(node.param, "DisplacementAmount", _displacementAmount);
                _grammarFileBase = ParameterUtil.Get(node.param, "GrammarFileBase", _grammarFileBase);
                _language = ParameterUtil.Get(node.param, "Language", _language);
                _culture = ParameterUtil.Get(node.param, "Culture", _culture);
                _fallbackLanguage = ParameterUtil.Get(node.param, "FallbackLanguage", _fallbackLanguage);
                _fallbackCulture = ParameterUtil.Get(node.param, "FallbackCulture", _fallbackCulture);
                _dateTimeFormatString = ParameterUtil.Get(node.param, "DateTimeFormatString", _dateTimeFormatString);
                _grammarFile = string.Concat(_grammarFileBase, "_", _culture, ".xml");

                if (node.publisher != null)
                {
                    var vcp = node.publisher.FirstOrDefault(s => s.msg_type == "VoiceCommandDescription");
                    if (vcp != null)
                    {
                        _voiceCommandPublisher = new VoiceCommandPublisher(vcp.host, vcp.port, vcp.topic);
                        Console.WriteLine(@"Created Voice command publisher : {0}, {1}, {2}", vcp.host, vcp.port, vcp.topic);
                    }
                }
            }
            if (_voiceCommandPublisher == null)
            {
                Console.WriteLine(@"Node info null");
                _voiceCommandPublisher = new VoiceCommandPublisher();
            }
        }
Beispiel #2
0
        private static void SendMotionRecognitionModuleInfo(Node node, string server, int timeout = 1000)
        {
            try
            {
                if (node == null)
                {
                    return;
                }

                var module = new GestureRecognitionModule { name = node.name };
                var desc = new GestureDescription
                {
                    name = "IMU_WAVE",
                    type = GestureDescription.GestureType.Discrete
                };

                module.motions.Add(desc);

               

                using (var context = NetMQContext.Create())
                {
                    using (var socket = context.CreateRequestSocket())
                    {
                        socket.Connect(server);
                        socket.SendMore("register_motions");
                        socket.SendMore(node.name);
                        using (var ms = new MemoryStream())
                        {
                            Serializer.Serialize(ms, module);
                            socket.Send(ms.GetBuffer(), (int)ms.Length);
                        }

                        var msg = socket.ReceiveString(new TimeSpan(0, 0, 0, 0, timeout));
                        if (msg != null)
                        {
                            Log.InfoFormat("Motion registration response: {0}", msg);
                        }
                        else
                        {
                            Log.Info("Message buffer empty!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.InfoFormat("{1} : {0}", ex.StackTrace, ex.Message);
            }
        }