Exemplo n.º 1
0
        /// <summary>
        /// Make the voice speak the text
        /// When the voice has ended, start listening
        /// </summary>
        /// <param name="text">Text to be spoken</param>
        /// <returns>nothing</returns>
        private async Task Speak(string text)
        {
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                AnimateCortana.Begin();

                CortanaSpeakTxt.Text = text;

                var stream = await _speechSynthesizer.SynthesizeTextToStreamAsync(text);
                MediaElementCtrl.SetSource(stream, stream.ContentType);
                MediaElementCtrl.Play();
            });
        }
Exemplo n.º 2
0
        private void VmOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == nameof(Vm.IsConfiguring))
            {
                if (Vm.IsConfiguring)
                {
                    ShowGridLines(Vm.IsConfiguring);
                }
            }

            if (e.PropertyName == nameof(Vm.SpeakStream))
            {
                if (Vm.SpeakStream != null)
                {
                    MediaElementCtrl.SetSource((IRandomAccessStream)Vm.SpeakStream, ((SpeechSynthesisStream)Vm.SpeakStream).ContentType);
                    MediaElementCtrl.Play();
                }
            }
        }