Author Topic: OSD Display Time  (Read 6129 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: OSD Display Time
« Reply #15 on: October 22, 2016, 06:31:34 PM »
Yes those are called payloads.

Here is the Python which will add a 7th payload that is the alternates, and I've separated the alternates using \r\n (new line) but you could change the Python to just use a comma if you wanted to.

Sorry the structure of the OSD object is undocumented at this point.  It was originally intended to be used directly by plugins written in C# and in that context it is somewhat documented for the developer.  One of the elements of OSD event object is a list of strings, named alternateSpeech.

so I added the line:    strAlts = '\r\n'.join(osdInfo.alternateSpeech)
and then included the variable strAlts in the list of payloads when calling  vc.triggerEvent.

Code: [Select]
from System.Collections.Generic import *

def osdEvent(osdInfo):   
    strText = unicode(osdInfo.speechText)   
    strCommandName = unicode(osdInfo.commandName)
    strGroup = str(osdInfo.groupName)
    strConfidence= str(osdInfo.confidence)
    strPass = str(osdInfo.confidencePassed)
    strDoingCommand=str(osdInfo.doingCommand)
    strAlts = unicode('\r\n'.join(osdInfo.alternateSpeech))

vc.OnOSD -= osdEvent
vc.OnOSD += osdEvent

I haven't looked at your commands yet, but ultimately if you are going to send this to Growl, it would be better to send it directly from the Python plugin in order to reduce the amount of work VC has to do every time it hears a voice command.  This is actually the reason I don't create events for recognized speech, because I think it would just be too much overhead on top of whatever else VC is supposed to do with your voice command when it's recognized.
« Last Edit: October 23, 2016, 11:13:01 AM by nime5ter »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: OSD Display Time
« Reply #16 on: October 23, 2016, 01:15:22 PM »
I'm talking about the data 1-6 in nime5ters image attached to this post.
Which is the correct term for them?

Maybe the wiki entry can help clarify: http://voxcommando.com/mediawiki/index.php?title=Payloads

The documentation on Events also has a bit of information on events with payloads: http://voxcommando.com/mediawiki/index.php?title=Events
« Last Edit: October 23, 2016, 01:25:47 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: OSD Display Time
« Reply #17 on: October 23, 2016, 02:02:23 PM »
I have also attached a Group with the Command I am experimenting with. Perhaps my questions gets clearer when you look at it.
While experimenting and trying it out I have put all parts in separate messages but I plan to combine them in fewer or one message when/if I get everything to work with Alternates.

Right now you are triggering the same command using multiple different events. Since VC.Reco will be generated with every recognized commands, you have the same VC command being triggered twice when there are alternates--once via the Alternates event and then again via the VC.Reco event.

The simplest solution is to create 2 commands. One that is triggered by the VC.Reco event, and a different command that is triggered by the VC.Alternates events.

Something like the following command could be used to send all alternates to Growl:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.0-->
<command id="340" name="Growl Notifications (Alternates)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="10" loopMax="{#P}" description="{#P}==number of payloads. If there are 7 alternates, we loop 7 times. Each time, the value for {j} increases by one. I add a brief pause here just in case Growl requires it. You can try without it.">
  <loop>
    <loopParams>
      <from>1</from>
      <to>{#P}</to>
    </loopParams>
    <loopActions>
      <action>
        <cmdType>Growl.Send</cmdType>
        <params>
          <param>alternate {j}</param>
          <param>{{j}}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.Pause</cmdType>
        <params>
          <param>100</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </loopActions>
  </loop>
  <event>VC.Alternates.*</event>
</command>

A few additional notes:

1) I see that you have tried to set the VC.Alternates events to "optional", as we do for phrases. Events don't work quite the same way as voice phrases. There is no such thing as an optional event, to my knowledge.

You can't build a "combination trigger" by dragging different events onto a command. Instead, each event will separately trigger the command.

(It would be better if the UI didn't permit you to set events to "optional" because it's technically meaningless. This is probably something we can change in an upcoming release.)

2) As you can see in the above command example, rather than separately attaching each VC.Alternates event to your command, you can use the * wildcard. This means that any event that starts with VC.Alternates to trigger the command.

http://voxcommando.com/mediawiki/index.php?title=Events#Using_event_triggers

3) My solution above does not address your desire to have all of the information combined into one message. But I think it's a good idea for you to start with this in order to see how it works.

---
All of the above does not change James's point that if you want to send information to Growl for every single command, it would be more efficient to use a Python-only solution.

In a Python-only solution, you would not generate a VC.Reco event in your script using VC.TriggerEvent and then execute VC commands with that event.

You would instead string all the different pieces of information together in your script, and then send the relevant notifications directly to Growl within the script.

However, if you're still learning how to use VC, experimenting with my suggestion above is a good starting point. Later you can look into adapting the Python script once you've decided how you want Growl to behave.

« Last Edit: October 23, 2016, 02:05:27 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Voxy

  • Jr. Member
  • **
  • Posts: 13
  • Karma: 1
    • View Profile
