N-Best Type Functionality
I was looking for a way to support N-Best type of processing in MSS 2007 BETA for a Speech Workflow Applications. I believe the best way to do this is to use the underlying SAPI stuff that Speech Server is built on, so you could use this same concept in a Windows app using SAPI 5.3. Below is a screenshot of the workflow. I have two QuestionAnswer activities with a code activity in between. (I probably could of done something more elegant with the GetAndConfirm activity, but this is good for demonstrating.)

For QA1's grammar I am using a List of three words, "To", "Two" and "Too".
<rule id="Rule1" scope="public">
<one-of>
<item>Two</item>
<item>Too</item>
<item>To</item>
</one-of>
</rule>
So QA1, gathers the input and QA2 does all the processing and confirmation work to figure out which one the user said. I first set the SpeechRecognizer.MaxAlternates to something greater than 1 to get possible alternates. Basically, the RecognitionResults always returns the top answer with the highest confidence score. The alternatives keeps list of all alternatives, from highest to lowest confidence score. I keep track of the list of alternatives using a generic list and remove the top one if the user doesn't confirm. It then moves onto the next possible alternative and ask the user if this is what they said. Notice I use the SayAs.SpellOut to distinguish each word.
Code:
private List<RecognizedPhrase> _alternatives;
public Workflow1()
{
InitializeComponent();
}
protected override void Initialize(IServiceProvider provider)
{
base.Initialize(provider);
this.SpeechRecognizer.MaxAlternates = 4;
_alternatives = new List<RecognizedPhrase>();
}
private void questionAnswerActivity2_TurnStarting(object sender, TurnStartingEventArgs e)
{
questionAnswerActivity2.MainPrompt.ClearContent();
questionAnswerActivity2.MainPrompt.AppendText("Did you say {0} as in ", _alternatives[0].Text);
questionAnswerActivity2.MainPrompt.AppendTextWithHint(_alternatives[0].Text, Microsoft.SpeechServer.Synthesis.SayAs.SpellOut);
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
if (_alternatives.Count == 0)
{
foreach (RecognizedPhrase rp in questionAnswerActivity1.RecognitionResult.Alternates)
{
_alternatives.Add(rp);
}
}
else
{
_alternatives.Remove(_alternatives[0]);
}
}