使用System.Speech.Synthesis时出现问题 [英] Problem when using System.Speech.Synthesis

查看:392
本文介绍了使用System.Speech.Synthesis时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是Asp.Net的初学者,我使用System.Speech.Synthesis在我的一个webform中将文本转换为语音。起初我得到一个错误,使'Async = True'。之后,我将文本转换为语音。但问题是Web表单永远不会停止加载阶段..这是我使用的代码:

I'm just a beginner in Asp.Net, I used System.Speech.Synthesis for converting text to voice in one of my webform. At first i got an error to make the 'Async=True'. After that I'm getting the text be converted to voice. But the problem is the web form never stops loading stage.. Here is the code I used:

con.Open();
string qs = "select phoneNo,emailId from reg where name='" + DropDownList1.SelectedItem.ToString() + "'";
SqlCommand cmd = new SqlCommand(qs, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
    TextBox1.Text = dr[0].ToString();
    TextBox.Text = dr[1].ToString();
}
dr.Close();
System.Speech.Synthesis.SpeechSynthesizer spk = new System.Speech.Synthesis.SpeechSynthesizer();
spk.Speak("Hello");
spk.Speak(DropDownList1.SelectedItem.Text);



问题是Web表单处于无限加载阶段且文本框未被填充。帮助!


The problem is the web form is in loading stage infinitely and the textboxes are not getting filled. Help!

推荐答案

尝试使用....使用?



http://www.dotnetperls.com/sqlconnection [ ^ ]



该链接显示如何使用使用来管理连接,并在使用后将其丢弃。 br />


如何逐步执行代码并确保从SQL返回记录?因为查看它,可能没有回来的记录,所以它确实说Hello和所选的项目文本,但因为没有返回记录,文本框是空白的?
Try using a .... Using?

http://www.dotnetperls.com/sqlconnection[^]

That link shows how to use Using to manage the connection, and will dispose of it after use.

How about stepping though the code and ensuring there are records being returned from the SQL? Because looking at it, there could be no records coming back, so it does say "Hello" and the selected item text, but because no records were returned, the textboxes were blank?


I在我的博客上写了一篇关于此的文章:http://weblogs.asp.net/ricardoperes/archive/2014/04/08/speech-synthesis-with-asp-net-and-html5.aspx。

希望它有所帮助!
I wrote an article on this on my blog: http://weblogs.asp.net/ricardoperes/archive/2014/04/08/speech-synthesis-with-asp-net-and-html5.aspx.
Hope it helps!


这篇关于使用System.Speech.Synthesis时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