Titan – AN20: Examples of Applications with Audio

¿Buscas alguna otra cosa?

Introduction

Titan routers do not have audio incorporated. However, they are compatible with economic multimedia USB dongles. Using a USB dongle connected to our router Titan, we can play audio files, use an API to convert text into audio, and play files hosted in web servers, by using simple AT commands sent by Telnet, SMS, modbus, snmp, etc. It is very simple. Below, there is a series of examples that will help to understand how it works.

Example 1: Text to Audio Conversion through SMS

In this example we are sending an SMS text to the Titan router. When the router receives the text, it turns it into audio and plays it through speakers.

In order to develop this example, we need to configure the TTS API first. That is, converting text into audio. On the Internet there are many TTS services, free and paid. For this example we will use api. voicerss.org. To do that, we will go to the section “Other > Audio” to configure the API as shown in the image below.

We need to be extra careful to include the parameter with the text we want to convert, into the last position within the API URL. In the case of this example:

http://api.voicerss.org/?key=1fc63bbc3b9e4da98ff4f6955f1cf5d9&hl=eses&f=44khz_8bit_mono&src=

That is, the parameter “src,” which will contain the text to be converted, must be included in the last part of the URL. On the other hand, the section “Other > SMS control” must be properly configurated so the Titan router can receive SMS (thus, to be able to play them as audio, among other things).

Once we configure and reset the Titan router, we are ready to send SMS texts to be converted into audio. For example, if we send the following SMS:

mtx at^mtxtunnel=playtext,This is an audio test.

We will listen the soft voice of a lady saying through the speakers “This is an audio test.”

Example 2: Text to Audio through Commands from Ethernet Device

This example is very similar to the previous one where we converted text to audio through SMS, but this time it is done through IP communication via Ethernet. In this example we are going to assume we have a PLC connected to a Titan router with an Ethernet cable providing Internet access. On top of that task, the Titan router must be able to make the text to audio conversion, as well as playing some audio files previously loaded into the Titan router, and that should be played in certain instances.

In order to develop this example, we first need to configure the TTS service as we did in the last example, that is, from the section “Other > Audio.”

Next, we will activate the console that will allow us to execute AT commands through Telnet from the PLC. To do that we will go to the section “Other > Remote Console” and will configure it as shown below.

After that, we will load the audio files (MP3) we need into the Titan router. We will do that from the section “Other > Audio.”

Once the router is configured and restarted, we can send the audio AT commands from our PLC. However, it would be better to test it beforehand from the Titan router itself. To do that, we will go to the section “Other > Audio” and will write the text to be converted as shown in the image below. If everything goes well, when we press the button “TEST TTS AUDIO,” we should hear the audio version of the text through the speakers.

In order to send AT commands through the Remote Console, we just need to connect to the Titan router through the TCP 20023 port. We can send commands like:

AT^MTXTUNNEL=PLAYTEXT,Volume,Text

Volume: -50 … 50 (0 normal)
Text: text to be converted to audio and played through the speakers.

AT^MTXTUNNEL=PLAYFILE,Volume,FileNumber

Volume: -50 … 50 (0 normal)
FileNumber: 1 … 10 the number of the loaded audio file to be played.

AT^MTXTUNNEL=PLAYURL,Volume,url

Volume: -50 … 50 (0 normal)
url: MP3 url. For example http://www.midominio.com/f.mp3

That is, with these three simple AT commands we can execute several actions: converting tex tinto audio, playing audio files loaded into the router, and playing audio files hosted on a website.

Other considerations:

  1. In this example we are executing AT commands locally via Telnet through a Telnet conection, but we could execute the same commands remotely through 3G/4G
  2. In this example we are executing AT commands from a PLC via Telnet. But we need to remember there are different ways to execute AT commands, like via modbus TCP. In the application note number 10 we will learn how to execute AT commands via modbus TCP (in other words, we can play audio files, convert text to audio, etc. via modbus TCP)

Example 3: Sending Audio Commands from a Web Platform

In this example we are going to assume we have a Titan router connected to a screen displaying informative text messages in a shopping centre. Sometimes, we need to play those text messages through the speakers. This action and more can be accomplished from a control web platform.

That is, we activate the “Enabled” box, specify the “HTTP GET” mode, indicate the complete URL where to dump the data (without http/https), such as “www.metering.es/json/set.asp? Data =, and then in the field ID we can indicate the KEYID of the device. This will be used by the platform to identify the device. In the field “Period” we indicate the period (in minutes) of sending status data to the Web Platform. Remember that in case of a change of IP in the Router will also make a sending of status data, informing your new IP immediately.

To do that, first we need to configure the TTS service, as we did in the previous example, in the section “Other > Audio.”

Next, we need to activate the Remote Console to connect the Titan router to a web platform. To do that, go to the section “Other > Remote Console”. We need to specify the IP address and TCP port of the web platform, an identifying KEY that will allow us to identify the Titan router connected (in case there is more than one) and a reconnection timeout in case the socket falls.

Once the Titan router has been configured and restarted we can send AT commands from our web platform as detailed in the second example, that is, enabling the text to audio conversions, playing audio files previously loaded into the Titan router, or playing audio files hosted in web servers. There is more information in the application note 18.

Remember that AT commands executed from a web platform must be executed between the tags <MTXTUNNEL> and </MTXTUNNEL>. For example, if we want to play the following text: “I love Titan router,” the AT command should be sent from the platform like this from the connection socket:

<MTXTUNNEL>AT^MTXTUNNEL=PLAYTEXT,0,I love Titan router</MTXTUNNEL>

Example 4: Using Audio with Titan Scripts

For this example let’s assume we have a Titan router connected to a temperature/humidity probe modbus RS485. The router, gathers the modbus temperature and humidity data periodically and autonomously from the connected sensor, and sends it to a web platform. We also need the router to play automatically the following audio: “New temperature X degrees” each time the sensor reads a different temperature.

In this example we are just going to focus on the configuration needed for the Titan Scripts to be able to play that audio. Check the user guide or contact iotsupport@matrix.es to learn about the configuration needed to send the gathered modbus data to a web platform.

As usual, in order to play the audio we first need to configure the API TTS in the section “Other > Audio.”

Next we will configure the serial port of the Titan router connected to the probe modbus RS485. We use the COM1 port since it is the only serial port of the Titan router that can be configured as RS485. To do that, we will go to the section: “Serial Settings > Serial Port1-232/485” and will select the speed and values related to the probe, as shown in the following picture.

Next, we will indicate which serial port of the Titan router should be used to read external modbus devices. We will select Serial Port 1, already configured in the section “External Devices > Modbus RTU/TCP.”

Finally, we can write the scripts we need in the section “Other > Titan Scripts.” Let’s say them modbus sensor (using the address modbus 1) sends the temperature to the registry number 5. Then, the script should be the following.

Check the Titan router user guide for more information about Titan Scripts. The audio related Script commands available in the router are:

PT[volume,text] > PlayText
To convert text to audio.
Volume: -50 … 50 (0 normal)

PF[volume,FileID] > PlayFile
To play one of the ten audio files that can be previously loaded in the Titan router.
Volume: -50 … 50 (0 normal)
FileIDo: 1…10

PU[volume,url] > PlayUrl
To play an audio file hosted on a web server.
Volume: -50 … 50 (0 normal)
url: http://www.midominio……/fichero.mp3