Check for TTS cache file

TL;DR;
I want to check if there is already a cache TTS file for my sentence. This shouldn’t be too hard to write in python, but there likely are people that are way better in creating that than I am. So, before I create a script i wonder if someone has a script that checks the availability of the TTS file and returns the result?

Full story
Based on the situation I like to increase the volume of a speaker during the TTS. The situation, when a member of a group that I can unjoin or when the speaker isn’t playing anything.
For as far as I know it’s not possible to detect if TTS is finished talking, so I calculate 0.51s per word, rounded to ‘ceil’ if the text is cached, and 0.8 when it’s not cached (in my case when I cache=false).

I like to catch the scenario in which cache=true, but the file is not already there. For as far as I know, there is no build in check for the cache file that “we” can use and since the filename is build using a SHA1 of the sentence with a postfix, this shouldn’t be too hard I guess.

I aim to write a script with the inputs sentence and postfix and that returnes true/false depending on the availability of the file.

I am planning this for the weekend and once succeeded I will of course post/share the result for feedback and for others to use.

You can use the custom Chime TTS integration which can be used to set the volume of the media_player for the notification, and return it back after it finishes.

Interesting. I did a quick read and believe it’s meant for the cloud TTS. Since I do local TTS, this might not work, but I will have a closer look later today.

Chime TTS works with TTS providers and is not a TTS platform itself. It works completely locally (unless you use it with a cloud TTS platform).

So it’s “compatible” with local Piper is TTS provider. Nice, the more reason to give it a close look. Thanks!

Well, I had a look at the chime.tts and it’s a great add-on but it creates too much refactoring to make it work. The reason is that it changes the player its state. That triggers a small chain of automations that I am not willing to refactor.

So when it starts raining again, I’ll spend a raining afternoon to see if I can build a proper python script that checks on the existence of the TTS file.