我正在尝试制作文本到语音转换软件。该代码按照visual studio 2008的预期工作。但是当我将项目移动到IIS时,它会出错。
下面我分别粘贴代码和错误
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SpeechLib;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void bttn_Speak_Click(object sender, EventArgs e)
{
SpVoice voice = new SpVoice();
SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFDefault;
voice.Speak("hello", SpFlags);
}
}
错误:
Server Error in '/speech' Application.
Error HRESULT E_FAIL has been returned from a call to a COM component.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Source Error:
Line 18: SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFDefault;
Line 19:
Line 20: voice.Speak("hello", SpFlags);
Line 21: }
Line 22: }
Source File: c:\inetpub\wwwroot\speech\Default.aspx.cs Line: 20
Stack Trace:
[COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.]
SpeechLib.SpVoiceClass.Speak(String Text, SpeechVoiceSpeakFlags Flags) +0
_Default.bttn_Speak_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\speech\Default.aspx.cs:20
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
我使用的是Windows 7作为操作系统。请帮我解决这个问题。 提前感谢您的帮助。
答案 0 :(得分:0)
您无法从IIS访问扬声器。即使您这样做,语音也会在服务器机房中生成,而不会在用户的网页上生成。