Interruption of speech


Rui Fontes
 

Hello!


I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?


Rui Fontes


Héctor Javier Benítez Corredera
 

Hello Rui.

Hera to ask if you were given any solution or way to do it.

If not, I add me to your request.

Greetings

El 09/01/2022 a las 3:50, Rui Fontes escribió:
Hello!


I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?


Rui Fontes






Rui Fontes
 

No, no solution yet...


Rui Fontes


Às 18:30 de 10/01/2022, Héctor Javier Benítez Corredera escreveu:

Hello Rui.

Hera to ask if you were given any solution or way to do it.

If not, I add me to your request.

Greetings

El 09/01/2022 a las 3:50, Rui Fontes escribió:
Hello!


I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?


Rui Fontes









Lukasz Golonka
 

Hello,

On Sun, 9 Jan 2022 02:50:03 +0000
"Rui Fontes" <rui.fontes@tiflotecnia.com> wrote:

I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?

Not really. Perhaps if you would describe your entire problem it would
be possible to propose a solution.

--
Regards
Lukasz


Stefan Moisei
 

Hi,
since no one answered, I'll try.
I guess you could define a focus gained event and delay its propagation until the mesage has been spoken. you could use a callback speech command to find out when the mesage has finished speaking.

------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 09.01.2022 04:50:03
Subject: [nvda-addons] Interruption of speech

Hello!


I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?


Rui Fontes







Rui Fontes
 

Hello!


When a specific group of keystrokes is pressed, it is fired a gainedFocusEvent...

And I need to make audible a message before the fired event...


The keystrokes force another control of the same window to get the system focus, and the correspondent messages of that control are fired so quickly the message prior is not reproduced...


I can put a delay, but the message will not be always with the same length, so I may end with a pause between the message and the get system focus messages and that is not desirable...


Stefan, can you gave me some example of your suggestion?


Rui Fontes




Às 22:13 de 10/01/2022, Lukasz Golonka via groups.io escreveu:

Hello,

On Sun, 9 Jan 2022 02:50:03 +0000
"Rui Fontes"<rui.fontes@tiflotecnia.com> wrote:

I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?
Not really. Perhaps if you would describe your entire problem it would
be possible to propose a solution.


Stefan Moisei
 

Hi Rui,
would some pseudocode suffice, or do you want a working example?
thanks.

------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 12.01.2022 21:01:18
Subject: Re: [nvda-addons] Interruption of speech

Hello!


When a specific group of keystrokes is pressed, it is fired a gainedFocusEvent...

And I need to make audible a message before the fired event...


The keystrokes force another control of the same window to get the system focus, and the correspondent messages of that control are fired so quickly the message prior is not reproduced...


I can put a delay, but the message will not be always with the same length, so I may end with a pause between the message and the get system focus messages and that is not desirable...


Stefan, can you gave me some example of your suggestion?


Rui Fontes




Às 22:13 de 10/01/2022, Lukasz Golonka via groups.io escreveu:
Hello,

On Sun, 9 Jan 2022 02:50:03 +0000
"Rui Fontes"<rui.fontes@tiflotecnia.com> wrote:

I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?
Not really. Perhaps if you would describe your entire problem it would
be possible to propose a solution.




Cyrille
 

Hello all

I am not personnally interested in this topic.
But FYI, it is discussed in NVDA's issue #13031. It does not seem that there is a way today to achieve this.

Cheers,

Cyrille

-----Message d'origine-----
De : nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> De la part de Stefan Moisei via groups.io
Envoyé : mercredi 12 janvier 2022 22:36
À : nvda-addons@nvda-addons.groups.io
Objet : Re: [nvda-addons] Interruption of speech

Hi Rui,
would some pseudocode suffice, or do you want a working example?
thanks.
------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 12.01.2022 21:01:18
Subject: Re: [nvda-addons] Interruption of speech

Hello!


When a specific group of keystrokes is pressed, it is fired a gainedFocusEvent...

And I need to make audible a message before the fired event...


