Skip to main content

SpeechRecognitionEventArgs

Namespace: Wisej.Web.Ext.Speech

Assembly: Wisej.Web.Ext.Speech (4.1.0.0)

Provides data for the Result and Error events.

public class SpeechRecognitionEventArgs : EventArgs

Constructors​

Instance member SpeechRecognitionEventArgs(results, error)​

Initializes a new instance of the SpeechRecognitionEventArgs class.

NameTypeDescription
resultsObjectThe speech recognition results received from the client: an array of dynamic objects with the isFinal, confidence and transcript fields, or null.
errorStringThe speech recognition error message, or null.

Properties​

Instance member Error​

String: Returns the error message from the speech recognition object.

The value is the error code reported by the browser, i.e. "no-speech", "aborted", "audio-capture", "network", "not-allowed" or "language-not-supported". It's null for the Result event.

Instance member Results​

SpeechRecognitionResult[]: Returns the list of speech recognition results.

The array contains all the alternatives (up to MaxAlternatives) of the results received, including interim results when InterimResults is true. It's empty for the Error event.

Example:

Using the final result with the highest confidence:

private void speechRecognition1_Result(object sender, SpeechRecognitionEventArgs e)
{
var best = e.Results
.Where(r => r.IsFinal)
.OrderByDescending(r => r.Confidence)
.FirstOrDefault();

if (best != null)
this.labelCommand.Text = best.Transcript;
}

Used By​

NameDescription
SpeechRecognitionEventHandlerRepresents the method that will handle the Result event.