Android text to speech cuts off another text to speech - android

so I have a 3 CountDownTimers. 2 of the timers have the same time set. 1 has a different time set. After all timers reach 0, they restart again.
Well after about 3 restarts, the timers catch up with each other.. which is fine... however, I have it set so that at the 20 second mark, Timers 1 & 2 say something in text to speech. And Timer 3 also says something at the 20 second mark. The problem is that the whole phrase is not spoken because they are cutting each other off.
Currently, in all 3 of the countdowns i'm using:
tts.speak("20 seconds remaining.", TextToSpeech.QUEUE_FLUSH, null);
is this problem occuring because i'm using the same TextToSpeech (tts) ?
or maybe it has something to do with QUEUE_FLUSH and null?
And also if I change QUEUE_FLUSH to QUEUE_ADD the text just keeps repeating so that won't work

I resolved this problem by using an onUtteranceCompleted callback that sets a boolean value to true when it's done speaking. This way, the voice doesn't get cut off.

Related

App Inventor - logic

This very simple code does not behave the way it should and I don't quite understand why.
App Inventor code:
When Button1.Click
#1 set Label1.Text to "Wait"
#2 call ProcedureXYZ
#3 set Label1.Text to "Done"
Here's the problem. ProcedureXYZ takes 5 seconds to complete. So Label1 should have displayed "Wait", but it does not. Instead, line #1, #2, #3 get executed simultaneously. In other word, it disappears for 5 second, and then "Done" is shown (that's because it immediately override "Wait").
So for 5 seconds, my app appears to be frozen until ProcedureXYZ completes its calculations. My question is, how do I display "Wait" when ProcedureXYZ takes 5 seconds to complete?
I try using clock to fire up the "Wait" message, but that does not work either. The only thing that work is to display an alert message, but I don't want popup message.
Why this in App Inventor does not work like that, is explained here:The model of event processing in App Inventor by Lyn
You will have to use a Clock component to do this, see pseudo code below. In the Designer, set a very small TimerInterval (for example 10 milliseconds) and set property TimerEnabled to false.
Button1.Click event
set Label1.Text to "Wait"
set Clock.TimerEnabled to true
Clock.Timer event
set Clock.TimerEnabled to false
call ProcedureXYZ
set Label1.Text to "Done"

Calabash - My device won't rotate

I'm discovering Calabash, using it with cucumber and I'm having an issue.
I started some code to test my basic app :
Scenario: I can see a button Test Button
When I enter "Something" into input field number 1
Then I wait
Then I press the "Test Button" button
Then I wait
Then I should see text containing "Something"
Then I go back
Then I rotate landscape
Then I wait for 5 seconds
Everything works fine and everything is passed until I arrive on the device rotation step. It just doesn't work (doesn't rotate) and is treated as an "undefined" instead of passed and the very last line gets "skipped"
The test ends like this.
I checked everywhere and just can't figure out why it doesn't work.
Could anyone help me please ?
As mentioned in comment - disable rotation lock.

textToSpeech.isLanguageAvailable returns different value 0 and -2

I have code to check isLanguageAvailable from TextToSpeech.
textToSpeech.isLanguageAvailable(locale);
The problem is the above line executed 2 times within 1 seconds. It returns 0 for the first time and -2 for the second time. Both the times textToSpeech, locale object is same.
Any idea on what circumstances it will behave like this.
Thanks in advance.
TextToSpeech engine got disconnected in the middle. Thats the reason for above mentioned scenario.

Countdowntimer works in short intervals, but not others

I am facing an interesting situation, maybe someone could explain to me why.
I am doing timer that runs at interval of 100 msec. At every tick, a textview is updated to show the time. Also there is a an edit text with a text watched in which the string is compared 2 times to different strings After each Text changed
When I use Timer class, then the thread seems to be busy because I can't type any text into the edit text . When I use handler same problem happens. But if I use countdowntimer class then it works.
Interestingly, if I increase the interval to 1 sec then all of the above works.
1-is 100 msec too short? I didint think the above computations I making would take that long.
2- why countdowntimer worked and other failed?
Thank you

AndEngine - setText on Text entity causing hiccups in first seconds

Imagine score counter made with Text() entity. Simple.
After I start a game, calling setText() causes launching a GC_EXPLICIT that slows down a game causing freezes, and after a few calls - problem disappears. Firstly I thought it's a problem with Strings and concatenation in Java, so I used a StringBuilder. The problem still exists. If I change setText("$" + score + "M") to simple setText("0") no hiccups are noticed!
The problem is in Font. Creation of Texture doesn't actually load characters to this Texture! All you need to do is after creating Font simply call:
pFont.prepareLetters("0123456789".toCharArray());
with all chars you need.
Occasional hiccups that were caused by GC_EXPLICIT were happening because Font in update() was explicitly calling System.gc(). Removing this line we were back on track below the green line, yeah! 60fps.
However, the author of AndEngine might had reasons for this explicit call. Since the stages are short we granted our app call this gc() when the GameScene is paused, quit or stage complete, anywhere where there is no excessive animation.
Preparing characters upfront did not sooth the hiccups, because the texts were dynamic and we could not prepare all possible characters to keep the System.gc() in this method, but honor it later.
Indeed preparing the letters upfront does not trigger GC_EXPLICIT, as it is described in the answer provided by the OP.
EDIT:
After some research, another thing that caused < 60fps, was the SoundPool, we should have playing a sound with volume 0f,0f and looping, in order to prevent the SoundPool reset to idle state and rearm again.

Categories

Resources