Spoken alerts from OpenRemote

I am now using freetts for spoken alerts from OpenRemote.

I a currently running it on the OpenRemote server machine, but will probably move it to my music computer, as when I run OpenRemote on the Raspberry Pi, it is unlikely to have audio out switched on much of the time.

Freetts implements the Java speech API, and is very easy to use.

When ORControl (or ORMusiControl) starts up, I create a synthesizer:


    // Create a speech synthesizer and start it
    try {  
      System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
      // Create a synthesizer for English
      synth = Central.createSynthesizer(new SynthesizerModeDesc(Locale.ENGLISH));
      synth.allocate();
      synth.resume();
    } catch (EngineException e1) {
      e1.printStackTrace();
    } catch (EngineStateError e1) {
      e1.printStackTrace();
    } catch (AudioException e) {
      e.printStackTrace();
    }

I have implemented a “say text” OpenRemote TCP/IP command, and this just does:


  private void say(String msg) {
    try {  
      // Speak the message
      synth.speakPlainText(msg, null);
  
      // Wait till speaking is done
      synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

This is best used from OpenRemote rules. For example, I have a test rule that tells me when it is hot:


rule "It is hot in here"
when
    Range(source == "Room 1 temperature", value >  20)
then
    execute.command("say","It is hot in here"); 
end

Soon, my house it going to tell me about everything that is happening, but I am sure that I will soon get bored of it.

Advertisements
This entry was posted in Electronics, Home automation. Bookmark the permalink.

6 Responses to Spoken alerts from OpenRemote

  1. [forgive me a little off-topic here]

    I found your blog by Googling for “rf arduino raspberry pi wireless” – well, I nearly found what I wanted 🙂 I’m looking for a way to establish a reliable Arduino to Pi link and ideally some existing library which does that. Are you aware of anything like that? Here’s my StackOverflow question – I would appreciate if you can comment!

    http://stackoverflow.com/questions/14911615/wireless-exchange-between-arduino-and-raspberry-pi-choice-of-protocol

    Cheers,
    Roman
    [me(at)romankirillov.info]

  2. Hello from OpenRemote,

    Love what you’ve done with the text-to-speech feature here, thanks for blogging about it and explaining the steps. Wasn’t aware of the FreeTTS project before.

    We’ve had one or two user questions about text-to-speech feature — would you be interested in contributing the FreeTTS integration you’ve done to the OpenRemote project?

    Best regards,

    — Juha

    • Geek Grandad says:

      Hi Juha, Yes I would be happy to contribute it. It is very little code, but I would need to separate it from the rest of my project. I will also need to learn how OpenRemote is structured. I have been using OpenRemote for some time but have not looked at the code much. Thanks for your project. It is excellent, and has worked perfectly for me. Let me know what I need to do to contribute the code. Lawrie

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s