Re: OSD Display Time
« Reply #18 on: October 23, 2016, 02:52:52 PM »
Yes those are called payloads.

Here is the Python which will add a 7th payload that is the alternates, and I've separated the alternates using \r\n (new line) but you could change the Python to just use a comma if you wanted to.

Sorry the structure of the OSD object is undocumented at this point.  It was originally intended to be used directly by plugins written in C# and in that context it is somewhat documented for the developer.  One of the elements of OSD event object is a list of strings, named alternateSpeech.

so I added the line:    strAlts = '\r\n'.join(osdInfo.alternateSpeech)
and then included the variable strAlts in the list of payloads when calling  vc.triggerEvent.

Code: [Select]
from System.Collections.Generic import *

def osdEvent(osdInfo):   
    strText = unicode(osdInfo.speechText)   
    strCommandName = unicode(osdInfo.commandName)
    strGroup = str(osdInfo.groupName)
    strConfidence= str(osdInfo.confidence)
    strPass = str(osdInfo.confidencePassed)
    strDoingCommand=str(osdInfo.doingCommand)
    strAlts = unicode('\r\n'.join(osdInfo.alternateSpeech))

vc.OnOSD -= osdEvent
vc.OnOSD += osdEvent

I haven't looked at your commands yet, but ultimately if you are going to send this to Growl, it would be better to send it directly from the Python plugin in order to reduce the amount of work VC has to do every time it hears a voice command.  This is actually the reason I don't create events for recognized speech, because I think it would just be too much overhead on top of whatever else VC is supposed to do with your voice command when it's recognized.

Oh yeah, now the solution is complete! Thank you very much nime5ter and jitterjames!

This solution to my feature request is much better and much more flexible and useful to me than what I asked for.
I guess this solution also could be satisfying to SteveB69 who started this thread.

I'm not surprised that there existed a solution because Voxcommando is a very cleverly designed application with lots of possibilities, flexibility and customizability and even though Voxcommando is a very powerful application it is at the same time not very difficult to learn and understand. Many applications are either powerful or easy to understand, Voxcommando is both.

After a computer reboot the timeout/duration parameter for the OSD.ShowText started to work correctly on my computer which gives me even more freedom to choose which Action I want to use for my automatic OSD setup.
I can choose to use OSD.ShowText Action if I want shorter timeout length than 3 seconds or I can choose to use Growl Action if I want it's extra features.

I love Voxcommando's high level of possibilities and customizability.
If there's a downside with a solution or when using a feature for me it's better to be given the information about the downside and then myself decide if the downside is worth paying to get the feature rather than all possible solutions is not presented/given to me.
In this case, about creating events for recognized speech perhaps adding to much overhead, for me I would have preferred a setting in Options to be able to turn on creating events for recognized speech if I needed it and then see how it affected my computer. If I would find it had to great negative impact on my computer I could just turn off these events again.
These kind of advanced settings could be put in a special section in options called Advanced.

About me confusing Payloads with variables I will try to get to understand the difference but it's really, really difficult and confusing for me to understand why Payloads aren't variables.
When the wiki about Payloads says;
"These placeholders are then replaced in the command's macro by the values we provide when we issue our voice commands (or through event payloads)."
it makes it even harder for me to understand that payloads are not variables. But I'm no programmer so perhaps I have misunderstood what variables are.
Regardless if I will manage to understand it or not I'll try to use the terms correctly in the future. Thanks for the links nime5ters.

Voxy

  • Jr. Member
  • **
  • Posts: 13
  • Karma: 1
    • View Profile
Re: OSD Display Time
« Reply #19 on: October 23, 2016, 02:59:43 PM »
Right now you are triggering the same command using multiple different events. Since VC.Reco will be generated with every recognized commands, you have the same VC command being triggered twice when there are alternates--once via the Alternates event and then again via the VC.Reco event.

The simplest solution is to create 2 commands. One that is triggered by the VC.Reco event, and a different command that is triggered by the VC.Alternates events.

Something like the following command could be used to send all alternates to Growl:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.0-->
<command id="340" name="Growl Notifications (Alternates)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="10" loopMax="{#P}" description="{#P}==number of payloads. If there are 7 alternates, we loop 7 times. Each time, the value for {j} increases by one. I add a brief pause here just in case Growl requires it. You can try without it.">
  <loop>
    <loopParams>
      <from>1</from>
      <to>{#P}</to>
    </loopParams>
    <loopActions>
      <action>
        <cmdType>Growl.Send</cmdType>
        <params>
          <param>alternate {j}</param>
          <param>{{j}}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.Pause</cmdType>
        <params>
          <param>100</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </loopActions>
  </loop>
  <event>VC.Alternates.*</event>
</command>

A few additional notes:

1) I see that you have tried to set the VC.Alternates events to "optional", as we do for phrases. Events don't work quite the same way as voice phrases. There is no such thing as an optional event, to my knowledge.

You can't build a "combination trigger" by dragging different events onto a command. Instead, each event will separately trigger the command.

(It would be better if the UI didn't permit you to set events to "optional" because it's technically meaningless. This is probably something we can change in an upcoming release.)

2) As you can see in the above command example, rather than separately attaching each VC.Alternates event to your command, you can use the * wildcard. This means that any event that starts with VC.Alternates to trigger the command.

