samtupy / nvgt

The Nonvisual Gaming Toolkit
https://nvgt.gg
Other
42 stars 27 forks source link

macOS: speak() doesn't work and libraries aren't copied over #16

Open patricus3 opened 1 month ago

patricus3 commented 1 month ago

hi. I tried to use nvgt and wrote some code, just for testing purposes, everything compiles fine, I can't run it until I put necessary libraries into the folder though, and also there's an issue with the speak() function.

samtupy commented 1 month ago

Hi, our voice over implementation requires that a window be shown in order to produce speech. This is a limitation of Apple's API and not something we can easily work around in the short term. Can you please try showing a window first and make sure it displays before speaking text?

patricus3 commented 1 month ago

don't use voiceover for speech output, queueing isn't working there because apple is apple

samtupy commented 1 month ago

You can see src/macos.mm to see how we got around that lack of queuing issue, it works in all basic scenarios where several speech events are sent in a constant stream. The fix we applied does not of course make it work entirely E. only queued events within 10ms of each other can speak properly, but it is actually enough to be quite usable in most games that don't just randomly speak things. I wouldn't even use that accept apparently AVSpeech broke whatever option lets you use the user's current voice over settings. We still plan to wrap AVSpeech (just have not gotten to it yet), however we want to keep voice over support working which will give users the option of their current VO settings with slightly broken speech queuing, or else not use their screen reader settings while having working non-interrupting speech events by selecting AVSpeech. So in short, neither are ideal. The result is that we plan to implement both, but have only gotten around to one of them so far. BTW as for the libraries not copying when you compile an executable if that's what you are talking about, this is currently an issue on all platforms and I need to decide how I want to resolve that issue. On one hand, copying the libraries to the location of a compiled executable would be convenient as it would run immediately, but on the other hand it could clutter people's dev environments a little and so for that reason, it would be better for us to find a way to add the install path for NVGT as an rpath entry in the compiled executable so that on your dev machine the program would directly run, and if you distribute your app to somebody you would then copy the libraries or we could add a -b --bundle option to nvgt's command line that would perform this task. Hopefully that helps clarify our stance/current position on these things. It was a bit unclear from your comment whether nvgt compiled fine from source or whether your nvgt app compiled into an executable where you then needed to move libraries, I'm assuming the latter unless told otherwise.

patricus3 commented 1 month ago

I don't know C/C++ so I can't help. and, also, I tried to make a window, and it didn't worked, like, at all.

samtupy commented 1 month ago

That is not helpful without extra information, an example, something. Creating a window on macOS has worked for everybody thus far. What didn't work, creating a window or speaking with VO? Was the window showing on screen by the time the text spoke? If you wrote something like:

void main() {
show_window("test");
screen_reader_speak("hello", true);
}

This of course won't work because the window can't even show before the application exits. Thus, are you speaking text from within the context of a game E. showing a window and speaking in response to a keypress or something?

patricus3 commented 1 month ago

I also add wait to wait 5 ms, I use it in the main context, without any key presses

samtupy commented 1 month ago

Yeah that's why, the VO speech really does only work in a game context. You need to actually open a loop and wait for the window to focus, then and only then will VO speak text. The window will absolutely not appear within 5ms after the show_window call, not even 100ms after. You need to create a loop and wait for the user to press escape, then you can speak. As an example, right now if I run stw on macos, the main menu text is not spoken because the main menu launches before VO registers the existence of the new window. Once VO tells me that I'm in the Survive the Wild window though, I can then safely up and down arrow through my main menu and get consistent speech.

samtupy commented 1 month ago

Here, does this break for you in any way? I apologize for any compilation errors as I wrote the code specifically for the issue here.

void main() {
    show_window("test");
    while(!key_pressed(KEY_ESCAPE)) { // Does not need to be escape, can be anything
        wait(5);
        if (key_pressed(KEY_SPACE)) screen_reader_speak("hello", true);
    }
}
patricus3 commented 1 month ago
works, but sometimes you want it to say something on game start, and, well...
patricus3 commented 1 month ago

ah ah ok also, I see that there's dynamic menu include that isn't documented yet, and, you mentioned stw on macOS, I don't see it on the website. could I have a link to test it?

peter1384 commented 1 month ago

@patricus3 LOL, I think that @samtupy said stw for MakOS as an example for you to understand the point, There is currently no STW for MakOs.

samtupy commented 1 month ago

We can talk about anything stw beta related outside of NVGT's github issues as: 1, that could quickly get off topic and 2, if you ask for the stw beta and I give it to you, others will do the same and soon loads of people will be asking for a beta that I have obviously chosen to not release yet. Thanks for the interest though, I'm certainly excited to get to a release ready point with that!