Download the Solution Example here: AlarmTextToSpeech.dbsln

  
  • Solution Name: Alarm Text To Speech
  • Software Version: v10
  • Keywords: Alarm, Speech

Summary

Alarms can be linked to scripts to run customized code whenever they are triggered. This solution example shows how to use scripts to voice an Alarm message.


Technical Information

Each AlarmItem is part of an AlarmGroup, which defines how alarms should be displayed and acknowledged. In this example, both AlarmItems belong to the 'Critical' AlarmGroup. To view the configuration for this group, navigate to the Alarms → Groups table.

You can define a custom message to better describe the meaning of an AlarmItem. To do so, go to the Alarms → Items table and change the values in the Message column. In order to audibly play the custom message whenever an Alarm is triggered, you first need to create a method with your custom text-to-speech code. To do so, go to Scripts → Classes and create a new class with the desired method. In this example, we have class ATSNotification set up with the following code:


//Pay attention to the function's parameter.
//It has to be like this to correctly connect with the AlarmGroup.
public void AlarmCustom(AlarmEventInfo[] items)
{
	if (items[0].State == 1)
	{
	    SpeechSynthesizer synth = new SpeechSynthesizer();
	
	    // Configure the audio output. 
	    synth.SetOutputToDefaultAudioDevice();
	
	    // Speak the message associated with the AlarmItem.
	    synth.Speak(items[0].Message);
    }
}

To make this method run whenever an Alarm is triggered, you can go to the Alarms → Groups table, right-click the column titles and enable the NotificationMethod column. Then, set its value to the method you created, which is ATSNotification.AlarmCustom in this case.


Reference Information

→ See Alarms (Audit Trail and Alerts) for more information on Alarms and how to set them up.

→ See Scripts (Tasks and Classes) to find out how scripts work and what more you can do with them.


In this section:

  • No labels