Raspberry pi TTS or play audio file

I have searched without success to see if anyone has come up with a TTS or other audio solution that works on a Raspberry pi. The idea is that the hubitat would send http post messages, and the pi would do the talking. I know that a lot of you use the Google Home Mini's, but that seems to defeat the purpose of being local. If the internet goes down, no notifications from the mini. I am also wondering about hosting images on a pi for dashboard backgrounds. I do not want to use web images. Again, it defeats the purpose.

Sending TTS from Hubitat is not completely local if it is a new phrase. Hubitat uses Amazon Poly to create the TTS messages. No TTS solution is going to be 100% local.

Any images or audio files you want to host on your pi should be hosted by a web file server. You have to be able to navigate to the image in a browser using standard HTTP addresses. Not FTP for FILE or anything like that.

I had a old moto Android phone laying around and put LANnouncer on it and added the driver code from one of the posters here. All my speech is local since I tide the headphone out jack to my NuTone intercom.

I gave the phone a static IP and then configured the device to talk to that static ip. I only use it for TTS and none of the other options such as alerts and chimes.

Thats a great idea

That will still require an internet connection unless the TTS message is one that has been cached by Hubitat as this will still use the Amazon Poly speech synthesis.

LANnoucer running on a Android phone uses local speech syntheses of Android OS. The phone is connected to my wireless network and it's fully blocked from the internet via my IoT policy rules. When I first set it up I factory reset the phone let it update it apps, installed LANnouncer and then blocked it. Also there is no SIM card in the phone.

I am using the web method with the device:

What driver are you using for Lannouncer?

The one I am using was from:

Tony McNamara

I had to make one modification to it to convert spaces in the text string to %20's in the URL call but that was all I fixed.

Do you have a link to it?

Here is the GitHub link to the repository that had his code:

Here if the function that I modified, The ToSay variable I removed spaces:

def speak(toSay) {
    log.debug "Executing 'speak'"
    if (!toSay?.trim()) {
        if (ReplyOnEmpty) {
            toSay = "Landroid Speech Synthesizer"
        }
    }
    
    toSay = toSay.replaceAll("\\s","%20")

    if (toSay?.trim()) {
        def command="&SPEAK="+toSay+"&"+getDoneString()
        sendCommands(command)

I'm curious as to why you modified it. What was the behavior and your solution?

I had to modify it because the request posted to the application on the phone is a web URL. You can't have spaces in the URL so the "\s" representation of a space and the "%20" is the URL representation of the space.

So if you have Hubitat safety monitor wanting to send a phrase this was necessary.

Hi @ronv42. I was wondering if you are still using lannouncer? I have tried it and realized that it seems that it goes to sleep after a while. I also found a thread about lannouncer and most people there had the same problem.

Also, if I disconnect internet, the HE can no longer say a new word or phrase. The old ones seems to be buffered.

Let me know what you have found. I’m looking for tts without internet, and not too expensive either. Old phone (and using my current one) is a great idea.

Regards
Guy

Yes if you are using a modern version of android the operating system will shut down background processes. There is an option to tell Android not to optimize the app but I don't remeber what version of Android that enabled that feature.
I am running it on a a older Moto G4 phone with stock Android I connected the audio out jack of the phone to the line in of my intercom and it still works fine. If I restart the phone for some reason, I make sure I launch the app manually just to be safe. One other thing I did was created a firewall rule on my network to keep the phone from calling home for software updates. Once you get it working you don't want any more updates.

Ok, that is great. I’ll search again in the settings for this shutting down the background processes. When I searched, could not find it. But ok if you say there is an option somewhere, I’ll find it.

I use the router to disable access to the internet to the old phone. I also disabled internet access to the HE. But then, this shows that HE requires internet for TTS. I’ll have to confirm with them if this is a requirement or a bug.

Thanks again.

That is super. Yes I found the setting in Android and it keeps working all the time now. Thanks.

Now I just need to find out if the fact that it requires internet to use tts is a bug or not. Wondering if @bravenel could tell us.

Thanks

1 Like

This is a old post but I also was searching for a script to do this. I Couldn't find one so I wrote one. No cloud is needed to use espeak on the pi. if anyone wants to test it its here.
https://github.com/tmastersmart/pi-talk

Hello.
I have someone who would like to have a PI with TTS Notifications, if it can be done on a purely local basis. I saw your post, and I see your github.
I'm not that experienced with Linux and pi's in general, but I'm going to give it a whirl and we will see how it goes.
Thanks for all your hard work on this matter
(I'm sure I'll have questions as I go forward, in advance, please excuse any simple questions. Although I have a lot of IT experience, my experience in the SBC area is quite limited.)