Configuring a grammar file
For speech recognition, it is necessary to store a grammar file. The required grammar files are stored in the format Speech Recognition Grammar Specification (SRGS). SRGS is a standard that describes how the grammars for speech recognition are specified.
SRGS is a powerful format. TwinCAT Speech supports this standard on 2 levels:
On the one hand, a "Simple SRGS Editor" is offered directly in the TwinCAT Speech Configurator when an ASR service is created. This essentially provides an assignment of tag and text, and the text can be stored in several languages.
On the other hand, external SRGSs, which are created with other editors and are more complex, can also be imported. An example of this use is Sample 03: EventLogger.
Some functions, such as FB_SetRuleState cannot work in this case because they place special demands on the SRGS, which are ensured by the Simple SRGS Editor. This also affects the TwinCAT HMI connection, so that here too only SRGS created by the Simple SRGS Editor can be used in multiple languages. The opening of complex files in the Simple SRGS Editor is denied.
Simple SRGS Editor
The SRGS file is provided with the ASR service, which is typically created by the ASR wizard. Here you can either use the Simple SRGS Editor to edit a local SRGS file or reference an externally provided SRGS.
In the Simple SRGS Editor, "Recognition Texts" are assigned to the "Recognition Tags". These texts can also be arranged in groups, "Recognition Group", in order to enable or disable them via FB_SetRuleState.
Procedure with the Simple SRGS Editor
- 1. Click Create new Grammar File while creating or modifying an ASR service.
- The Simple SRGS Editor opens.
- 2. Name the SRGS file and select a default language. This language is used if no other language is specified. This is also used for the Speech-To-Event integration.
- 3. Under Recognition Tag, enter a tag that is provided in the PLC upon recognition and can be reacted to accordingly. This Recognition Tag is also configured for a response within the HMI. See TwinCAT HMI documentation.
- 4. Under Recognition Text, enter a text to be recognized by ASR.
- 5. If necessary, enter a group under Recognition Group.
- 6. Click the Save button.
- The SRGS file is fully configured.
- The SRGS file is transferred to the target by activating the TwinCAT Speech Configurator project.
Entering voice commands in different languages
The Simple SRGS Editor can be used to recognize multilingual texts.
This is used in particular in connection with the TwinCAT HMI to switch between different languages. Switching does not work simultaneously; the language must always be switched first before a different language can be recognized.
- 1. To open the SRGS Grammar Translation Editor, click the button.
- When the editor is opened, all Recognition Tags already defined are displayed.
- 2. Click the button to add a new language.
- 3. The tab selected on the left defines the language that belongs to the recognition texts.
Previewing the SRGS file
By clicking on the button, you can preview the code of the SRGS file in your default Windows editor for XML files.