GoogleTTS responding with 503 error (even after the URL fix)

I’ve been playing with this as well over the last few days. I’m quite happy with the pico2wave results. I did this with a rule instead which I’ll share for those interested. Again pico2wave and lame need to be installed. First a lambda expression to replace squeezeboxSpeak

val org.eclipse.xtext.xbase.lib.Functions$Function3 squeezeSay = [
    String playerID,
    String message,
    int volume |
            executeCommandLine("pico2wave@@--wave=/tmp/openhab.wav@@"+message)
            Thread::sleep(500)
            executeCommandLine("lame@@-V2@@/tmp/openhab.wav@@/tmp/openhab.mp3")
            Thread::sleep(500)
            squeezeboxPlayUrl(playerID,"/tmp/openhab.mp3",volume) ]

then just replace squeezeboxSpeak with squeezeSay.apply ie:

squeezeSay.apply("mainPlayer","My Message",20)

Make sure the directory you use (in my case /tmp) can be reached by both openhab and the logitech media server. If openhab is running on a faster computer, you may be able to decrease the sleep times. The only downside is that squeezeboxPlayUrl does not have a resume function.

I have just create a pull request with some changes to the Squeezebox io and action bundles to allow TTS URL configuraton. Note that I have removed the language config option as this is just a parameter in the TTS URL. The URL just needs a single %s parameter which is substituted with the text to be translated. I have also updated the openhab_default.cfg with details about the new configuration options.

1 Like

Using these updated Squeezebox io and action bundles, along with my tts.php script from above, I now have entirely local TTS notifications with no reliance on any cloud services.

Ben, how is the lag time doing it locally? Do you have the tts on the same box as openhab or another local network box?

The delay is barley noticeable using my local TTS service, my notifications are almost instant now. I am running the TTS service on a different VZ container than the openHAB container (but on the same physical host).

FYI - my changes to the Squeezebox action have been merged so if you grab the latest SNAPSHOT build you can test these changes out (you will need both the io.squeezserver and action.squeezebox bundles).

Added a page to the WIKI with these details;

3 Likes

What changes are needed to make openHAB use the new TTS provider for rules and such? I have the setup working as you describe. I can test TTS with success in my browser passing the URL example you have given, but when I define my Google TTS url within openhab.cfg, it doesn’t seem to work. I do get audio, but it seems to be only the last file or test I used via the browser test example and not the actual strings being passed by openhab. For example, I have a test rule to fire every 2 mins and announce the time. when it runs now, it repeats “hello” as used in the test string: http://172.16.0.51/tts/tts.php?lng=en-GB&msg=Hello.

I can see the following in the logs when I intentionally make it throw an error:

2015-12-29 16:12:00.057 [WARN ] [.i.m.i.tts.TTSServiceGoogleTTS] - Error while connecting to Google translate service
java.io.FileNotFoundException: http://172.16.0.51/tts/tts.php?lng=en-GB&msg=en

This shows me it’s only passing “en” to the server and not the actual string.

Any thoughts or insight would be awesome! Thanks!

The Google TTS service substitutes two parameters into the URL - the first is the language (defaults to ‘en’) and the second is the text to be spoken.

So you will probably need to update your TTS URL to;

http://172.16.0.51/tts/tts.php?lng=%s&msg=%s

And then specify your Google TTS language as en-GB.

That did the trick! I thought I had tried it specified like that, but maybe not. In any case, it’s working like a charm. Many thanks!

I’m really pleased with the new local TTS solution Ben has described. It’s running quite well for the last four days. Thanks!

1 Like

yeah, this is huge in my opinion. I never liked the idea of TTS relying on the cloud. All the other solutions just don’t sound polished enough. I utilize TTS over “whole home audio/multi zone audio” and it has been less then ideal with the previous setup.

If anyone is curious, a fella named Mat who wrote up a really cool bit about a $40 rack mount, 12x12 input/output audio control device called the XAP 800. It ties perfectly into openHAB, and facilitates room by room voice control with it’s “gating” features and GPIO :slight_smile: Think killing music playing to play an alert or notification among other things…
Here’s the link: http://hazymat.co.uk/2015/04/multi-room-audio-options/.

With TTS working much better now, and some good zoned audio/voice control, my home is really starting to sound and work like a smart home lol.

Yep @hazymat has done some pretty awesome work, in particular with Squeezeboxes + openHAB. His MQTT based wall controller is very cool - check out his blog for more details.

I have been using the local TTS service for about a week now and am finding it very good. Can’t see me ever going back to a cloud based service now.