The keystrokes force another control of the same window to get the system focus, and the correspondent messages of that control are fired so quickly the message prior is not reproduced...


I can put a delay, but the message will not be always with the same length, so I may end with a pause between the message and the get system focus messages and that is not desirable...


Stefan, can you gave me some example of your suggestion?


Rui Fontes




Às 22:13 de 10/01/2022, Lukasz Golonka via groups.io escreveu:
Hello,

On Sun, 9 Jan 2022 02:50:03 +0000
"Rui Fontes"<rui.fontes@tiflotecnia.com> wrote:

I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?
Not really. Perhaps if you would describe your entire problem it would
be possible to propose a solution.




Rui Fontes
 

I think that some pseudo-code will suffit...



Thanks in advance!


Rui Fontes


Às 21:35 de 12/01/2022, Stefan Moisei via groups.io escreveu:

Hi Rui,
would some pseudocode suffice, or do you want a  working example?
thanks.
------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 12.01.2022 21:01:18
Subject: Re: [nvda-addons] Interruption of speech

Hello!


When a specific group of keystrokes is pressed, it is fired a gainedFocusEvent...

And I need to make audible a message before the fired event...


The keystrokes force another control of the same window to get the system focus, and the correspondent messages of that control are fired so quickly the message prior is not reproduced...


I can put a delay, but the message will not be always with the same length, so I may end with a pause between the message and the get system focus messages and that is not desirable...


Stefan, can you gave me some example of your suggestion?


Rui Fontes




Às 22:13 de 10/01/2022, Lukasz Golonka via groups.io escreveu:
Hello,

On Sun, 9 Jan 2022 02:50:03 +0000
"Rui Fontes"<rui.fontes@tiflotecnia.com>  wrote:

I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?
Not really. Perhaps if you would describe your entire problem it would
be possible to propose a solution.







Stefan Moisei
 

hello,
sorry for the delayed reply. I wanted to find out how could you intercept messages, but I didn't manage to. I hope those instructions would be enough.
First, you would have to find out what function to hook in order to get notified when your target messages are spoken. You can use Cyrille's excelent addon for that:
https://github.com/CyrilleB79/NVDA-Dev-Test-Toolbox
create a variable to indicate whether messages are being spoken
messageSpeaking=False
and a queue of delayed focus events, to be executed after your messages end speaking
delayedEvents=[]

def gainFocus(obj, nextHandler)
{
if obj is what you want:
{
if messageSpeaking
{
delayedEvents.add(nextHandler)
}
}
}
both ifs will have an else branch running nextHandler imediatly
then, in the function which speaks messages,
def speakMessageHook(msg):
{
if msg is what you want
{
messageSpeaking=True
speech.speak(msg, speech.commands.CallbackCommand(callback=speakDelayedEvents))
}
}
def speakDelayedEvents
{
messageSpeaking=False
for e in delayedEvents:
{
e()
}
delayedEvents.clear()
}
Hope it helps. I'm not a very good explainer, ask if you have more questions.

------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 13.01.2022 02:26:48
Subject: Re: [nvda-addons] Interruption of speech

I think that some pseudo-code will suffit...



Thanks in advance!


Rui Fontes


Às 21:35 de 12/01/2022, Stefan Moisei via groups.io escreveu:
Hi Rui,
would some pseudocode suffice, or do you want a working example?
thanks.
------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 12.01.2022 21:01:18
Subject: Re: [nvda-addons] Interruption of speech

Hello!


When a specific group of keystrokes is pressed, it is fired a gainedFocusEvent...

And I need to make audible a message before the fired event...


The keystrokes force another control of the same window to get the system focus, and the correspondent messages of that control are fired so quickly the message prior is not reproduced...


I can put a delay, but the message will not be always with the same length, so I may end with a pause between the message and the get system focus messages and that is not desirable...


Stefan, can you gave me some example of your suggestion?


Rui Fontes




Às 22:13 de 10/01/2022, Lukasz Golonka via groups.io escreveu:
Hello,

