SpeakTextAction: Text to Speech not working Retrying Once

chaoscreater

Active member
Has anyone seen an issue with macros using Speak Text? Sometimes, the text will be spoken really quickly and then the rest of the actions do not run. However, if I re-run the macro, it runs perfectly fine.

It almost seems like MacroDroid needs to first initialize text to speech and then subsequent speak text will be OK. However, this "initialization" needs to happen regularly and so it's not a one-time thing on each phone reboot. I mostly use speak text in the morning when I leave for work and in the evening coming home from work. So in between that time, it seems the text to speech needs to be re-initialized again.

Some of my macros use the Bluetooth Device Connected as a trigger. When my phone is connected to e.g. my car's bluetooth, the music audio stream is played through my car's speakers, not through my phone. This can be a problem because my car's audio is muted on startup by default. There can also be other situations where my phone could be connected to other bluetooth devices with no output, e.g. a headphone. Therefore, to be able to hear the spoken text, I need to use something like Ringer audio stream.

I noticed that it's mostly the Ringer audio stream that is causing this issue. I've tried other audio streams and they either do not speak the text using the phone's speaker, due to them already connected to a bluetooth device, or that the other audio streams produce the same issue.

My speech to text setting in MacroDroid is set to english and my Android setting is set to use Google TTS. I don't have any other TTS engines apart from just Google TTS.

I even tried to create a dummy macro with a single action "speak text". I then use this macro in the very beginning of my other macros. The idea is to trigger speak text in the dummy macro, which will probably produce the "Text to Speech not working" error in the log. Then my actual macro will run its own speak text and *should* work, but they don't.....

If I take out speak text completely, my macros run perfectly fine. However, I need to use speak text.
 
Last edited:

dsnz

Well-known member
I use TTS a lot and never had such an issue

remember to select options

1. Queue text if already speaking
2. Wait to complete before running next action
 

chaoscreater

Active member
I use TTS a lot and never had such an issue

remember to select options

1. Queue text if already speaking
2. Wait to complete before running next action
Done that already. I can replicate this issue on 2 different phones from different brands (Oppo and Xiaomi). Both phones are on Android 10 and 11 respectively.

Just to emphasize, if I re-run the same macro a 2nd time, it works perfectly fine. I can re-run it 15 times and it will work 14/15 times. The first attempt will fail because of that error message. It seems after that initial error message, MacroDroid will somehow be able to "initialize" TTS and use it properly in subsequent macro runs.
 

Jacob L

Moderator (Lawsonator)
Why not get it to say 1 letter at full speed so you hardly hear it as a workaround.
 

chaoscreater

Active member
Tried that already, even tried creating a new "dummy" macro to mute the volume and then say a dummy text, then adjust volume back to normal. Then, in the actual macro, have an action that runs the dummy macro first.

I'm still testing a few things atm, but so far none of the solutions I'm using are working very well....
 

chaoscreater

Active member
I'm currently using Ivona TTS as the default TTS engine. It's free to download and apparently was so good that Amazon bought them. You can still find the APKs available to download though.

I've also set the speak text action to run at full speed and again, this is created as a separate macro, so that my main macro will call it using "Run Macro". With these combinations, will see how things go...
 

Lupus52

Member
Done that already. I can replicate this issue on 2 different phones from different brands (Oppo and Xiaomi). Both phones are on Android 10 and 11 respectively.

Just to emphasize, if I re-run the same macro a 2nd time, it works perfectly fine. I can re-run it 15 times and it will work 14/15 times. The first attempt will fail because of that error message. It seems after that initial error message, MacroDroid will somehow be able to "initialize" TTS and use it properly in subsequent macro runs.
Hello,
I have nearly the same problem. In the startup-macro for my android car radio (Android 10) I use some textmessages between the actions. The first text will be spoken. And the macro stops. A errormessage (... not initialized...) is the last entry in the systemprotocol

The macro for speechinit (for testing) only has 3 actions

Speak text "dummy"
Wait 1 s
Speak text "dummy"

This should speek 2 times "dummy"


The last 3 logtexts in the systemprotocol are

Invoking macro Speechinit
Text ansagen (dummy) / Speechinit
Text to speech not initialized - attempting to re-initialise / Speedinit

The wait and 2. speechcommand are not done.
 

