本文介绍了异步语音合成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

(无论如何,这听起来像是一个魔兽世界NPC)

我一直在努力尝试要尝试的家庭项目.

我想在网页中使用System.Speech.Synthesis,但它给了我以下错误.

在这种情况下,不允许异步操作.页面启动异步操作必须将Async属性设置为true,并且异步操作只能在PreRenderComplete事件之前的页面上启动.

老实说,我不知道该怎么办,这就是我所要做的

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;
使用System.Speech.Synthesis;

公共局部类_Default:System.Web.UI.Page
{
受保护的void Page_Load(对象发送者,EventArgs e)
{

}
受保护的void Button1_Click(对象发送者,EventArgs e)
{

SpeechSynthesizer语音=新的SpeechSynthesizer();
speech.SpeakAsync(TextBox1.Text);

}
}

单击该按钮时,它应该读取文本框中的内容.
对于Windows应用程序,我已经做过多次,但是对于Web应用程序,我从未做过.

有人对我有建议吗?

欢迎任何建议.

谢谢,

Harry Neethling

Hi there,

(That sounded like a world of warcraft NPC, anyway)

I have been struggling a bit with a home project that I am trying to figure out.

I want to use System.Speech.Synthesis in a web page but it gives me the following error.

Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to PreRenderComplete event.

To be honest I have no idea what to do, here is what I have

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Speech.Synthesis;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

SpeechSynthesizer speech = new SpeechSynthesizer();
speech.SpeakAsync(TextBox1.Text);

}
}

When the button is clicked, it should read what ever is in the textbox.
I have done this multiple times for windows applications, but never before for a web application.

Does anyone have a suggestion for me?

Any advice is welcome.

Thanks,

Harry Neethling

推荐答案




这篇关于异步语音合成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 15:40