API官網手冊:http://msdn.microsoft.com/zh-cn/library/System.Speech.Recognition.SpeechRecognitionEngine(v=vs.110).aspxless
微軟語音識別識別率比較低,尤爲是話筒不清晰或者音量低的狀況下,識別率幾乎爲0。慎用。google
微軟、訊飛和google語音識別引擎的對比:spa
http://fqctyj.blog.163.com/blog/static/70843455201361955322797/blog
微軟語音識別引擎字符串
C# sample代碼:input
using System;
using System.Speech.Recognition;
using System.IO;string
namespace SynchronousRecognition
{
class Program
{
static void Main(string[] args)
{it
String textFilePath = null;
int audDevOrFile = -1;
String waveFilePath = null;io
if (args.Length < 1)
{
Console.WriteLine("Too less Params: " + args.Length);
return;
}
else if (args.Length > 1)
{
textFilePath = args[0];
audDevOrFile = int.Parse(args[1]); //大於0,是音頻文件;0是音頻設備
if (audDevOrFile > 0)
{
if (args.Length < 3)
{
Console.WriteLine("please check the param!");
}
else
{
waveFilePath = args[2];
}
}
}
waveFilePath = "F:\\7_.wav";
// Create an in-process speech recognizer for the en-US locale.
using (SpeechRecognitionEngine recognizer =
new SpeechRecognitionEngine(
new System.Globalization.CultureInfo("zh-CN")))
{class
// Create and load a dictation grammar.
recognizer.LoadGrammar(new DictationGrammar());
// Configure input to the speech recognizer.
if (audDevOrFile > 0)
{
recognizer.SetInputToWaveFile(waveFilePath);
}
else
{
recognizer.SetInputToDefaultAudioDevice();
}
// Modify the initial silence time-out value.
recognizer.InitialSilenceTimeout = TimeSpan.FromSeconds(500);
// Start synchronous speech recognition.
RecognitionResult result = recognizer.Recognize();
if (result != null)
{
//FileStream fs = new FileStream(textFilePath, FileMode.Open, FileAccess.ReadWrite);
StreamWriter sw = File.CreateText(textFilePath);
//fs.SetLength(0);//首先把文件清空了。
sw.Write(result.Text);//寫你的字符串。
sw.Close();
Console.WriteLine("{0}", result.Text);
Console.WriteLine("recognize done!");
}
else
{
Console.WriteLine("No recognition result available.");
}
}
//Console.WriteLine(); //Console.WriteLine("Press any key to continue..."); //Console.ReadKey(); } }}