C#中没有声音类。播放声音请参阅API!
比如:
[DllImport("Winmm.dll")]
public static extern long PlaySound(string name,long module,long flag);
比如:
[DllImport("Winmm.dll")]
public static extern long PlaySound(string name,long module,long flag);
//
//先将MSTTS的vtxtauto.tlb转换为dll:
//tlbimp vtxtauto.tlb /silent /namespace:mstts /out:mstts.dll
//
//一个封装vtxtauto的类:Speech
using System;
using mstts;
using System.Windows.Forms;
namespace WinApp_Speech
{
/// <summary>
/// Speech 的摘要说明。
/// </summary>
public class Speech
{
public Speech()
{
//
// TODO: 在此处添加构造函数逻辑
//
VTxtAutoEx=new VTxtAuto();
VTxtAutoEx.Register(" "," ");
}
public void Speak(string text)
{
try
{
VTxtAutoEx.Speak(text,0);
}
catch
{
MessageBox.Show("Not support Chinese!");
}
}
private VTxtAuto VTxtAutoEx; }
}----------------------------------------
private void button1_Click(object sender, System.EventArgs e)
{
Speech sp=new Speech();
if (textBox1.Text.Length==0)
{
MessageBox.Show("Please input test!");
}
else
{
sp.Speak(textBox1.Text);
}
}
“
//先将MSTTS的vtxtauto.tlb转换为dll:
//tlbimp vtxtauto.tlb /silent /namespace:mstts /out:mstts.dll
”过程怎么做?我没玩过api指点!!!谢!
使用该工具需要先进入目录:
\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin
2.使用DX9