Author Topic: Text to Speech  (Read 5631 times)

Offline pocster

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
Text to Speech
« on: March 24, 2013, 01:12:06 pm »
Hi all,

I see some work for Sonos and Squeezebox has been done on this. But wonder if a general method can be used.
For example:

www.text2speech.org is free and returns an mp3 with the speech in.
Just wondering 'how' verde could maybe call this and then issue a command to a slave (XBMC or whatever) to 'play' the mp3 (presumably stored on a common drive).

Just thinking out loud!  :D

Offline pocster

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
Re: Text to Speech
« Reply #1 on: March 24, 2013, 02:02:11 pm »
OK, getting warm!

Found this:  http://www.codeproject.com/Articles/435434/Text-to-Speech-tts-for-the-Web

So I am guessing it *should* be possibel for verde to issue this ; perhaps use the site I suggested (as the wav/mp3/ogg) is stored on the cloud. Then get XBMC (or whatever) to play the file from there .....
More research required!. Anyone who is more knowledgeable than me (i.e. everyone  ;)) just jump in at any point!

Cheers

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +476/-10
Re: Text to Speech
« Reply #2 on: March 24, 2013, 02:42:09 pm »
http://www.text2speech.org/ is OK if you want your automation to sound like Dr. Stephen Hawking.  ;D

I used the AT&T Natural Speech Demo as suggested by @cbutters http://forum.micasaverde.com/index.php/topic,13619.msg105826.html#msg105826 to create a set of announcements that cover my needs. The speech quality is pretty good and sounds quite natural. I haven't yet found the need to create new sound-files on the fly.

Offline SteveZ

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: +4/-1
Re: Text to Speech
« Reply #3 on: March 24, 2013, 02:49:15 pm »
http://ctrlq.org/listen/ is one that uses the google tts and gives you the option to download to a mp3, but only allows you so many per hour

but another option is to use vera alerts app and install it to a android tablet or a android phone.

Offline pocster

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
Re: Text to Speech
« Reply #4 on: April 13, 2013, 11:13:21 am »
Ooooo!
http://ctrlq.org/listen/ seems nice
So how do I send it a string to convert to speech and then get it to save the mp3 to verde???

Or better still wget send to translate.google.com ??

Cheers
« Last Edit: April 13, 2013, 11:51:06 am by pocster »

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2178
  • Karma: +29/-38
  • Life Moves Pretty Fast....
    • Node Central
Re: Text to Speech
« Reply #5 on: April 13, 2013, 11:37:06 am »
@pocster

Have a look at the code used for the Sonos plugin, I seem to recall that within its design it downloads and saves the requested GoogleTTS to Vera - but how you get that file and play it back via XBMC is another thing.

Also keep in mind you can look at the google TTS message as an MP3 radio stream, so that might be of use too as it'll save you playing with mp3 files.

Both the Sonos and Squeezebox plugins are a great reference points

Offline pocster

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
Re: Text to Speech
« Reply #6 on: April 13, 2013, 11:52:54 am »
Hey Parkerc!

Well!, too be honest. I *really* just want Verde to trigger an aplay or something on a remote device or trigger a google translate. I have read through the sonos threads - and decided to avoid doing an XBMC thing...

Cheers

Offline VeraUser

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Text to Speech
« Reply #7 on: April 13, 2013, 12:11:02 pm »
I have a working text to speech module now for Vera using Raspberry Pi.

Essentially, I have a node.js script running on the raspberry pi that Vera can call (using LUA script).

Basically the node.js script accepts a call from vera, calls Google translate to get an mp3 version of the text passed from Vera and outputs it though the USB speakers I have connected to the Pi.

This works really well as I can have the PI anywhere I like and could have multiple Pis in the house although I only currently have one. Since the speakers connected to the Pi are powered through the USB port there is only one mains lead to power the Pi.

