August 19, 2015 | Reliance SCADA
The Reliance SCADA system allows you to select a sound to be played when an alarm/event starts, ends, or is acknowledged. The sound to be played can be common to all alarms/events in your project, or can be specified separately for each alarm/event. This helps the user (operator) immediately identify a serious alarm or a standard event when the alarm starts. Another option to distinguish alarms by sound is to let the Reliance system convert an alarm text string to speech and play the speech to the user.
To convert text to speech, you can use the SAPI.SpVoice object, which first appeared in Windows XP, so there is no need to install it. In our experience, the quality of speech reproduction in Windows XP is poor. In Windows 7, however, it is outstanding.
The following example shows how to convert a simple text string to speech using the SAPI.SpVoice object:
As you can see, the example is really easy. Simply create an SpVoice object and call the Speak method to which the text to convert is passed as a parameter.
Warning: You must realize that the Speak method is called synchronously in this example. This means that the script will wait until the speech is finished while blocking other scripts that are to run in the same thread. The simplest solution to this problem is to have a separate thread in the Reliance project for the scripts that will convert the text to speech. Thanks to this, the scripts for controlling the industrial process itself are not affected.
The voice, language, and pronunciation of the speaking "person" are preset based on the Windows regional settings and voices installed on the operating system. They can be changed by setting the Voice property. The following example shows how to get the list of voices available and how to set a particular voice:
To convert alarm text to speech when the alarm starts, ends, or is acknowledged, simply create a common event script in the Reliance project and – for all required alarms – link it to a particular event (e.g., start).
In addition to other information, alarm text is passed to each script that is generated by the alarm. The alarm text can be retrieved in the script by calling the RScr.GetCurrentScriptDataEx method. The text can then be easily used for conversion to speech in the way described in this article. The following is a general-purpose script that – if linked to the alarm's start, end, or acknowledgment – will convert the alarm text to speech:
The sound of the alarm text "Sensor Error! It could cause the system to behave unpredictably." converted to speech is available here:
Text-to-speech conversion in VBScript can not only be used for alarms, but also for any Reliance event for which a script is run.