Bug or feature?

In the Color Text as SpeakLine Speaks It challenge, I found something interesting with the SpeechSynthesizer and I’m not sure if it’s a bug or a feature.

I started at the end of the challenge first and implemented the updateTextField function. I called the function in the most logical place, in the calculated isStarted variable declaration. When I run the program, the textField does not disable while the speech is occurring. However, when I put breakpoints in at the function call or within the function itself (and then click the continue processing arrow), THEN the text field disables until the speech completes. It then re-enables properly.

I tried moving the call to the function in other locations, but had no success no matter what I tried.

Either I need to implement a delay or there’s a sync problem. Note, the language I’m using is English.

Any ideas? This one has left me scratching my head.

I don’t know if technically it is a bug but it certainly isn’t a feature. I think the problem is that although the [color=#0000FF]speechSynth[/color] has been told to speak when [color=#0000FF]isStarted[/color] is set it hasn’t actually started speaking when [color=#0000FF]speechSynth.speaking[/color] is called. Try putting the call to [color=#0000FF]updateTextField()[/color] somewhere you KNOW that speechSynth is definitely should be speaking. You would also need put in another call somewhere you KNOW it should be finished speaking. There is probably a reason this part of the challenge was listed last.

Thanks. I actually played around like you suggested as I suspected it was a timing issue, but had no more success. Then I returned it to the original place and to my shock, it started working the way it was expected. Non-deterministic coding is all the rage. :smiley: :smiley: :smiley:

The fact that when the call to [color=#2B4EA0]updateTextField()[/color] is in the [color=#FF40FF]didSet[/color] of [color=#FF40FF]var[/color] isStarted the behaviour is erratic or ‘non-deterministic’ means that this is probably not a good place to put that call. It should be somewhere else, or eliminate the call to [color=#2B4EA0]updateTextField()[/color] and reliance on [color=#40BFBF]speechSynth[/color].[color=#BF80FF]speaking[/color] by placing the commands to [color=#40BFBF]textField[/color].[color=#8080FF]enabled[/color] = [color=#FF40FF]true/false[/color] in [color=#2B4EA0]updateButtons()[/color] (and maybe rename that function to [color=#2B4EA0]updateUI()[/color]).
In a previous life as a software tester I heard “but it works on my system” from developers way too much. It needs to work everywhere.

Ha, we shared past lives (both as a coder and a tester)! :smiley:

I spent quite a bit of time trying different methods, but to no avail. I did read that the SpeechSynthesizer module is documented to be problematic, so I’ve attributed the erratic behavior on that as I’ve run out of ideas. I’ve beaten the snot out of the application and it behaves consistently now, so I’ve marked that one done and have moved on.

Thanks again for your input!