On Sun, 9 Jan 2022 02:50:03 +0000
"Rui Fontes"<rui.fontes@tiflotecnia.com> wrote:

I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?
Not really. Perhaps if you would describe your entire problem it would
be possible to propose a solution.











James Scholes
 

@Rui

There may be an easier way to do this, that is less likely to break/slow down NVDA in strange ways and will work for braille users too: change the name of the object that is to receive focus, to prepend your message to it. Then, once it has received focus (or at some other appropriate time), set the original name back again. Or, place focus on an object with your message as its name, then onto the target object afterwards, allowing NVDA to create a natural speech sequence (may not work with braille).

However, for what it's worth, there is almost certainly a better design to achieve what you're attempting, than requiring a message to be spoken at a certain time anyway. You haven't indicated exactly what you're aiming for other than in abstract terms, so it's impossible to say what. But simpler is better, and you shouldn't rely on timing that you don't control. There are many, many possible bugs by trying to intercept speech events and act on their timing, particularly when you're trying to act on speech coming to an end. For instance, what happens if the user has "no speech" selected, or speech mode set to off? What about speech mode beeps? What if something else, like an alert from another app, interrupts your message in the middle?

Regards,

James Scholes

On 17/01/2022 at 12:49 pm, Stefan Moisei via groups.io wrote:
hello,
sorry for the delayed reply. I wanted to find out how could you
intercept messages, but I didn't manage to. I hope those instructions
would be enough.
First, you would have to find out what function to hook in order to get
notified when your target messages are spoken. You can use Cyrille's
excelent addon for that:
https://github.com/CyrilleB79/NVDA-Dev-Test-Toolbox
create a variable to indicate whether messages are being spoken
messageSpeaking=False
and a queue of delayed focus events, to be executed after your messages
end speaking
delayedEvents=[]

def gainFocus(obj, nextHandler)
{
if obj is what you want:
{
if messageSpeaking
{
delayedEvents.add(nextHandler)
}
}
}
both ifs will have an else branch running nextHandler imediatly
then, in the function which speaks messages,
def speakMessageHook(msg):
{
if msg is what you want
{
messageSpeaking=True
speech.speak(msg,
speech.commands.CallbackCommand(callback=speakDelayedEvents))
}
}
def speakDelayedEvents
{
messageSpeaking=False
for e in delayedEvents:
{
e()
}
delayedEvents.clear()
}
Hope it helps. I'm not a very good explainer, ask if you have more
questions.
------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 13.01.2022 02:26:48
Subject: Re: [nvda-addons] Interruption of speech

I think that some pseudo-code will suffit...



Thanks in advance!


Rui Fontes


Às 21:35 de 12/01/2022, Stefan Moisei via groups.io escreveu:
Hi Rui,
would some pseudocode suffice, or do you want a working example?
thanks.
------ Original Message ------
From: "Rui Fontes" <rui.fontes@tiflotecnia.com>
To: nvda-addons@nvda-addons.groups.io
Sent: 12.01.2022 21:01:18
Subject: Re: [nvda-addons] Interruption of speech

Hello!


When a specific group of keystrokes is pressed, it is fired a gainedFocusEvent...

And I need to make audible a message before the fired event...


The keystrokes force another control of the same window to get the system focus, and the correspondent messages of that control are fired so quickly the message prior is not reproduced...


I can put a delay, but the message will not be always with the same length, so I may end with a pause between the message and the get system focus messages and that is not desirable...


Stefan, can you gave me some example of your suggestion?


Rui Fontes




Às 22:13 de 10/01/2022, Lukasz Golonka via groups.io escreveu:
Hello,

On Sun, 9 Jan 2022 02:50:03 +0000
"Rui Fontes"<rui.fontes@tiflotecnia.com> wrote:

I need a message to be totally spoken before a focus event message be fired.


It is possible? If yes, how?
Not really. Perhaps if you would describe your entire problem it would
be possible to propose a solution.