请求这样的委托为什么得不到结果呢,结果总是空的?急!

战斗生活 2010-06-24 01:58:55
aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="Text1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"
style="height: 26px" />
</div>
</form>
<asp:Label ID="Label1" runat="server" ></asp:Label>
</body>
</html>



aspx页面



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

}
protected void Button1_Click(object sender, EventArgs e)
{
SpeechLib.SpVoice vox = new SpVoiceClass();
//SpVoice vox = new SpVoice();
vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
vox.Speak(Text1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);
}

void vox_Viseme(int StreamNumber, object StreamPosition, int Duration, SpeechLib.SpeechVisemeType NextVisemeId, SpeechLib.SpeechVisemeFeature Feature, SpeechLib.SpeechVisemeType CurrentVisemeId)
{
// Label1.Text = Label1.Text + CurrentVisemeId + " ";
Label1.Text = "Hellow" + Text1.Text;

}
}



因为急忙需要 大侠们 先谢谢了

...全文
190 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
战斗生活 2010-06-30
  • 打赏
  • 举报
回复
这个帖子让我哦觉得好可怜啊 没有办法结贴了
战斗生活 2010-06-29
  • 打赏
  • 举报
回复
[Quote=引用 26 楼 blogtjf 的回复:]

vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
只是注册,没有触发啊
[/Quote]
那请给予你的建议好吗? 在线等待!!!
宇峰科技 2010-06-29
  • 打赏
  • 举报
回复
vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
只是注册,没有触发啊
战斗生活 2010-06-29
  • 打赏
  • 举报
回复
[Quote=引用 23 楼 topso 的回复:]

解决了吗?我在用这个控件的时候根本没用到委托,直接调用方法即可
[/Quote]

那我改如何写呢
战斗生活 2010-06-29
  • 打赏
  • 举报
回复
问题是我也这样用 你说我怎么直接调用呢?
请你给予 建议。
topso 2010-06-29
  • 打赏
  • 举报
回复
解决了吗?我在用这个控件的时候根本没用到委托,直接调用方法即可
战斗生活 2010-06-29
  • 打赏
  • 举报
回复

vox.Speak(Text1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);



这个就是会触发啦啊
战斗生活 2010-06-24
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 a121984376 的回复:]

SpVoiceClass 有没有的源码??
[/Quote]

SpVoice是从微软库里面加进来的 我没有自己写啊

你去看一下
www.codeproject.com/Messages/810450/Using-Viseme-from-sapi-5-1.aspx
a121984376 2010-06-24
  • 打赏
  • 举报
回复
SpVoiceClass 有没有的源码??
战斗生活 2010-06-24
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 a121984376 的回复:]

if(!Page.IsPostBack)
{
vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
}
并没有出发这个事件~
vox.Speak(Text1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);
你的这段代码会触发么??
[/Quote]

我看了别人的那些源码是会触发啊

你觉得该如何写呢 大侠
战斗生活 2010-06-24
  • 打赏
  • 举报
回复
还是不行

public partial class _Default : System.Web.UI.Page
{
public SpeechLib.SpVoice vox = new SpVoiceClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
vox.Speak(Text1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);
//vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
Label1.Text = "Hellow";
}

void vox_Viseme(int StreamNumber, object StreamPosition, int Duration, SpeechLib.SpeechVisemeType NextVisemeId, SpeechLib.SpeechVisemeFeature Feature, SpeechLib.SpeechVisemeType CurrentVisemeId)
{
// Label1.Text = Label1.Text + CurrentVisemeId + " "; //我想得到这个值 但是测试的时候都没有触发.
Label1.Text += Text1.Text; //问题就在这里没有结果 没有触发
}
}


没有触发啊
a121984376 2010-06-24
  • 打赏
  • 举报
回复
if(!Page.IsPostBack)
{
vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
}
并没有出发这个事件~
vox.Speak(Text1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);
你的这段代码会触发么??
a121984376 2010-06-24
  • 打赏
  • 举报
回复
if(!Page.IsPostBack)
{
vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);

}
战斗生活 2010-06-24
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 a121984376 的回复:]

引用 13 楼 a121984376 的回复:
把你的SpVoice类 贴出来~
SpVoice类里应该有个这个事件的定义把??

是不是只定义了一个委托??
[/Quote]

SpVoice就是SpeechLib.SpVoice 啊 是库里面就有的
我加了using SpeechLib的啊这个没有问题
战斗生活 2010-06-24
  • 打赏
  • 举报
回复
希望各位朋友帮帮忙啦! 我本来是学PHP
的 但是工作需要没有办法了,必须得用这个。
a121984376 2010-06-24
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 a121984376 的回复:]
把你的SpVoice类 贴出来~
SpVoice类里应该有个这个事件的定义把??
[/Quote]
是不是只定义了一个委托??
a121984376 2010-06-24
  • 打赏
  • 举报
回复
把你的SpVoice类 贴出来~
SpVoice类里应该有个这个事件的定义把??

战斗生活 2010-06-24
  • 打赏
  • 举报
回复
源码如上面 但是就是没有得到触发的结果
也就是说输入英文字母后没有得到Label1.Text 的结果。
是说明没有触发吧

有朋友说要把vox_Viseme放在button_click里面
那还能说是委托吗?那不就是直接调用了?

我对委托还是不太了解 但是这样应该是没有多大问题的吧
战斗生活 2010-06-24
  • 打赏
  • 举报
回复
aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server"> <title>Untitled Page</title> </head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="Text1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
<asp:Label ID="Label1" runat="server" ></asp:Label>
</body>
</html>



aspx.cs页面

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using SpeechLib;

public partial class _Default : System.Web.UI.Page
{
public SpeechLib.SpVoice vox = new SpVoice();
protected void Page_Load(object sender, EventArgs e)
{
vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
}
protected void Button1_Click(object sender, EventArgs e)
{
vox.Speak(Text1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);
//vox.Viseme += new SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(vox_Viseme);
}

void vox_Viseme(int StreamNumber, object StreamPosition, int Duration, SpeechLib.SpeechVisemeType NextVisemeId, SpeechLib.SpeechVisemeFeature Feature, SpeechLib.SpeechVisemeType CurrentVisemeId)
{
// Label1.Text = Label1.Text + CurrentVisemeId + " "; //我想得到这个值 但是测试的时候都没有触发.
Label1.Text = "Hellow" + Text1.Text;
}
}


战斗生活 2010-06-24
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 topso 的回复:]

提醒你下,你做的bs架构的程序,最后部署在服务器上面,发的声音是在服务器上面发的,嘿嘿。
想在客户端要调用js
[/Quote]

问题是触发都没有出来 我还能做什么呢?
加载更多回复(9)

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