用c#语言编写的语音应用程序
程序能够正常运行了,在富文本框中输入文字可以读出来了,因为我们再做一个3d智能导游员,需要导游员根据用户语音输入的问题可以进行相应回答,应该怎样进行语音匹配? 请教各位高手。。using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DotNetSpeech;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private Button button2;
private RichTextBox richTextBox1;
private Button button1;
public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(22, 199);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(103, 22);
this.button1.TabIndex = 0;
this.button1.Text = "朗读";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(154, 199);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(103, 22);
this.button2.TabIndex = 1;
this.button2.Text = "生成声音文本";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(36, 33);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(220, 130);
this.richTextBox1.TabIndex = 2;
this.richTextBox1.Text = "";
//
// Form1
//
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.ResumeLayout(false);
}
private void button1_Click(object sender, EventArgs e)
{
try
{
DotNetSpeech.SpeechVoiceSpeakFlags SSF = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
DotNetSpeech.SpVoice vo = new SpVoiceClass();
vo.Speak(this.richTextBox1.Text, SSF);
}
catch (System.Exception ec)
{
MessageBox.Show(ec.ToString(), "SpeechApp", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
DotNetSpeech.SpeechVoiceSpeakFlags SSF = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
DotNetSpeech.SpVoice vo = new SpVoiceClass();
System.Windows.Forms.SaveFileDialog SFD = new System.Windows.Forms.SaveFileDialog();
SFD.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
SFD.Title = "Save to a wav file";
SFD.FilterIndex = 2;
SFD.RestoreDirectory = true;
if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
DotNetSpeech.SpeechStreamFileMode SSFM = DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite;
DotNetSpeech.SpFileStream SFS = new DotNetSpeech.SpFileStreamClass();
SFS.Open(SFD.FileName, SSFM, false);
vo.AudioOutputStream = SFS;
vo.Speak(this.richTextBox1.Text, SSF);
vo.WaitUntilDone(System.Threading.Timeout.Infinite);
SFS.Close();
}
}
catch (System.Exception ec)
{
MessageBox.Show(ec.ToString(), "SpeechApp", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
}
}
}
--------------------编程问答-------------------- 听写用户的问话,然后识别出字符串,你再拿去问题库里匹配,最后合成回答。。
听写是重点。。。参考微软的SpeechSDK,IBM的ViaVoice,科大讯飞。。。很多听写库。。 --------------------编程问答-------------------- 是都需要c#语言编写进去么?。。
补充:.NET技术 , C#