I have simply code here:
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using System.Diagnostics;
namespace Zad3
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
String text = System.IO.File.ReadAllText(@"C:\Users\source\repos\Lista3\zad3.txt");
if (text != null)
{
MediaElement mediaElement = new MediaElement();
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(text);
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();
}
}
}
}
And i create one button in xaml. When i click button my program turn off... When i change text for normal string (np."Hello") my program work perfectly.
How can i repair this ? Please help. I tried to do it in a million ways . I'm begginer in this language.