TwinCAT Speech

The TwinCAT Speech Extension offers a connection to TwinCAT Speech systems. This allows a TwinCAT HMI client/browser to be used as an audio input and output device. For the extension, the .NET Core Runtime must be installed.

1. Install the TwinCAT Speech extension using the NuGet Package Manager:
TwinCAT Speech 1:
The extension can now be used:
TwinCAT Speech 2:

The extension is now responsible for the exchange of data between TwinCAT Speech and the browser. Therefore, nothing needs to be configured on the extension itself.

The server must be announced first in TwinCAT Speech (see Documentation of TwinCAT Speech).

Base configuration

By default, no speech connection is established. For this purpose, a connection must be actively started by a TypeScript/JavaScript API call.

TcHmi.TcSpeech.openConnection({
   enableMicrophone: true,
   enableSpeaker: true
});

Further possible parameters of the call with the respective default value are:

defaultVolume: 1 This is the volume of the sound output when loading the application. This can be set from 0 to 1.

domain: 'TcHmiSpeech' Domain name under which the speech extension is reachable.

confidenceThreshold: 0.2 Each recognition event has a probability that the recognized text corresponds to the specified entry. This threshold value specifies the value from which this is treated as a genuine event. If, for example, 0.9 is specified here, an HMI event is only triggered in the case of a very precise correspondence. (Refer also to the documentation from Microsoft)

Use of recognized events in the project

Recognized texts call events in the speech system. These are transferred to the browser and are usable there in an identical way to events of controls (such as myButton.onClick). The Recognition Tag from the SRGS file is taken here as the name.

It can thus be used as an event in the Actions and Conditions Editor in the HMI. The name is entered in the Custom area for this purpose. If, for example, SpeechOnCommand<SET_ENGLISH> is entered here, then an action is started on recognition of the Recognition Tag SET_ENGLISH.

Use via CodeBehind is also possible. Sample code with TypeScript:

TcHmi.EventProvider.register('SpeechOnCommand<SET_ENGLISH>', (e, data: TcHmi.TcSpeech.IEventCallbackParameter) => {
    // Will output:
    // 'The user said a text which triggered the recoginition tag: SET_ENGLISH'
    console.log('The user said a text which triggered the recoginition tag: ' + data.Command);
    if (data.Confidence > 0.9) {
        console.log('The speech recognition was pretty sure about that.');
    }
    if (data.Parameter) {
        console.log('We got a parameter for this recognition: ', data.Parameter);
    }
});
TwinCAT Speech 3:

Available from version 1.12.744.0