实现语音聊天,请指点 不知道你的语音聊天到底是什么概念?有没有用到语音识别?微软有语音开发包SDK,你去微软站点找找,不过只支持英文。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 需要用到微软的AGLIENT(好象是这个单词,记不大清了!) 在Windows中有一套以wavein和waveout开头的函数,可以实现你的功能。 我要的是中文,大家能不能结合.net网络应用,说的详细一点,再谢 ##要求 (1)微软公司视窗2000服务器版或视窗 XP 版 (2).Net FrameWrok SDK Beta 2版 (3)Microsoft Agent核心组建 (4)Microsoft Agent的精灵:吉尼(Genie)、么林(Merlin)、罗比(Robby)和皮蒂(Peedy) (5)至少有一个英语的Text-to-Speech引擎(现在还找不到中文的) (6)微软运行时发音API4.0a (如果还要实现语音识别功能的话,还要有微软的语音识别引擎) 所有这些都可以在http://microsoft.com/msagent/downloads.htm,下载下面六个文件:Download selected language component Download selected character Download selected engineDownload the Microsoft SAPI 4.0a runtime binaries (824 KB exe) Download the Microsoft® Speech Recognition Engine (6 MB exe) Download the Speech Control Panel (927 KB exe) 下载完后,直接解压安装它们,重启电脑.另外,必须要安装Office2000(Office97是不行的)。 ##实现方法 1.打开VS.Net,新建一个工程,不妨取名为CoolUI.2.创建用户界面。 选择菜单:工具->自定义工具箱,并选择Microsoft Agent Control 2.0组件, 将Microsoft Agent Control控件添加到窗体上(在程序运行时是看不到窗体是的Microsoft Agent控件的,只有在设计界面时它才显示出来),将主窗体的Text属性设置为“CoolUI”;将左边三个按钮的Text属性分别设置为“导入精灵”、“朗读文本”、“隐藏精灵”;将textBox的Text属性设置为“Type anything here for the character to read for you!(Only English)”,Multiline属性设置为True。 3.简单的用户界面已经完成,现在来进行代码部分的工作: 首先,添加using AgentObjects;到代码的开始处。其次,在我们的类里添加私有数据成员:private IAgentCtlCharacterEx Character;(这就是我们要用到的精灵的对象)。修改构造函数如下: public Form1() { InitializeComponent(); button2.Enabled=false;//先使下面的两个按钮无效 button3.Enabled=false; } 接着,添加左边三个按钮的鼠标单击的消息相应函数: private void button1_Click(object sender, System.EventArgs e) private void button2_Click(object sender, System.EventArgs e) private void button3_Click(object sender, System.EventArgs e) 代码如下: private void button1_Click(object sender, System.EventArgs e) { axAgent1.Characters.Load("Genie", (object)"GENIE.ACS");//导入吉尼这个精灵 Character = axAgent1.Characters["Genie"]; Character.LanguageID = 0x409;//把语言设置为英语,这里不能是中文 Character.Show(null);//显示精灵 button1.Enabled=false;//重新设置按钮的有效性 button2.Enabled=true; button3.Enabled=true; } private void button2_Click(object sender, System.EventArgs e) { if(textBox1.Text.Length == 0) //如果没有字符的话,就不读 return; Character.Speak(textBox1.Text, null);//让精灵朗读文本 } private void button3_Click(object sender, System.EventArgs e) { Character.Play("Wave"); Character.Play("Hide");//隐藏精灵 } 所有完整的代码如下:using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using AgentObjects;namespace CoolUI{ public class Form1 : System.Windows.Forms.Form{private System.Windows.Forms.Button button1;private System.Windows.Forms.Button button2;private System.Windows.Forms.Button button3;private System.Windows.Forms.TextBox textBox1;private System.ComponentModel.Container components = null;private AxAgentObjects.AxAgent axAgent1;private IAgentCtlCharacterEx Character;public Form1(){InitializeComponent();button2.Enabled=false;//先使下面的两个按钮无效 button3.Enabled=false; }protected override void Dispose( bool disposing ){if( disposing ){if (components != null) {components.Dispose();}}base.Dispose( disposing );}#region Windows Form Designer generated code/// /// Required method for Designer support - do not modify/// the contents of this method with the code editor./// private void InitializeComponent(){System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));this.button1 = new System.Windows.Forms.Button();this.button2 = new System.Windows.Forms.Button();this.button3 = new System.Windows.Forms.Button();this.textBox1 = new System.Windows.Forms.TextBox();this.axAgent1 = new AxAgentObjects.AxAgent();((System.ComponentModel.ISupportInitialize)(this.axAgent1)).BeginInit();this.SuspendLayout();// // button1// this.button1.Location = new System.Drawing.Point(32, 32);this.button1.Name = "button1";this.button1.TabIndex = 1;this.button1.Text = "导入精灵";this.button1.Click += new System.EventHandler(this.button1_Click);// // button2// this.button2.Location = new System.Drawing.Point(32, 80);this.button2.Name = "button2";this.button2.TabIndex = 2;this.button2.Text = "朗读文本";this.button2.Click += new System.EventHandler(this.button2_Click);// // button3// this.button3.Location = new System.Drawing.Point(32, 128);this.button3.Name = "button3";this.button3.TabIndex = 3;this.button3.Text = "隐藏精灵";this.button3.Click += new System.EventHandler(this.button3_Click);// // textBox1// this.textBox1.Location = new System.Drawing.Point(120, 16);this.textBox1.Multiline = true;this.textBox1.Name = "textBox1";this.textBox1.Size = new System.Drawing.Size(184, 184);this.textBox1.TabIndex = 4;this.textBox1.Text = "Type anything here for the character to read for you!(Only English)";// // axAgent1// this.axAgent1.Enabled = true;this.axAgent1.Location = new System.Drawing.Point(56, 176);this.axAgent1.Name = "axAgent1";this.axAgent1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAgent1.OcxState")));this.axAgent1.Size = new System.Drawing.Size(32, 32);this.axAgent1.TabIndex = 5;// // Form1// this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);this.ClientSize = new System.Drawing.Size(336, 229);this.Controls.AddRange(new System.Windows.Forms.Control[] {this.axAgent1,this.textBox1,this.button3,this.button2,this.button1});this.Name = "Form1";this.Text = "CoolUI";((System.ComponentModel.ISupportInitialize)(this.axAgent1)).EndInit();this.ResumeLayout(false);}#endregion[STAThread]static void Main() {Application.Run(new Form1());}private void button1_Click(object sender, System.EventArgs e){axAgent1.Characters.Load("Genie", "Genie.acs");//导入吉尼这个精灵 Character = axAgent1.Characters["Genie"]; Character.LanguageID = 0x409;//把语言设置为英语,这里不能是中文 Character.Show(null);//显示精灵 button1.Enabled=false;//重新设置按钮的有效性 button2.Enabled=true; button3.Enabled=true; }private void button2_Click(object sender, System.EventArgs e){if(textBox1.Text.Length == 0) //如果没有字符的话,就不读 return;Character.Speak(textBox1.Text, null);//让精灵朗读文本 }private void button3_Click(object sender, System.EventArgs e){Character.Play("Wave"); Character.Play("Hide");//隐藏精灵 }}}4.好了,现在完成了所有的工作了,安Ctrl+F5试试效果吧! 呵呵,我也是看了别人的例子!! 多谢, heroabi(萧索寒) 大哥详细的解说,但我要的是语音聊天,不是朗读,而且,一定要支持中文,谢 想语音聊天室怎么做的。我一直也想知道。调用agent很简单,我以前在delphi下实现过。c#也修改啦。没问题 先看一下多媒体高级编程吧,agent只是一些锦上添花的功能,并不能完成语音的录入和播放,同时还有网络编程,text-to-spech可以支持中文在微软的网页可以down在w2k下测试没有问题 xml下相应的子节点应该怎样获得 新浪、QQ微博评论功能如何做的 从后台赋值 请问如何验证CheckBox被选中? 如果对TextBox.Text里内容进行验证 |M|用户控件给我们的界面更好的设计和管理:但却增加了服务器的压力这种情况大家是怎么做的 服务器配置问题 问个脚本问题: 这个系统大小是否合适? 斑竹在嘛?又要麻烦你了 服务器装着是英文win2k,在页面上显示的时间是十二小时制???怎样显示24小时制。 100分求好的混淆器,各位高手谁有,请帮帮小弟?
(1)微软公司视窗2000服务器版或视窗 XP 版
(2).Net FrameWrok SDK Beta 2版
(3)Microsoft Agent核心组建
(4)Microsoft Agent的精灵:吉尼(Genie)、么林(Merlin)、罗比(Robby)和皮蒂(Peedy)
(5)至少有一个英语的Text-to-Speech引擎(现在还找不到中文的)
(6)微软运行时发音API4.0a
(如果还要实现语音识别功能的话,还要有微软的语音识别引擎)
所有这些都可以在http://microsoft.com/msagent/downloads.htm,下载下面六个文件:
Download selected language component
Download selected character
Download selected engine
Download the Microsoft SAPI 4.0a runtime binaries (824 KB exe)
Download the Microsoft® Speech Recognition Engine (6 MB exe)
Download the Speech Control Panel (927 KB exe)
下载完后,直接解压安装它们,重启电脑.
另外,必须要安装Office2000(Office97是不行的)。 ##实现方法
1.打开VS.Net,新建一个工程,不妨取名为CoolUI.
2.创建用户界面。
选择菜单:工具->自定义工具箱,并选择Microsoft Agent Control 2.0组件,
将Microsoft Agent Control控件添加到窗体上(在程序运行时是看不到窗体是的Microsoft Agent控件的,只有在设计界面时它才显示出来),
将主窗体的Text属性设置为“CoolUI”;将左边三个按钮的Text属性分别设置为“导入精灵”、“朗读文本”、“隐藏精灵”;将textBox的Text属性设置为“Type anything here for the character to read for you!(Only English)”,Multiline属性设置为True。
3.简单的用户界面已经完成,现在来进行代码部分的工作:
首先,添加using AgentObjects;到代码的开始处。
其次,在我们的类里添加私有数据成员:private IAgentCtlCharacterEx Character;(这就是我们要用到的精灵的对象)。修改构造函数如下:
public Form1()
{
InitializeComponent();
button2.Enabled=false;//先使下面的两个按钮无效
button3.Enabled=false;
}
接着,添加左边三个按钮的鼠标单击的消息相应函数:
private void button1_Click(object sender, System.EventArgs e)
private void button2_Click(object sender, System.EventArgs e)
private void button3_Click(object sender, System.EventArgs e)
代码如下:
private void button1_Click(object sender, System.EventArgs e)
{
axAgent1.Characters.Load("Genie", (object)"GENIE.ACS");//导入吉尼这个精灵
Character = axAgent1.Characters["Genie"];
Character.LanguageID = 0x409;//把语言设置为英语,这里不能是中文
Character.Show(null);//显示精灵
button1.Enabled=false;//重新设置按钮的有效性
button2.Enabled=true;
button3.Enabled=true;
} private void button2_Click(object sender, System.EventArgs e)
{
if(textBox1.Text.Length == 0) //如果没有字符的话,就不读
return;
Character.Speak(textBox1.Text, null);//让精灵朗读文本
} private void button3_Click(object sender, System.EventArgs e)
{
Character.Play("Wave");
Character.Play("Hide");//隐藏精灵
} 所有完整的代码如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using AgentObjects;namespace CoolUI
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.Container components = null;
private AxAgentObjects.AxAgent axAgent1;
private IAgentCtlCharacterEx Character;public Form1()
{
InitializeComponent();
button2.Enabled=false;//先使下面的两个按钮无效
button3.Enabled=false;
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.axAgent1 = new AxAgentObjects.AxAgent();
((System.ComponentModel.ISupportInitialize)(this.axAgent1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(32, 32);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "导入精灵";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(32, 80);
this.button2.Name = "button2";
this.button2.TabIndex = 2;
this.button2.Text = "朗读文本";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(32, 128);
this.button3.Name = "button3";
this.button3.TabIndex = 3;
this.button3.Text = "隐藏精灵";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(120, 16);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(184, 184);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "Type anything here for the character to read for you!(Only English)";
//
// axAgent1
//
this.axAgent1.Enabled = true;
this.axAgent1.Location = new System.Drawing.Point(56, 176);
this.axAgent1.Name = "axAgent1";
this.axAgent1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAgent1.OcxState")));
this.axAgent1.Size = new System.Drawing.Size(32, 32);
this.axAgent1.TabIndex = 5;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(336, 229);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.axAgent1,
this.textBox1,
this.button3,
this.button2,
this.button1});
this.Name = "Form1";
this.Text = "CoolUI";
((System.ComponentModel.ISupportInitialize)(this.axAgent1)).EndInit();
this.ResumeLayout(false);}
#endregion[STAThread]
static void Main()
{
Application.Run(new Form1());
}private void button1_Click(object sender, System.EventArgs e)
{
axAgent1.Characters.Load("Genie", "Genie.acs");//导入吉尼这个精灵
Character = axAgent1.Characters["Genie"];
Character.LanguageID = 0x409;//把语言设置为英语,这里不能是中文
Character.Show(null);//显示精灵
button1.Enabled=false;//重新设置按钮的有效性
button2.Enabled=true;
button3.Enabled=true;
}private void button2_Click(object sender, System.EventArgs e)
{
if(textBox1.Text.Length == 0) //如果没有字符的话,就不读
return;
Character.Speak(textBox1.Text, null);//让精灵朗读文本
}private void button3_Click(object sender, System.EventArgs e)
{
Character.Play("Wave");
Character.Play("Hide");//隐藏精灵
}
}
}4.好了,现在完成了所有的工作了,安Ctrl+F5试试效果吧!
呵呵,我也是看了别人的例子!!