Question SpeechSynthesizer

Ecal

New member
Joined
Feb 22, 2016
Messages
3
Programming Experience
1-3
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using System.Speech.Recognition;
namespace EnriqueSpeachSynth
{
    
    public partial class MainWindow : Window
    {
        internal class txtGrouping
        {
            public string txtGroupingDef;
        }
        List<string> list = new List<string>();
        public string txtMessage = "";
        public class talkText 
        {
            private string _txbx;
            public string Txbx
            {
                get { return _txbx; }
                set { _txbx = value; }
            }
        }
        
        public MainWindow()
        {
            InitializeComponent();            
        }
        SpeechSynthesizer MainSynth = new SpeechSynthesizer();
        PromptBuilder MainPBuilder = new PromptBuilder();
        SpeechRecognitionEngine MainSRecognize = new SpeechRecognitionEngine();
        string boxthis;
       
        
        public void OnContentRendered (object sender, EventArgs e)
        {
            
            MainPBuilder.ClearContent();
            string txtMainBuilder = "Hello, this is the text Analyzer May I have your name?";            
            MainPBuilder.AppendText(txtMainBuilder);
            //MessageBx.Text = txtMainBuilder;
            MainSynth.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(MainSynth_SpeakProgress);
            MainSynth.Speak(MainPBuilder);
        }       
        
        static void MainSynth_SpeakProgress(object sender, SpeakProgressEventArgs e)
        {            
            int charPos = e.CharacterPosition;            
            txtGrouping txtString = new txtGrouping();
            txtString.txtGroupingDef = txtString.txtGroupingDef + e.Text;
            
        }
        
        private void buttonOne_Click(object sender, RoutedEventArgs e)
        {
        }
    }
}

//////XAML code
<Window x:Class="EnriqueSpeachSynth.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:EnriqueSpeachSynth"
        ContentRendered="OnContentRendered"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBox x:Name="MessageBx" Text="{Binding Path=talkText, Mode=OneWay}"/>
        <Button x:Name="buttonOne" Content="Press Me" HorizontalAlignment="Left" Margin="36,270,0,0" VerticalAlignment="Top" Width="75" Click="buttonOne_Click"/>

    </Grid>
</Window>
I am having trouble trying to display the text in TextBox I know I am going to have to concatenate the code in a string the only thing is I can not make the string global and if I try to concatenate the accessors it will not let me. Any ideas or can someone point me in the right direction?
 
Back
Top Bottom