Attachments

  • 20211005_114709.jpg
    20211005_114709.jpg
    441.5 KB · Views: 9

MacroDroidDev

Administrator
Staff member
Please use the report a bug feature in the troubleshooting section of the app and share the relevant macro. I've never seen anything like this happening myself so I need as much info as I can get to look into this (which the report a bug feature will provide).
 

Lupus52

Member
Please use the report a bug feature in the troubleshooting section of the app and share the relevant macro. I've never seen anything like this happening myself so I need as much info as I can get to look into this (which the report a bug feature will provide).
Hello, I told you all I can say to this problem in the last post

Short: <g>

I have a new car-android-radio with android 10.
I have problem that some macros don't work correctly.
I found out, that "speek" is the problem

For more see my last post

Now I have reduced the post to one action "speek text"

The same - speechinitproblem like above

3 examples from today: Each time radio waked up with ACC-ON

11-10-21 08:48:55 - MacroDroid process has started
11-10-21 08:48:55 - Text to Speech not initialised - attempting to re-initialise
11-10-21 08:48:55 - Text ansagen (initialisiert)
11-10-21 08:48:55 - Invoking Macro: 1_initalisiert
11-10-21 08:48:55 - MacroDroid ist initialisiert

11-10-21 08:16:28 - MacroDroid process has started
11-10-21 08:16:28 - Text to Speech not initialised - attempting to re-initialise
11-10-21 08:16:28 - Text ansagen (initialisiert)
11-10-21 08:16:27 - Invoking Macro: 1_initalisiert
11-10-21 08:16:27 - MacroDroid ist initialisiert

11-10-21 07:47:40 - All cloud backups deleted
11-10-21 07:47:28 - Failed to upload to cloud backup: com.google.firebase.storage.StorageException: The operation retry limit has been exceeded.

11-10-21 07:46:37 - MacroDroid process has started
11-10-21 07:46:37 - Text to Speech not initialised - attempting to re-initialise
11-10-21 07:46:37 - Text ansagen (initialisiert) "initialisiert" is the text to speek.
11-10-21 07:46:37 - Invoking Macro: 1_initalisiert
11-10-21 07:46:37 - MacroDroid ist initialisiert (german message for MD is initialised)


I don't use any report features in an app of my car because it is not online.

I work with a normal computer where I have a normal screen and a normal keyboard. And therefore I write on this way

The second problem is, that MD often does not start when the radio is woken up from sleep with ACC-ON.
Sometimes it works, most time not. Today it worked for 3 times correctly. See above - 3 starts of the car.

With ACC-OFF the radio goes into a deep sleep mode. Not like a smartphone with dark display "sleeping" and doing things in the background like receiving mails, SMS and so on
The car-radio makes a shutdown like a windows-pc sleeping in energy-saving-mode and have saved the status and ram-content to disk
And starts in about 2-3 seconds after ACC on into the last used app.

What about the backup message above? There is no cloud to backup. Who starts this backup and why?
 

dsnz

