[英]Microsoft Speech Platform speech to text
我想將用戶說的話寫成文字。 我可以使用Microsoft語音平台執行此操作嗎? 也許我只是誤解了它應該如何工作以及其預期的用例是什么。
我現在有這個控制台應用程序:
static void Main(string[] args)
{
Choices words = new Choices();
words.Add(new string[] { "test", "hello" ,"blah"});
GrammarBuilder gb = new GrammarBuilder();
gb.Append(words);
Grammar g = new Grammar(gb);
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
sre.LoadGrammar(g);
sre.SetInputToDefaultAudioDevice();
//add listeners
sre.Recognize();
Console.ReadLine();
}
而且它似乎只輸出我在Choices
指定的單詞。
如果我想(最多)匹配用戶說的話,是否需要添加整個單詞詞典?
此外,它在匹配單個單詞后立即停止。 如果我想記錄整個句子怎么辦?
我正在尋找A)捕獲大量單詞,以及B)一次捕獲多個單詞的解決方案。
我發現了這一點: http : //www.codeproject.com/Articles/483347/Speech-recognition-speech-to-text-text-to-speech-a#torecognizeallspeech
如本頁所示 , DictationGrammar類具有基本的常用單詞庫。
一次捕獲多個單詞
sre.RecognizeAsync(RecognizeMode.Multiple);
所以我的代碼現在是這樣的:
public static SpeechRecognitionEngine sre;
static void Main(string[] args)
{
sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
sre.LoadGrammar(new Grammar(new GrammarBuilder("exit")));
sre.LoadGrammar(new DictationGrammar());
sre.SetInputToDefaultAudioDevice();
sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
Console.ReadLine();
}
private static void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "exit")
{
sre.RecognizeAsyncStop();
}
Console.WriteLine("You said: " + e.Result.Text);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.