So, I have scenes in Vera which are triggered by PIR sensors around the house which announce when someone is at the front or side of the house etc.

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2178
  • Karma: +29/-38
  • Life Moves Pretty Fast....
    • Node Central
Re: Text to Speech
« Reply #8 on: April 13, 2013, 12:45:06 pm »
Hi @VeraUser

Do you have post somewhere on your Raspberry Pi & TTS set up?
I'd be interested to have a go with that.

Offline VeraUser

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Text to Speech
« Reply #9 on: April 13, 2013, 01:32:58 pm »
I don't have a post no, but these are the main steps:

To get node.js on the Pi:
http://www.jeremymorgan.com/tutorials/raspberry-pi/how-to-install-node-js-raspberry-pi/


To get Google text to speech on the Pi (to create the file called speech.sh)
http://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis)


Node.js script:
var net = require('net');
var cp = require('child_process');
/*
* Callback method executed when a new TCP socket is opened.
*/
function newSocket(socket) {
        socket.write('Welcome to the Telnet server!');
        socket.on('data', function(data) {
                receiveData(socket, data);
        })
}
/*
* Cleans the input of carriage return, newline
*/
function cleanInput(data) {
        return data.toString().replace(/(\r\n|\n|\r)/gm,"");
}

/*
* Method executed when data is received from a socket
*/
function receiveData(socket, data)
{
        var cleanData = cleanInput(data);
        var speakCmd = '/usr/local/nodejs/speech.sh ';
        var speakData = "";
        switch(cleanData)
        {

                case "@frontdoor":
                        speakData = 'There is movement detected at the front door.';
                break;
                case "@sidehouse":
                       speakData = 'There is movement detected at the side of the house.';
                break;

         
                default:
                        speakData = cleanData;

        }
        cp.exec(speakCmd + speakData);

        var currentTime = new Date()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
        console.log(hours + ":" + minutes + " " + cleanData);
}

// Create a new server and provide a callback for when a connection occurs
var server = net.createServer(newSocket);

// Listen on port 5150
server.listen(5150);

cp.exec('/usr/local/nodejs/speech.sh Welcome.');


And LUA script to run for a scene when the front door is triggered:
local socket = require("socket")
host = "192.168.0.99"
local tcp = assert(socket.tcp())
if( tcp ~= "nil" and tcp ~= nill) then
tcp:settimeout(0.5)
tcp:connect(host, 5150)
tcp:send("@frontdoor\r")
tcp:close()
end

That will trigger the node.js to say the text that is defined in the node.js script for when the text @frontdoor is sent.
Alternatively, in the lua script if you sent text not caught in the switch statement it will just say that text
i.e. you could put in the lua script:
tcp:send("Hello, from Vera\r")

The IP address of 192.168.0.99 is the IP you have assigned to the Raspberry Pi. Obviously, this is set to whatever IP you have used.

I think that is everything but if you can't follow the steps or you feel I have missed something out, let me know.

Offline jrthomasii

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: Text to Speech
« Reply #10 on: June 05, 2013, 08:33:18 pm »
I just setup a RaspberryPi with xbmc and the following code, works great and took less than an hour to setup.


os.execute('curl -g http://10.10.10.2/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22id%22:%221%22,%22method%22:%22Player.Open%22,%22params%22:{%22item%22:{%22file%22:%22backdoor.wav%22}}}')

Offline pdipesh11

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-1
Re: Text to Speech
« Reply #11 on: April 17, 2017, 02:29:02 am »
hi, could it be possible for someone to post the raspberry pi setup in detail considering person don't know anything about raspberry pi and have basic knowledge of programming and setup

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9368
  • Karma: +704/-129
    • RTS Services Plugins
Re: Text to Speech
« Reply #12 on: April 17, 2017, 09:27:30 am »
I am trying to get  my Google Home interface (Vera Concierge) released to google.
It provided TTS to a Google Home.
I will be released an update to Vera Alerts to send messages to this.
It already supports TTS on Android devices.