2017-01-02 19:07:32

Hi, so I built the  dice game pig as an audio game with pygame and accessible_output2. I built a simple AI that would hold the turn total
if it fell into a randomly generated range. I was having some problems though, because the sounds and screen reader were overlapping, so I used

pygame.time.delay(t)

to delay for a specific amount of given time. After messing with the time for a while, I finally got it so that there were delays around the sounds such that the screen reader would not start talking while the sound is playing. I realized then that this was a poor solution because It was time delayed based on the rate of my screen reader, as soon as I slowed NVDA down, I had the same problem as before and all the delays were in the wrong places.

Is there a better solution to use so that sounds don't play until after a screen reader has stopped speaking?

TJ Breitenfeldt

2017-01-02 19:45:46 (edited by visualstudio 2017-01-02 19:46:37)

write your code like this:

while(Tolk_IsSpeaking())
{
sleep(100);
}

i've wrote an example using Tolk with C++ for you, it is totaly up to you, but you must write it like this
sorry, python is not my main language and i dont know anything about accessible_output

2017-01-03 07:24:59

This is not going to work in practice because nothing except sapi5 can tell you whether the screen reader is speaking or not. This problem has existed for a long time, with no good solution.

2017-01-03 07:33:38

I didn't think it was really possible, so what is a better solution, just turning down the sound of my sound effect? Is this really the only possible solution, also, that doesn't solve my problem of NVDA getting behind on the game messages, and the game starts moving faster than NVDA can read the message.

2017-01-03 17:34:38

this is the best thing that you can do, you cant really know when screen reader stopped speaking

2017-01-03 19:11:06

I suppose I could record the messages I want spoken by NVDA which would solve the issue, but not very elegantly. I could also use a screen reader specifically for this game. How would I go about doing that? I know games like sound RTS use its own screen reader. I downloaded the source code for sound rts, and located where the speech functions were, but  I didn't understand them though.

Are these the solutions people are using to build there games? or are there other ways of getting speech and forcing the timing of the speech output to be spoken at the correct time?

2017-01-03 19:54:06

you can record them, and check if the sound finished playing, continue the game

2017-01-04 01:39:20

In the common case there's just not really anything you can do since most screen readers don't provide any way to query whether or not they are speaking.

2017-01-04 03:54:05

So are most people who are developing games using one of the two solutions when faced with this problem? Either use recorded messages, or use a screen reader with a fixed speaking rate.

2017-01-04 05:00:03

Honestly, I think the best method you're currently going to find is the one that Manamon uses. Basically, speak a sentence or short block of text, then wait for the user to press enter before continuing. This does mean more keypresses for the user, but until the screen reader manufacturers give us a way to tell when their products are talking, I don't think you'll find a better solution.

2017-01-04 06:43:12

The manamon solution is painful. A better solution is a heuristic that you use to estimate whether the screen reader has finished speaking or not. For example, based on the length of the text being spoken. That's what Sound RTS does.

2017-01-04 21:35:45

Victorious's suggestion sounds more appealing to me than creating more key presses. Especially since this is my first audio game, and it is very simple right now. It is just the dice game pig, and you press enter on the game in the menu and it starts a game against a computer. If the player is having to press enter for the computers rolls,, it takes away the idea of playing against someone else and feels like you are playing against your self. I know this is a really basic game so it doesn't matter that much, but I want to find a good solution so I can use in other games.

I thought about recording my messsages, but I realized that I could not account for variables without recording every potential message spoken to the player and then doing checks to see and play the right message. That just seems like more work than it is worth.

Can you explain more Victorious about what you are talking about and possibly give an example?

2017-01-04 23:33:03

@victorious, it depends on screen reader's rate then to calculate text length

2017-01-05 02:45:41

You can ask the user to set their speech delay with a sample line of text.When the line of text is finished, the user hits the spacebar to let the application know that's how long it took the text to speak. Then this time is divided by the length of text to get an approximation for the average time per character. You will need to then refine this text length: make a formula for defining character length, for example you will want to add some amount of extra length for pauses in punctuation and remove length for doubled letters that don't actually  make the word longer, such as dd, sh and wh.You will also want to nullify addition of length for spaces and punctuation that does not pause the speech such as - or _ in order to get high accuracy. Then you will probably want to also make a way for it to decide how long numbers are, since a single number is equivalent to a full word of some number of characters if it were to be written as text. Then once your text length has been calculated, multiply it by the time it takes to speak a single character and wait that long.

I like to sleep, Sleep is good,
This is how I do it: Lie on a nice warm cozy bed, and dream dreams about how to rule the world!
Follow @TheGreatAthlon5 on twitter for humorous facts and game updates!
If you like my posts, thumb me up!

2017-01-09 06:52:14

So, I think I am going to switch to using pyttsx. It seems to provide much more control from the developers end. Everything I have learned about it so far, I think it will make timings easier to manage.