2011-11-01 70 views
0

那麼我使用的是Microsoft Speech Platform SDK 10.2。我做了一個asp.Net WebService應用程序和大多數WebServices工作正常(HelloWorld()等),但我有一個使用SpeechRecognitionEngine的服務,當我部署應用程序並嘗試運行這個web服務我沒有得到任何結果,也就是說,我可以通過調試模式看到它到達返回行,但是當我調用瀏覽器時,頁面始終加載,沒有任何響應。微軟在webservices中的語音識別沒有返回結果

下面的代碼示例:

[WebMethod] 

public bool voiceRecognition() {  
    SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("pt-PT")); 
    Choices c = new Choices(); 
    c.Add("test"); 
    GrammarBuilder gb = new GrammarBuilder(); 
    gb.Append(c); 
    Grammar g = new Grammar(gb); 
    sre.LoadGrammar(g); 
    sre.InitialSilenceTimeout = TimeSpan.FromSeconds(5); 

    //// just for Testing 
    RecognitionResult result = null; 

    if (result != null) { 
     return true; 
    } else { 
     return false; 
    } 
} 

注:我使用IIS部署WebService的應用。

如果有人有一些想法,請讓我知道。

回答

0

我不知道你是否找到了你的答案。幾天前,當我試圖解決這個問題時,我偶然發現了你的問題,並且它將我們的情況與「T」相匹配。

爲了解決這一切,我們所要做的就是把...

sre.RecognizeAsyncStop(); 
sre.Dispose(); 

其中「SRE」是你SpeechRecognitionEngine變量。如果您不停止並在Web服務結束時處理它,則Web服務將不會返回。

希望這會有所幫助。 :)