I just added another useful tool to the home control arsenal – speech – not on the PC but on my phone. As regular readers know I use ImperiHome a lot – talking directly to Node-Red to control stuff – and that’s fine – it works – it’s not the only package – I also use Blynk. I just found another reason to concentrate on ImperiHome.
Today I discovered what the “API http server” in ImperiHome is for, at least, one use for it. You don’t normally need this with Node-Red as the phone talks to the Node-Red http link and that’s all that is needed. However I was aware that there was a TTS Engine available in ImperiHome but had never taken the time to find out what it could do.
Now I know. You can fire text at the API from Node-Red and it will speak the text, even when the phone is sitting idle and it sounds ok!!
So the first thing you need to know - in SETTINGS, GENERAL PREFERENCES in ImperiHome, tick the API server.
You need to know the IP address of your phone - so that kills using this outside of the house or office unless someone can think of a wheeze. You should ideally do an IP-MAC binding on your router to ensure the phone always get the same internal address when on the WIFI.
And with that done, you’re almost up and running. In Node-Red you need this simple SUBFLOW – create a new sub-flow, call it “My phone” for want of a better name and create this.
msg.url="http://192.168.1.31:8080/api/rest/speech/tts?text=" + msg.payload;
That’s it – you’re done. Whatever you send in the payload to that sub-flow will speak on the phone. Couldn’t be easier. Oh, that IP address – that needs to be the IP address of your phone.
June 2, 2016: I have found a slight bug. So you can let the phone go idle and run other tasks – the speech continues to work – but if you go out of signal area, perhaps onto a mobile network then come back in – noting that the mobile signal is now off and you are on the same IP address, no speech. Bring the app to the foreground – the speech comes back. I reported it and for once got quite a quick response – they think it might be Google power management shutting the API down – so looks like some re-writing may be in order.. will have to wait and see but at least they’re aware of it.