Well-known member
it seems you don't have a normal Android environment (car radio with Android ? 🤔) the message of MD initializing again after 30 minutes is worrisome,
same for Text to Speech initialization (which is external to MD and not MD's responsibility)
from these messages I doubt that "The car-radio makes a shutdown like a windows-pc sleeping in energy-saving-mode and have saved the status and ram-content to disk" is the correct way this device operates, and you should research it's settings for some setting that will ensure uninterrupted MD and TTS operation (uninterrupted = not initializing again)
 

Lupus52

Member
it seems you don't have a normal Android environment (car radio with Android ? 🤔)
Never seen? It looks like a 7" tablet, build to fit in a 2-DIN-radio-box. Using and handling like a smartphone or tablet. Some extra-features like video- and sound in-/outputs for multimediaequipment, video-input for backdriving-camera e.t.c., GPS-Module with external antenna. Ebay or Amazon and all other media equipment companies are full.

the message of MD initializing again after 30 minutes is worrisome,
why? I started my car 3 times today in the morning. The Android therefore started 3 times from sleeping to running. And MD recognized this correctly today. But the speech-module makes a problem when calling the first time after wakeup.

I used my MD with my macros in the radio I had before. This had Android 5.1. And I changed now to a radio with Android 10

same for Text to Speech initialization (which is external to MD and not MD's responsibility)
I don't know how this works and who initializes the service or what I can do. When I start the macro to test manually, it works correct.
from these messages I doubt that "The car-radio makes a shutdown like a windows-pc sleeping in energy-saving-mode and have saved the status and ram-content to disk" is the correct way this device operates, and you should research it's settings for some setting that will ensure uninterrupted MD and TTS operation (uninterrupted = not initializing again)
There are no other settings, or I don't know where to look. I think I have searched in all possible places for any options
 

dsnz

Well-known member
I just pointed the obvious that if MD initializes every time the device is going from "sleeping" (as you say) to running then definitely it's not doing something like "saving ram content to disk" !
seems more like the deep sleep (ie. kill) of some phones
so, I suggest you see relevant posts by searching for "dontkillmyapp"
 

Lupus52

Member
I just pointed the obvious that if MD initializes every time the device is going from "sleeping" (as you say) to running then definitely it's not doing something like "saving ram content to disk" !

I don't know what happens exactly, I am no android-programmer or technician. When the radio is in use (ACC=ON), then it uses, depending on actual volume, about 0,7A or more on the power line. Switching ACC = OFF the screen gets dark, the current on the power line goes to about 0,5A for about 20 seconds. I think, this is the time when android saves all things to flash or SD-card without screen-illumination. Then the power goes down to equal or less than 0,00A. This is the same behavior like bringing a windows-PC to sleep.

Switching ACC=ON, the radio androidsystem starts in 2-3 seconds into the same state like it was before. Like waking up a smartphone.

I see this from user side What really happen is not my world.

The main problem is: MD starts through triggering by "Macrodroid ist initialisiert" (German APP). It does all, what I set as action in my Init-Macro.
All, but speakting correct. Errror with not initialized speech... .
seems more like the deep sleep (ie. kill) of some phones
so, I suggest you see relevant posts by searching for "dontkillmyapp"
I think, that "dontkillmyapp" belongs to an other problem. But I will read it again.
 

chaoscreater

Active member
Just realized I never replied to this thread. I've been using a workaround which seems to have worked so far:

1. Create Send Intent action with the following:
Action: android.intent.action.MAIN
Package: com.google.android.tts
Class: apps.speech.tts.googletts.settings.GetSampleText

2. Wait 50ms
3. Volume change (Notification 10%)
4. Wait 50ms
5. Speak Text (dummy) - set to high pitch and speed
6. Wait 50ms
7. Volume change (Notification 65%)
8. Speak Text (real text)

So basically, we run Google Speech to Text to make sure it is initialized before we use Speak Text. We then speak a dummy text and then finally our real text.

In MacroDroid settings, I've configured my Spoken Text Audio Stream and Play Sound Audio Stream to both use Notification.

I used to have an Action that sets the MacroDroid audio stream and language, but I don't use them anymore. I just use the default in the MacroDroid settings and all I do is adjust the volume for Notification stream (as per step 3 and 7). This seems to work OK for me.
 
Last edited:

quangtien

New member
Just realized I never replied to this thread. I've been using a workaround which seems to have worked so far:

1. Create Send Intent action with the following:
Action: android.intent.action.MAIN
Package: com.google.android.tts
Class: apps.speech.tts.googletts.settings.GetSampleText

2. Wait 50ms
3. Volume change (Notification 10%)
4. Wait 50ms
5. Speak Text (dummy) - set to high pitch and speed
6. Wait 50ms
7. Volume change (Notification 65%)
8. Speak Text (real text)

So basically, we run Google Speech to Text to make sure it is initialized before we use Speak Text. We then speak a dummy text and then finally our real text.

In MacroDroid settings, I've configured my Spoken Text Audio Stream and Play Sound Audio Stream to both use Notification.

I used to have an Action that sets the MacroDroid audio stream and language, but I don't use them anymore. I just use the default in the MacroDroid settings and all I do is adjust the volume for Notification stream (as per step 3 and 7). This seems to work OK for me.
I have the same issue and will try your solution, hope it solve mine.
Thank you.

PS: I have just tried and test its action but get error as below
"Unable to find explicit activity class {com.google.android.tts/apps.speech.tts.goooogle.settings.GetSampleText}; haveyou declared this activity in your AndroidManifest.xml, one does your intent not match its declared <intent-filter>?''

Could you share your setting?
1677033828763.png
 
Last edited:
Top