OpenRemote Speaks!

Or at least, I've found a fun way of sending HTML commands to an Android service that converts text to speech.

A great Android app developer has kindly built a background service app that secures a port and listens for simple http commands.

The app is called "Web TTS" and can be found here - https://play.google.com/store/apps/details?id=webtts.alexkenion.apps.webtexttospeech

The usage instructions can be found in the help section and are pretty clear.

Once the background service is running, all you need is the IP address or host name of the Android device to build a command in OpenRemote.

Something simple like this :-

http://My_Android:4000/?say=Hello World

Or if you want to play a tone :-

http://My_Android:4000/?play=tone.mp3&vol=0.75

(Assuming that there is a file called tone.mp3 in your selected folder)

The app can even read out in different languages by adding the relevant language code.

For example, if your default language is set to English US, the following command will force the speech to be UK English

http://My_Android:4000/?say=Hello World&l ang=en-uk

It doesn't translate, but if you want a different accent it can be fun.
English read with a Dutch accent sounds very good.

http://My_Android:4000/?say=Hello World&l ang=nl&vol=1

There is a PIN feature if you'd like a little security.

I have a couple of rules working in OpenRemote that do there following :-

One rule monitors my doorbell button and sends a command to each of our phones to play the same doorbell MP3 file that has been loaded into the doorbell.
So that as long as we are connected to the WiFi, we'll never miss an important delivery.

Another simply sends a command to say that a heating mode has changed.

I'm working on a rule that is based on the LAN presence tutorial so that when any of us return home, we can be greated with a personalised message that tells us the thermostat mode of the house, the current temperature, how many messages on the voicemail and anything else we dream up :wink:

I'm doing this as a precursor to 2 assisted living projects MDAR is involved with.

It would be nice for these two clients to be able to get spoken feedback about their properties, either on demand or when sensors get triggered.

For example I've noticed that my washing machine has a single LED that lights when the machine is active and goes out when its finished, so it shouldn't be too hard to pick that up and trigger a command to announce when the machine completes a cycle.

I'm sure there are hundreds of other uses :slight_smile:

I haven't tried it yet, but I'm fairly sure that a clever use of the $param feature in a command could enable a rule to send out constructed messages.

Alex is very approachable, but I'm quite happy to help if needed.

Good luck,

Stuart

If anyone is interested, here is an example of the rules I've got running to send speech commands to our Android devices.

The HTTP get command for each device looks like this :-

http://192.168.178.39:4000/?say=${param}&lang=en-gb&vol=1&pin=1234

(Nothing else is required in the HTTP command)

A sample rule to monitor a push button event (doorbell) and send speech commands

// TTS rules

rule "Someone at front door"
when
    $evt:Event(source matches "02-10VMB7IN_7_Status", $source : source) // NOTE SENSOR NAME IS WHAT IS BEING COMPARED HERE
then
    String buttonStatus = $evt.getValue().toString();
    boolean isActive = buttonStatus != null && buttonStatus.equalsIgnoreCase("Pressed");

    System.out.println("Button Status Change '" + $source + "': " + buttonStatus);

    // EXECUTE ANY COMMANDS BY USING THEIR NAME AND VALUE TO SET
    // ADD ADDITIONAL COMMANDS AS REQUIRED

    if (isActive)
    {
// execute.command("TextToSpeech_Kristi-param", "Just thought you might like to know that there is someone at the front door"); // Uncomment to send command
// execute.command("Stu_S7-Play-param", "doorbell/Doorbell-sound-tubular-chimes.mp3");
        execute.command("TextToSpeech_Stu_S7-param", "Quick! Quick! Panic stations, there is someone at the front door");
        execute.command("TextToSpeech_Note10", "There is someone at the front door");

    }
    else
    {
// execute.command("something else", ""); // Uncomment to send command
    }
end

For anyone interested, the following rule works like a charm. :slight_smile:

When a temperature mode is changed in a glass panel thermostat, the custom sensor will return text to be announced.

Using a similar pattern of sensors, in theory it would be possible to just create new sensors that match the naming convention and have their values announced.

As an assisted living solution this might just be a nice feature?
Please feedback your experiences.

package org.openremote.controller.protocol;

global org.openremote.controller.statuscache.CommandFacade execute;

import java.util.*;
import java.util.regex.*;

// TTS Test rules

// the aim of this rule is that each glass panel will have a numbered custom Temperature mode sensor with the following fields
// mapped in a Custom Sensor
// {Replace 'Hallway' with the name of the area the glass panel is in}

// "heat_comfort"= "Hallway in Comfort mode"
// "heat_day"= "Hallway in day mode"
// "heat_night"= "Hallway in night mode"
// "heat_safe"= "Hallway in safe mode"

// An android device would then say :- "The heating mode has changed, Hallway in comfort mode"

rule "TTS heating mode"

when
    $evt:Event(source matches "^.*_Temp_Mode-\\d+$", $source : source)
then

// This next line will extract the value of the sensor and hold it in a string

    String ModeStatus = $evt.getValue().toString();

    System.out.println("TTS - Temperature Mode Status Change '" + $source + "': " + ModeStatus);

   try {

      execute.command("TextToSpeech_Stu_S7-param", "The heating mode has changed," + ModeStatus);
   
   } catch (Exception e) {
      System.out.println("############## TTS heating mode exception: " + e.getMessage() + " #################");
      return;
   }

end