Author Topic: VoiceAttack preventing PC auto sleep  (Read 9326 times)

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
VoiceAttack preventing PC auto sleep
« on: April 23, 2017, 06:00:19 PM »
I have my PC set to automatically go to sleep after a certain period of time. I recently noticed when VA is running (listening or not listening) and I have my headphones and/or microphone plugged in my PC won't automatically go to sleep. As soon as I close VA or unplug both audio cables my PC will go to sleep as expected.

Is there a way around this issue that allows me to keep VA running and my audio cables plugged in?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: VoiceAttack preventing PC auto sleep
« Reply #1 on: April 23, 2017, 06:07:49 PM »
I'm not sure what is causing that with your setup....  I have VA running a lot and Windows sleeps without problem.
Any plugins running?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: VoiceAttack preventing PC auto sleep
« Reply #2 on: April 23, 2017, 08:00:04 PM »
Could both of you run the command
Code: [Select]
powercfg -requestsFrom an elevated command prompt, and check whether you have an entry for your sound card while VoiceAttack is running?

On my machine, my sound card driver is marked as "An audio stream is currently is use." while VoiceAttack is running(though also when any media players are running, even if they're not playing), which would be a reason for the system not to sleep.

As it's listed as a "[DRIVER]" entry, perhaps Gary's soundcard driver doesn't "tell" the system not to sleep while VoiceAttack is running, while ours do.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VoiceAttack preventing PC auto sleep
« Reply #3 on: April 23, 2017, 09:40:07 PM »
As usual, Pfeil is right on target. I actually did some powercfg testing before posting but I didn't want to overclutter my original post. Attached is the powercfg -requests report with:
  • all playback and recording devices disabled except for those corresponding to the current ports for my microphone (Antlion Modmic 4.0) and headphones (Sony MDR-7506) on the front of my PC
  • VoiceAttack running (listening or not listening doesn't matter, the output is the same)
As you can see there is a power request by the audio device (driver) when VA is running. Once every entry says "None" (obtained by either shutting VA down or unplugging my audio cables) then the PC will go to sleep by itself.

I also did this same powercfg testing with a music player (Groove Music). When the app is open all the reports (including System) show "None." As soon as I start playing music the same HD Audio Device as shown in the attachment pops up under "System." If I pause the music it goes away again.

So compared to the music player, it looks like VA is continuously triggering power requests, whereas the music player only triggers requests when music is playing. I could try playing around with powercfg overrides to see if this helps, but I figured I'd post my issue here to see if anything can be done from VA's side.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: VoiceAttack preventing PC auto sleep
« Reply #4 on: April 23, 2017, 09:47:05 PM »
I can pop a check for standby mode and try to disable things if it can catch it in time.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: VoiceAttack preventing PC auto sleep
« Reply #5 on: April 24, 2017, 06:01:10 AM »
the music player only triggers requests when music is playing.
So it does.

When testing I had to close my media players and a browser window with a paused youtube video to make the audio entry disappear, testing again after a reboot shows that the applications do vanish from the list when they stop playing(I can only assume something wasn't quite shutting down properly on my machine, the first time around).

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VoiceAttack preventing PC auto sleep
« Reply #6 on: April 24, 2017, 08:24:01 AM »
@Gary: not sure if this is possible, but maybe VA could check for Windows commands to automatically turn on/off the monitor? Or maybe a periodic check for voice input with a volume threshold such that if enough time passes with no significant voice input provided then VA could enter a different state? Or maybe that could "prime" VA to check or start checking for standby mode? (please pardon my probably unintelligent shooting from the hip)

More info about the requests override (source):
Quote
/REQUESTSOVERRIDE

Description: Sets a Power Request override for a particular process, service, or driver. If no parameters are specified, this command displays the current list of Power Request overrides.

Arguments: [<CALLER_TYPE> <NAME> <REQUEST>]

Arguments Description:
  • <CALLER_TYPE> Specifies one of the following caller types: PROCESS, SERVICE, DRIVER. This is obtained by calling the POWERCFG /REQUESTS command.
  • <NAME> Specifies the caller name. This is the name returned from calling the POWERCFG /REQUESTS command.
  • <REQUEST> Specifies one or more of the following Power Request types: DISPLAY, SYSTEM, AWAYMODE.

Examples: POWERCFG /REQUESTSOVERRIDE PROCESS wmplayer.exe DISPLAY SYSTEM

...and some info for rolling back the override based on unofficial comments from one user (source):
Quote
Is there a possibility to "reset" the overriding ?
To remove the power request override, use the -REQUESTSOVERRIDE option, but do not specify any type of override (System, Display, AwayMode) as in the following example: POWERCFG -REQUESTSOVERRIDE PROCESS wmplayer.exe
But this is only a user comment and not a trustworthy Microsoft statement.

IIRC I also tried changing the power settings as shown in the below attachment, but I don't think that eliminated the problem. Even if it DID, I'm thinking these multimedia settings are far reaching, and I'd hate to have my PC start going to sleep while watching movies just to prevent VA from stopping auto-sleep.

As always, Pfeil and Gary your comments and help are extremely appreciated  :D

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: VoiceAttack preventing PC auto sleep
« Reply #7 on: April 24, 2017, 09:12:32 AM »
More info about the requests override
The problem here is that it's a driver level setting, presumably meaning that if VoiceAttack overrides it, no sound-playing applications on your system that don't explicitly individually prevent the system from sleeping, will be able to do so.

E.G. you could be playing music through the speakers while not at your computer, and it would suddenly go to sleep.

I also tried changing the power settings as shown in the below attachment
Sharing Media applies when you're sharing your local machine's library across the network so other devices can play the contents remotely. It should not apply to any media-playing scenario on your local machine.
So unless you're using that feature, it doesn't solve the issue, but it shouldn't cause issues either if you do change that setting.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VoiceAttack preventing PC auto sleep
« Reply #8 on: April 24, 2017, 09:34:32 AM »
Thanks again for the illuminating comments Pfeil. Everything you're saying makes sense. Hopefully there is something Gary can do within VA to address this issue.

Based on how the power request appears/disappears depending on whether a music app is playing/paused, it would be neat if VA mirrored this behavior whether VA has voice, button, keypress, etc. recognition on/off. Again, I have no idea how feasible this might be.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VoiceAttack preventing PC auto sleep
« Reply #9 on: May 15, 2017, 11:27:47 AM »
Any comments Gary about how far down the pipe this kind of feature (if possible) might be?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: VoiceAttack preventing PC auto sleep
« Reply #10 on: June 03, 2017, 06:46:38 PM »
I was wrong about the sleep... the *monitor* is going off, not the machine itself.

Not sure if this is going to be resolved easily, as the speech engine keeps the audio channel open.  If the audio channel is open, a Windows power broadcast message is never sent (this is to tell applications that Windows wants to shut down/hibernate/power down/etc).

I can *try* adding a, 'put speech engine to sleep if nothing is processed in the speech events for X minutes'-type option, however, I just need to roll that around for a bit as that just doesn't seem like an elegant solution.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: VoiceAttack preventing PC auto sleep
« Reply #11 on: June 04, 2017, 03:44:33 AM »
I can *try* adding a, 'put speech engine to sleep if nothing is processed in the speech events for X minutes'-type option, however, I just need to roll that around for a bit as that just doesn't seem like an elegant solution.
Could VoiceAttack check the current power scheme settings, and keep an internal timer set to the same length of time as in the power scheme, starting when the audio device is the only thing keeping the system awake?

VoiceAttack is already checking mouse and keyboard activity under normal circumstances, so would it not be able to determine whether the system could be considered idle?

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VoiceAttack preventing PC auto sleep
« Reply #12 on: June 05, 2017, 07:54:12 AM »
I've come up with a workaround that involves the Task Scheduler (monitoring for screensaver invoking/dismissal), some VBScript, and an executing VA command. I figured if I couldn't prevent VA from interfering with the sleep commands I might be able to get VA itself to handle the PC sleep with some triggers provided by the normal Windows processes.

So basically when the screensaver is activated/deactivated the Task Scheduler triggers a VBScript that checks to see if VA is running. If it is running the VBScript executes a command line function to switch to a specific VA profile and run a specific VA command. This command contains a countdown that will lead to VA putting the PC to sleep. This same command contains logic to terminate the countdown if the command is called while the countdown is in progress (stops PC sleeping if the screensaver is dismissed by the user prior to the countdown expiring).

It works fine for Windows 7, but I need to perform additional testing for Windows 10 (mostly because the Group Policy Editor where screensaver event monitoring is activated is by default not enabled/available on some versions of Windows 10 without another workaround).

Gary perhaps you don't have to put the speech engine to sleep...why not just have VA put the PC to sleep? Or better yet, maybe VA could perform a command or action once the internal VA idle timer expires?
« Last Edit: June 05, 2017, 09:45:55 AM by Exergist »

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VoiceAttack preventing PC auto sleep
« Reply #13 on: July 10, 2017, 07:59:36 AM »
Any news about this Gary? If this is something you're interested in implementing, how far down the to-do list is this?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: VoiceAttack preventing PC auto sleep
« Reply #14 on: July 10, 2017, 08:04:55 AM »
Actually, I've got this on a priority list.  My machine is set to go to sleep after one minute of no activity as a reminder (I keep VA on to prevent it lol).


No ETA, though.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VoiceAttack preventing PC auto sleep
« Reply #15 on: July 13, 2017, 06:47:09 AM »
Ok, thanks for the feedback!

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: VoiceAttack preventing PC auto sleep
« Reply #16 on: July 13, 2017, 10:15:19 PM »
Made some headway on this.  I need to try a few more things out and see how it goes.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: VoiceAttack preventing PC auto sleep
« Reply #17 on: July 15, 2017, 12:21:15 PM »
Try out the latest beta if you'd like.  It has an option on the System/Advanced screen to allow you to turn on sleep mode after x seconds of audio inactivity.  I didn't want to add an additional hook to monitor hardware activity... just using the speech engine's own events to drive this one.  Keyboard/mouse activity hooks are only turned on when the sleep mode is active, so as not to add more overhead to your system.

Once, 'sleep mode' is entered, you just move or click your mouse, or press a key to wake the speech engine back up.  I haven't tested it, but I *believe* that the hooks should ignore any key presses or mouse clicks made by VA, but NOT the mouse movements made by VA.

I usually hibernate my machine.  If it wakes up later for backups and VA was still running, it would not go back to sleep.  It's sleeping correctly now.  This was a good exercise ;)