Exemple #1
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);

            InitializeComponent();
            Suspending += OnSuspending;
            Resuming += OnResuming;

            var config = new AIConfiguration("cb9693af-85ce-4fbf-844a-5563722fc27f",
                                 "40048a5740a1455c9737342154e86946",
                                 SupportedLanguage.English);

            AIService = AIService.CreateService(config);
        }
Exemple #2
0
        public override void ViewDidLoad()
        {
            try
            {
                aiConfig = new AIConfiguration("135f1908-3d38-4954-83f4-d128948708b2",
                    "a8f248a646ad49d3aa8d5f3ee017009a",
                    SupportedLanguage.PortugueseBrazil);

                aiService = AIService.CreateService(aiConfig);

                this.StartListening();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            base.ViewDidLoad();
        }
        void SelectLanguageSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            var selectedLanguage = languages[e.Position];

            var lang = SupportedLanguage.FromLanguageTag(selectedLanguage.LanguageCode);
            var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d",
                             selectedLanguage.AccessToken, lang);

            //TODO: Option for verbose logging. Remove this line in production.
            config.DebugLog = true;

            if (aiService != null)
            {
                aiService.Cancel();
            }

            aiService = AIService.CreateService(this, config);

            aiService.OnResult += AiService_OnResult;
            aiService.OnError += AiService_OnError;
            aiService.ListeningStarted += AiService_ListeningStarted;
            aiService.ListeningFinished += AiService_ListeningFinished;
            aiService.AudioLevelChanged += AiService_AudioLevelChanged;
        }
        private void InitializeService(LanguageConfig conf)
        {
            var lang = SupportedLanguage.FromLanguageTag(conf.LanguageCode);
            var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d",
                conf.AccessToken, lang);

            //TODO: Option for verbose logging. Remove this line in production.
            config.DebugLog = true;

            if (aiService != null)
            {
                aiService.Cancel();
            }

            aiService = AIService.CreateService(config);

            aiService.OnResult += AiService_OnResult;
            aiService.OnError += AiService_OnError;
            aiService.ListeningStarted += AiService_ListeningStarted;
            aiService.ListeningFinished += AiService_ListeningFinished;
            aiService.AudioLevelChanged += AiService_AudioLevelChanged;
        }
Exemple #5
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            Debug.WriteLine("OnSuspending");

            var deferral = e.SuspendingOperation.GetDeferral();
            if (AIService != null)
            {
                AIService.Dispose();
                AIService = null;
            }
            deferral.Complete();
        }