ASP.NET文本到语音代码在本地开发机器上工作,但不在生产服务器上工作

时间:2013-01-11 19:23:22

标签: asp.net iis-7

我有一个ASP.NET应用程序,可以进行文本到语音TTS。代码在本地计算机上运行正常但是当我在Windows 2008 R2服务器企业64位上部署它时,应用程序池就崩溃了。该应用程序由v4.0 .NET框架构成。我在服务器上使用IIS 7。以下是应用程序池崩溃时的错误。

Service Unavailable

HTTP Error 503. The service is unavailable.

这是我应该添加的代码

        MemoryStream ms = new MemoryStream();

        context.Response.ContentType = "audio/wav";

        Thread t = new Thread(() =>
        {
            SpeechSynthesizer ss = new SpeechSynthesizer();
            ss.SetOutputToWaveStream(ms);
            ss.Speak(context.Request.QueryString["tts"]);
        });
        t.Start();

        t.Join();
        ms.Position = 0;
        ms.WriteTo(context.Response.OutputStream);
        context.Response.End();

任何帮助将不胜感激

由于

以下是Exception的更多细节

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/17/ROOT

Process ID: 5340

Exception: System.UnauthorizedAccessException

Message: Retrieving the COM class factory for component with CLSID {A832755E-9C2A-40B4-89B2-3A92EE705852} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

StackTrace:    at System.Speech.Internal.Synthesis.VoiceSynthesis.Speak(Prompt prompt)
   at System.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
   at TTS.<>c__DisplayClass3.<ProcessRequest>b__0()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

我已将IIS_USRS的完全权限授予C:\ Program Files(x86)\ Microsoft Speech SDK 5.1 \ Bin \ TTSEng.dll。现在错误已更改为

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/17/ROOT

Process ID: 2816

Exception: System.InvalidOperationException

Message: No voice installed on the system or none available with the current security setting.

StackTrace:    at System.Speech.Internal.Synthesis.VoiceSynthesis.Speak(Prompt prompt)
   at System.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
   at TTS.<>c__DisplayClass3.<ProcessRequest>b__0()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

我的服务器上没有任何声音设备。这个例外是否正确?

3 个答案:

答案 0 :(得分:2)

尝试以下

  1. IIS正在运行
  2. 默认网站正在运行
  3. 应用程序池和ASP.Net版本
  4. 访问是合适的

答案 1 :(得分:0)

扎希德在这里有正确的答案。 在IIS中,选择“应用程序池”,单击“高级设置”,然后选择“标识类型”。

语音需要在用户级别访问数据。

答案 2 :(得分:0)

尝试为运行应用程序池的同一用户授予对C:\windows\system32\config\systemprofile\appdata\roaming的读/写访问权限。