SpeechRecognitionEventArgs
Namespace: Wisej.Web.Ext.Speech
Assembly: Wisej.Web.Ext.Speech (4.1.0.0)
Provides data for the Result and Error events.
- C#
- VB.NET
public class SpeechRecognitionEventArgs : EventArgs
Public Class SpeechRecognitionEventArgs
Inherits EventArgs
Constructors
SpeechRecognitionEventArgs(results, error)
Initializes a new instance of the SpeechRecognitionEventArgs class.
| Name | Type | Description |
|---|---|---|
| results | Object | The speech recognition results received from the client: an array of dynamic objects with the isFinal, confidence and transcript fields, or null. |
| error | String | The speech recognition error message, or null. |
Properties
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.
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
| Name | Description |
|---|---|
| SpeechRecognitionEventHandler | Represents the method that will handle the Result event. |