<Window x:Class ="Wpfwithdatabase.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" >
<Grid Background="#FF7BB8DE">
<TextBlock Height="23" HorizontalAlignment="Left" Margin="133,84,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="118" Visibility="Collapsed" />
<TextBox Height="80" HorizontalAlignment="Left" Margin="123,43,0,0" Name="textBox1" VerticalAlignment="Top" Width="265" BorderBrush="#FF22EE22" Background="#CD335387" Foreground="White" FontWeight="Bold" FontSize="14" />
<Button Content="Click To Listen Voice" Height="23" HorizontalAlignment="Left" Margin="182,129,0,0" Name="button2" VerticalAlignment="Top" Width="150" Click="button2_Click" Foreground="#FF1E48EA" />
<Label Content="Enter Text Here" Height="28" HorizontalAlignment="Left" Margin="26,68,0,0" Name="label1" VerticalAlignment="Top" />
</Grid>
</Window>
Code Page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Speech.Synthesis;
namespace Wpfwithdatabase
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
// object
creation of SpeechSynthesizer Class
private
SpeechSynthesizer voice = new SpeechSynthesizer();
public
MainWindow()
{
InitializeComponent();
}
private
void button2_Click(object
sender, RoutedEventArgs e)
{
// Code
for select Female Voice
voice.SelectVoiceByHints(VoiceGender.Female);
//code
for convert text to voice
voice.SpeakAsync(textBox1.Text);
}
}
}