Click here to Skip to main content
15,919,341 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I make a Lan Chat Application With Spoken Message . I have problem for example if type the text " HELLO " in the chatbox the application read the word " HELLO " it is Okay but on my second message for example if I type " How are you"? the problem is the application would speak the first message " Hello " and after it would speak the second message which is " How are you?" I want it that the older message would not be speak anymore and the new message will only be speak.

Here's My code I Put this code on a textbox

C#
private void msg_TextChanged(object sender, EventArgs e)
     {

          speech.Rate = speechRate;
          speech.Speak(msg.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);




     }
Posted
Updated 23-Jan-12 2:02am
v2
Comments
Dave Kreskowiak 22-Jan-12 14:33pm    
Well, it's obviously you've done something very wrong in your code, but what that is is impossible to tell since we can't see your code at all.
Sergey Alexandrovich Kryukov 22-Jan-12 16:06pm    
This is a matter where anyone could easily screw up things, not just you. You need to do the architecture and design very accurately paying attention to fine detail, especially order or execution and related timing. You just did not provide enough information for us to help you.
--SA

1 solution

I am agree with Comments by Dave and SAKryukov,

You need to see your code and you will get solution.

speech.Speak(msg.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);


Above code itself says that you are passing msg.Text to Speak() method, instead you need to modify msg.Text string and pass the updated one. Probably you would do it using some class level string variable and store all string inserted or better maintain in an Array which help you to create Chat History and at time of speak you can remove existing chat from current updated Chat.

This is just a remedy for your issue, I am not saying this is best approach you really need to design your approach in batter way.

Regards
Rushikesh Joshi
 
Share this answer
 
Comments
odolskie 23-Jan-12 10:57am    
public void timer1_Tick(object sender, EventArgs e)
{

try
{
if (listener.Pending() == true)
{
message = "";
client = listener.AcceptTcpClient();
StreamReader reader = new StreamReader(client.GetStream());
while (reader.Peek() > -1)
{
//error here -> message.Append((char)reader.Read());

}
this.Focus();
rtbConversation.Text = (rtbConversation.Text
+ (message + "\r\n"));

speech.Speak(rtbConversation.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
//p_objSynth.SelectVoice(cmbInstalled.Text)
//p_objSynth.SpeakAsync(TextBox3.Text)
}

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);

}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900