# Speech

The Speech [extender component](https://docs.wisej.com/docs/controls/extenders) **enhances all Wisej.NET components** by providing additional speech synthesis and recognition features that allow a component to speak it’s content – or any text provided in code – and to receive text coming from speech recognition.

{% embed url="<https://github.com/iceteagroup/wisej-extensions/tree/master/Wisej.Web.Ext.Speech>" %}
Speech Source Code
{% endembed %}

## Features

![](https://2248866391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFp7MR1wemvcC5891_r%2Fuploads%2Fgit-blob-5f88409d4246a01c8c9b303c0bc84e4e3b678c17%2FSpeechSynthesis.bmp?alt=media) The **SpeechSynthesis** interface of the Web Speech API is the controller interface for the speech service; this can be used to retrieve information about the synthesis voices available on the device, start and pause speech, and other commands besides.

![](https://2248866391-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFp7MR1wemvcC5891_r%2Fuploads%2Fgit-blob-23032c1e58631a02f0b34a6eed2711964c5b30c6%2FSpeechRecognition.bmp?alt=media) The **SpeechRecognition** interface of Web Speech API allows JavaScript to have access to a browser's audio stream and convert it to text.

## How to Use

The **Speech** extension can be added to a Wisej.NET project using NuGet Package Manager.

{% embed url="<https://www.nuget.org/packages/Wisej-3-Speech>" %}

### SpeechSynthesis

For **SpeechSynthesis** it´s important to set up the SpeakMode:

* *Never*. Speech is disabled for this control.
* *TextOnEnter*. Speaks the specified text when the control is activated.
* *TextOnLeave*, Speaks the specified text when the control is deactivated.
* *ValueOnEnter*. Speaks the value of the control when it is activated.
* *ValueOnLeave*. Speaks the value of the control when it is deactivated.
* *TextOnEnterOnce*. Speaks the specified text when the control is activated the first time only.
* *TextOnLeaveOnce*. Speaks the specified text when the control is deactivated the first time only.
* *ValueOnEnterOnce*. Speaks the value of the control when it is activated the first time only.
* *ValueOnLeaveOnce*. Speaks the value of the control when it is deactivated the first time only.

Further configure the [**SpeechSynthesis** ](https://docs.wisej.com/extensions/extensions/speech/api/wisej.web.ext.speech.speechsynthesis)using [*Voice*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#voice), [*Language*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#language), [*Volume*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#volume), [*Rate* ](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#rate)and [*Pitch* ](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#pitch)property.

**SpeechSynthesis** can be controlled with the Methods [*Pause*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#pause), [*Speak*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#speak-text), [*Resume*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#resume), and [*Cancel*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechsynthesis#cancel).

Sample usage for **SpeechSynthesis**.

```csharp
using (speechSynthesis synthesis = new Wisej.Web.Ext.Speech.SpeechSynthesis())
{
    synthesis.Speak("The CPU is running at 99%.");
}
```

### SpeechRecognition

For [**SpeechRecognition** ](https://docs.wisej.com/extensions/extensions/speech/api/wisej.web.ext.speech.speechrecognition)you need to specify a [*Language*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#language).

If not specified, this defaults to the HTML lang attribute value, or the user agent's language setting if that isn't set either. Other properties are [Continuous](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#continuous), [MaxAlternatives ](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#maxalternatives)and [Grammars](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#grammars). Please refer to the [JSpeech Grammar Format (JSGF).](https://www.w3.org/TR/jsgf/)for the latter.

Use these methods with **SpeechRecognition**: *Start*, *Stop*, *Abort*, and *Clear*. Use [*GetSpeechRecognition* ](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#getspeechrecognition-control)and [*SetSpeedRecognition* ](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#setspeechrecognition-control-properties)to define further properties. Feedback from **SpeedRecognition** is provided through these events: [*Result*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#result), [*NoMatch*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#nomatch), [*Error*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#error), [*SpeechStart* ](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#speechstart)and [*SpeechEnd*](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.speech.speechrecognition#speechend).