Glad others are finding this useful as well.

1 Like

Thanks for the mention @ben_jones12! Wow - local TTS using Squeezebox? This is awesome. My announcements using Google TTS were reliable for a while, then less-so, then altogether stopped working - I couldn’t be bothered to look into it, but I shall use this. Thanks for your excellent work!

@jbags81 (and others) may be interested to know that I didn’t end up using the GPIO port of the XAP, but rather I’m using the serial port, and addressing it from OpenHAB. Haven’t written this up on my blog yet, but I’ll paste below an example config for addressing the XAP from OpenHAB.

You need a USB to serial (RS232) cable, I got mine for a couple of quid on eBay.

The below is quite basic, it simply switches the audio input for a given zone (in this case the bedroom) from one stereo source to another.

There are four commands in the rule for each time I switch an audio source, see rule below. Imagine a matrix with an x that marks a mapping. Each time you switch an output you need to remove an x from the matrix, and add an x elsewhere. That’s two actions. Then times by two because it’s a stereo source.

Check out Appendix E of the user guide (http://www.clearone.com/uploads/resource/800_151_101_Rev4_1_XAP800Man.pdf)

I set up the XAP using the Windows software so that it had device number 1. The format in the above doc says you need to feed it with this:

#DEVICE COMMAND [X] [X]

#DEVICE = 51 = the device type of the XAP800 which is always 5, and the device number you set (i.e. 1 in my case)

The command is MTRX, meaning you want to edit the matrix, i.e. you want to map or unmap something to / from something. The MTRX command is documented on page 118, that’s how I came up with the below.

OpenHAB settings:

Items:
Number Bedroom_Audio_Source
String XAP800

Rules:
rule “Bedroom Source”
when
Item Bedroom_Audio_Source received command
then
switch(receivedCommand) {
case 0 : {
sendCommand(XAP800, “#51 MTRX 11 I 1 O 1 \n”)
sendCommand(XAP800, “#51 MTRX 12 I 2 O 1 \n”)
sendCommand(XAP800, “#51 MTRX 9 I 1 O 0 \n”)
sendCommand(XAP800, “#51 MTRX 10 I 2 O 0 \n”)
}
case 1 : {
sendCommand(XAP800, “#51 MTRX 9 I 1 O 1 \n”)
sendCommand(XAP800, “#51 MTRX 10 I 2 O 1 \n”)
sendCommand(XAP800, “#51 MTRX 11 I 1 O 0 \n”)
sendCommand(XAP800, “#51 MTRX 12 I 2 O 0 \n”)
}
}
end

By the way, @ben_jones12 does pico2wave need to be installed on Linux to make this work? My OH server is Win. I have a spare RPi which I could dedicate to TTS (and maybe other things later…)

Hmm - not sure about Windows sorry - there may well be other TTS services you can use on Windows, in the same way I have done with that little PHP script.

Otherwise a RPi with a simple Apache web server running pico2wave should do the trick. I am sure you can think of a few other uses for the Pi as well…

I assume you can run the TTS service on the same box as openHAB and forego the PHP server?

If you want to use it with a Squeezebox you need a URL for the SqueezeServer to play. This is the reason for the PHP script. And Squeezebox can’t play WAV files directly, hence the need to convert to MP3 using lame.

Hi,

I’ve created a simple REST service with C# to use the build in TTS from Windows (I use it on Win 10 - but should work on 8 as well). Source code and bin is available:

https://dl.dropboxusercontent.com/u/1781347/RESTTTS.zip

openhab.cfg:
squeeze:ttsurl = http://192.168.10.100:8089/Service/TTS?text=%s
squeeze:ttsmaxsentencelength = 4096

Port and IP needs to be configured in the the “RESTTTS.exe.config” as well.

At the moment it is only optimized for my needs; thus uses the os default language - but if required it should be easy to add additional languages, voices as configuration parameter.

Would be glad if it is usefull for you as well :smile:

Note: you need to start the .exe with administrator rights - else you’ll get an exception.

1 Like

Very Nice! sticking to serial keeps things easy. I might even try adding an arduino or other micro controller to simply “receive” commands sent from openHAB.

@patrik_gfeller Great work, thank you. You mentioned it uses the OS default language- mine (Win10) is defaulting to Microsoft Susan Mobile which is rubbish. Would it be easy for me to change that? To be honest I have struggled to get other TTS voices in Win10, I followed this Superuser.com post to install Speech Platform v11, but couldn’t import the registry entries (I get an error about them being in use). I know it’s nothing to do with your .exe but wondered if you’d had experience with this?