http://voxcommando.com/mediawiki/index.php?title=Events#Using_event_triggers

3) My solution above does not address your desire to have all of the information combined into one message. But I think it's a good idea for you to start with this in order to see how it works.

---
All of the above does not change James's point that if you want to send information to Growl for every single command, it would be more efficient to use a Python-only solution.

In a Python-only solution, you would not generate a VC.Reco event in your script using VC.TriggerEvent and then execute VC commands with that event.

You would instead string all the different pieces of information together in your script, and then send the relevant notifications directly to Growl within the script.

However, if you're still learning how to use VC, experimenting with my suggestion above is a good starting point. Later you can look into adapting the Python script once you've decided how you want Growl to behave.

nime5ter: thanks for looking at and commenting my Command. It was just a kind of laboratory trying to guess and figure out how different things works by trial and error without having enough knowledge nor information.
After jitterjames put the Alternates as a variable in the python script I don't need to use the VC.alternates events any longer.
I've attached the command I made after jitterjames updated the python script. At the momentI have both OSD.ShowText and Growl.Send doing the same thing to compare them and see which one I prefer.
I'll examine and try out your Command later, I always learn something new looking at and trying the Commands you make.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: OSD Display Time
« Reply #20 on: October 23, 2016, 03:33:11 PM »
About me confusing Payloads with variables I will try to get to understand the difference but it's really, really difficult and confusing for me to understand why Payloads aren't variables.

:) Mea culpa. That is because I created the documentation. When programmers try to explain what a payload is, no one understands them. I tried to explain payloads in a way that makes sense to non-programmers so that our users can get more comfortable using them.

I know James would prefer if I avoided using the same kind of language to describe payloads and variables.

Real programmers consider payloads to be a discrete concept. A payload in the real world is an item that is transported and passed along from one place to the next. So, a truck that is transporting 500 kilos of tomatoes is carrying a 500 kg payload. The payload is not part of the truck: the truck can travel without it, but the whole reason the truck is traveling is to carry those tomatoes to a destination.

"Payload" is a more concise way of describing the parcels of information that we pass to a command when triggering the command.

It is certainly easier for us to help users on the forum when queries are expressed as concisely as possible.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: OSD Display Time
« Reply #21 on: October 24, 2016, 02:13:36 PM »
* VcAdvanced.Notify work well but it's timeout setting didn't have any effect on my Windows 7 computer, it was 4 seconds no matter what number for milliseconds I set.
For me, I prefer the VC Growl plugin over VcAdvanced.Notify.


Microsoft, in their wisdom have decided to ignore the duration specified by programmers in Windows 7 and later, in order to make everyone feel safe and happy. 
Thanks again MS!  ::dis

Voxy

  • Jr. Member
  • **
  • Posts: 13
  • Karma: 1
    • View Profile
Re: OSD Display Time
« Reply #22 on: October 24, 2016, 05:29:28 PM »
Microsoft, in their wisdom have decided to ignore the duration specified by programmers in Windows 7 and later, in order to make everyone feel safe and happy. 
Thanks again MS!  ::dis

I read somewhere that the minimum timeout for tray notifications in Windows is 5 seconds.
Somehow Growl manage to set it shorter anyway but has chosen to not offer shorter timeout than 3 seconds.
For shorter OSD timeout than 3 seconds I can use OSD.ShowText but OSD.ShowText can interfere with some other overlay windows/dialogues.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: OSD Display Time
« Reply #23 on: October 24, 2016, 05:38:06 PM »
Yes, that is correct, but it is set by the user and 5 seconds is the default.

I could be wrong but I don't think that growl uses the windows notification system at all and instead creates its own popups.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: OSD Display Time
« Reply #24 on: October 26, 2016, 05:55:18 PM »
Microsoft, in their wisdom have decided to ignore the duration specified by programmers in Windows 7 and later, in order to make everyone feel safe and happy. 
Thanks again MS!  ::dis

As of the beta release of VC version 2.2.3.0 today, users can now set a duration of less than 5 seconds when using the action VCadvanced.Notify. Please note that the fix is experimental. You can try it, but we can't guarantee it will work on every system.

Change log: http://voxcommando.com/mediawiki/index.php?title=ChangeLog#Version_2.2.3.0

Beta can be downloaded on the Downloads page: http://voxcommando.com/home/downloads/
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: OSD Display Time
« Reply #25 on: October 28, 2016, 09:36:05 AM »
I was wondering if there is a way to reduce the amount of time the OSD stays on screen for, looked al over the options but can't find anything.

As of beta release VC 2.2.3.0, there is a new setting in Options—"OSD display time"—permitting users to set the amount of time that the automated OSD messages stay on the screen (e.g., recognized commands or alternates, if these OSD message options are selected).

Change log: http://voxcommando.com/mediawiki/index.php?title=ChangeLog#Version_2.2.3.0

Latest beta version is available on the Downloads page: http://voxcommando.com/home/downloads/

TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)