Example #1
0
        public async Task <bool> GetPrivacyDataAsync(Func <StoryNode> lazynode)
        {
            var node = lazynode();

            if (IsAuthenticated && authResult != null)
            {
                var param   = new MySecretParameter();
                var content = await GetHttpContentWithTokenAsync(param.GraphAPIEndpoint, authResult.AccessToken, node.CTS.Token, node.MessageBuffer)
                              .ConfigureAwait(false);

                if (string.IsNullOrEmpty(content))
                {
                    return(false);
                }
                var s1 = StrUtil.MidSkip(content ?? "", "\"displayName\"\\s*:\\s*\"");
                var dn = StrUtil.LeftBefore(s1 + "\"", "\"").Trim();           // pick displayName part
                if (string.IsNullOrEmpty(dn) == false)
                {
                    DisplayName = dn;
                }
                return(true);
            }
            else
            {
                node.MessageBuffer?.WriteLine($"Warning : Could not load privacy data from Microsoft Graph");
                node.MessageBuffer?.WriteLine("(E115)");
                return(false);
            }
        }
Example #2
0
        private static async Task <bool> StartRecognizeSpeechAsync(SpeechHandler handler)
        {
            var param = new MySecretParameter();

            handler.Recognizer                      = new SpeechRecognizer(SpeechConfig.FromSubscription(param.SubscriptionKey, param.ServiceRegion), "ja-JP", handler.AudioConfig);
            handler.Recognizer.Recognizing         += OnRecognizing;
            handler.Recognizer.Recognized          += OnRecognized;
            handler.Recognizer.Canceled            += OnCancel;
            handler.Recognizer.SessionStarted      += OnSessionStarted;
            handler.Recognizer.SessionStopped      += OnSessionStopped;
            handler.Recognizer.SpeechStartDetected += OnSpeechStartDetected;
            handler.Recognizer.SpeechEndDetected   += OnSpeechEndDetected;

            await handler.Recognizer.StartContinuousRecognitionAsync();

            return(true);
        }