private void SpeakDirection(object sender, RouteTrackerNewVoiceGuidanceEventArgs e) { #if !NET_CORE_3 // Say the direction using voice synthesis. _speechSynthesizer.SpeakAsyncCancelAll(); _speechSynthesizer.SpeakAsync(e.VoiceGuidance.Text); #endif }
private async void SpeakDirection(object sender, RouteTrackerNewVoiceGuidanceEventArgs e) { // Say the direction using voice synthesis. if (e.VoiceGuidance.Text?.Length > 0) { _speechToken.Cancel(); _speechToken = new CancellationTokenSource(); await SpeakAsync(e.VoiceGuidance.Text, _speechToken.Token); } }
private async void SpeakDirection(object sender, RouteTrackerNewVoiceGuidanceEventArgs e) { // Generate the audio stream for the voice guidance. SpeechSynthesisStream stream = await _speechSynthesizer.SynthesizeTextToStreamAsync(e.VoiceGuidance.Text); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // Play the audio stream. _mediaElement.SetSource(stream, stream.ContentType); _mediaElement.Play(); }); }
private async void SpeakDirection(object sender, RouteTrackerNewVoiceGuidanceEventArgs e) { // Generate the audio stream for the voice guidance. SpeechSynthesisStream stream = await _speechSynthesizer.SynthesizeTextToStreamAsync(e.VoiceGuidance.Text); DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () => { // Play the audio stream. // _mediaElement.SetSource(stream, stream.ContentType); // _mediaElement.Play(); }); }
private void RouteTracker_VoiceGuidanceChanged(object sender, RouteTrackerNewVoiceGuidanceEventArgs e) { Device.BeginInvokeOnMainThread(() => { // Update the help label with the new guidance. HelpLabel.Text = e.VoiceGuidance.Text; }); try { // Say the direction using voice synthesis. if (e.VoiceGuidance.Text?.Length > 0) { _speechToken.Cancel(); _speechToken = new CancellationTokenSource(); SpeakAsync(e.VoiceGuidance.Text, _speechToken.Token); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void SpeakDirection(object sender, RouteTrackerNewVoiceGuidanceEventArgs e) { // Say the direction using voice synthesis. _speechSynthesizer.StopSpeaking(AVSpeechBoundary.Word); _speechSynthesizer.SpeakUtterance(new AVSpeechUtterance(e.VoiceGuidance.Text)); }
private void SpeakDirection(object sender, RouteTrackerNewVoiceGuidanceEventArgs e) { _textToSpeech.Stop(); _textToSpeech.Speak(e.VoiceGuidance.Text, QueueMode.Flush, null, null); }