hi ,
I developed an application which converts wav file to text using c#. Using SAPI TTS app tool i saved the wav file in microsoft voice itself. For accurate recognition only i saved it in microsoft voice. Though the result is not accurate. It is recognizing the words wrongly, such as meeting as needing and cute as dubed etc.
I attached my code with it.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using SpeechLib;
namespace using_wav
{
public partial class Form1 : Form
{
private SpeechLib.ISpeechRecoContext wavRecoContext = null;
private SpeechLib.SpFileStream InputWAV = null;
private SpeechLib.ISpeechRecoGrammar Grammar = null;
private String _WAVFile = null;
private string strData = "No recording yet";
private String _lastRecognized = "";
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title =
"Select a Speech file";
dialog.ShowDialog();
_WAVFile = dialog.FileName;
if (_WAVFile == null) return;
wavRecoContext =new SpeechLib.SpInProcRecoContext();
((SpInProcRecoContext)wavRecoContext).Recognition +=new _ISpeechRecoContextEvents_RecognitionEventHandler(wavRecoContext_Recognition);
((SpInProcRecoContext)wavRecoContext).EndStream += new _ISpeechRecoContextEvents_EndStreamEventHandler(wavRecoContext_EndStream);
Grammar = wavRecoContext.CreateGrammar(2);
Grammar.DictationLoad("", SpeechLoadOption.SLOStatic);
InputWAV = new SpFileStream();
InputWAV.Open(@_WAVFile,SpeechStreamFileMode.SSFMOpenForRead, false);
wavRecoContext.Recognizer.AudioInputStream = InputWAV;
Grammar.DictationSetState(SpeechRuleState.SGDSActive);
}
private void wavRecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
{
strData = Result.PhraseInfo.GetText(0, -1,true);
_lastRecognized = textBox1.Text;
textBox1.Text = strData;
}
private void wavRecoContext_EndStream(int StreamNumber, object StreamPosition, bool f)
{
Grammar.DictationSetState(
SpeechRuleState.SGDSInactive);
}
}
}
Is there any fault in this code.
Thanks in advance.
[edit]Code block added - OriginalGriff[/edit]