我尝试使用System.Speech
该类在 ASP.NET mvc 应用程序中生成语音。
[HttpPost]
public ActionResult TTS(string text)
{
SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
speechSynthesizer.Speak(text);
return View();
}
但它给出了以下错误。
System.InvalidOperationException: 'An asynchronous operation cannot be
Started at this time. Asynchronous operations may only be started within an
asynchronous handler or module or during certain events in the Page lifecycle.
If this exception occurred while executing a Page, ensure that the Page is
marked <%@ Page Async="true" %>.
This exception may also indicate an attempt to call an "async void" method,
which is generally unsupported within ASP.NET request processing. Instead,
the asynchronous method should return a Task, and the caller should await it.
我在 wpf 应用程序中使用了 System.Speech 类和异步方法。
System.Speech 类可以在 ASP.NET mvc 应用程序中使用吗?
怎么做?
- 应该
<%@ Page Async="true" %>
放在哪里?