VoxCommando

VoxNastics (User Guides and Mods) => Integration Ideas => Topic started by: rebelmaveric19 on April 27, 2014, 12:07:04 AM

Title: My deployment of Voxcommando
Post by: rebelmaveric19 on April 27, 2014, 12:07:04 AM
I recently started integrating voxcommando into my network and wanted to let you all know about some stuff I have figured out.

I run voxcommando on a win7 virtual machine that is running on top of my WHS 2011 box in virtualbox. Right off the bat I made skype as my primary means of talking to "Jarvis" (laugh later). I am not really using Jarvis to do stuff like htpc commands (later maybe if mics get better) but more for home automation commands. My "alarm" system is currently 6 ip cameras that are recording in a program called Blue Iris. Blue iris sends a tcp command to voxcommando through vox's webserver and in turn writes a xml payload as the reason why he called (motion detect in the living room) and then calls me and reads the payload to me. I also use vox to activate and deactivate blue iris alerts by my phone on and off the wifi (always looking for my phone's static ip address). I use pstools batch files to make xml payload files of running processes on all the computers (Jarvis is Blue Iris running on the server) and can launch,kill and restart any process too. My main goal right now is making Jarvis "smart" by everytime he does something, he rights a payload xml to "know" what he is doing at all times and ALOT of if and then statements. I have no formal computer training and trying to create logic in Jarvis is the single hardest thing for me to create. Some day I want Jarvis to be able to fix things for me (if he sees the living room receiver come on but cant ping the living room htpc, wake it up incase eventghost didnt do it) so the WAF for all my htpc's goes way up and she dosent call me and I have to walk her over the phone while I am at work. I just wrote this to see if any of you would like to know how am using it with Blue iris and when I was google searching for how to get running processes on a remote computer I couldn't find anything. So if you are interested just ask and help you as much as I can.

James thank you very much for what you have built and it is an amazing piece of software.
Title: Re: My deployment of Voxcommando
Post by: rebelmaveric19 on May 03, 2014, 12:29:28 PM
To add to this I recently started using tasker on my android S4 with autovoice plugin. I set autovoice to run in continuous mode and listen for my payload command "Jarvis" and then whatever I say after and tasker sends a http command with all the payloads....example "Jarvis are you there" and tasker sends a http command as http://ip:port/api/vc.tellvox&&%avcomm.........where %avcomm is the phrase that I said. I can get this to successfully work without my screen on and even touching my phone (about 90% accuracy). Now the question is how can I send a payload of the tts.speak that VC says to my phone and somehow my phone interpret the payload into a tts speech command. That is the missing piece of the puzzle. Anyone smarter than me mind helping me out?
Title: Re: My deployment of Voxcommando
Post by: Kalle on May 03, 2014, 01:27:41 PM
If I understand you correct, you use your S4 as mic with tasker. You can test VoxWav (which is available for free in the playstore), and the pro version has also a always "Mic ON" function. Here are more information about voxwav: [url][http://voxwav.wikispaces.com/VoxWav+Home/url]
Title: Re:
Post by: rebelmaveric19 on May 03, 2014, 11:53:31 PM
Yea I understand what VoxWav can do but I can do sooooo much more with tasker. Call me crazy too but using tasker with autovoice also has less unrecognized commands. I want my phone to be the "voice" of my voxcommando install. I am trying to send all tts.speak commands back to my phone as a payload so my S4 is my "central" mic. Like I said I can send payloads to VC but trying to figure out a way to receive payloads is my problem. Thanks
Title: Re:
Post by: nime5ter on May 04, 2014, 09:44:00 AM
Call me crazy too but using tasker with autovoice also has less unrecognized commands.

Crazy isn't the word I'd use, but it *is* surprising, and suggests that maybe VoxWav wasn't set up properly or something when you tried to use it.

wrt you other questions, it sounds like you need people who understand how Tasker works. The question mark here isn't how VC works, but how Tasker works. If you can find out via the Tasker documentation or forums how Tasker can listen for a message, we can then probably tell you how to send it from VC.
Title: Re: My deployment of Voxcommando
Post by: rebelmaveric19 on May 04, 2014, 11:14:33 AM
The people that make AutoVoice have a plugin for tasker called autoremote that I can use as a webserver on the phone to receive payloads and it works outside of lan. Once I figure out how to get all my variables right I will be able to use VC from anywhere in the world without even touching my phone.
Title: Re: My deployment of Voxcommando
Post by: nime5ter on May 04, 2014, 11:29:41 AM
Great. That's one of the main ideas behind VC -- that users can combine it with many other pieces of software and hardware to customize things according to whatever suits their needs, limited only by personal creativity and capacity.

Hopefully you can let other users here know how to actually do it once you've figured it out.
Title: Re: My deployment of Voxcommando
Post by: jitterjames on May 04, 2014, 01:43:12 PM
It would be nice to figure out how to send information to tasker using autoremote,

However, if all you want to do is enable your phone as a TTS device then you can do it using VoxWav pro.  It should still receive TTS messages and speak even if running in the background.

The problem you will face when using autoremote is that you will need to create special actions for each command that you want to send TTS to your phone.  There is no way to "redirect" the existing TTS actions to a new action.
Title: Re: My deployment of Voxcommando
Post by: rebelmaveric19 on May 04, 2014, 02:36:50 PM
You can use autoremote to send events to tasker through your personal webpage you get when you buy autoremote in the play store.
I came back to ask if there was a internal variable in VC that is whatever was spoken BY VC last. Is there anyway I could somehow make a variable. My existing tts commands are random (because its nice not to hear the same thing over and over). I could replace my responses with XML's and chose random and use {LastResult} that way but is there an easier way?
Title: Re: My deployment of Voxcommando
Post by: jitterjames on May 04, 2014, 02:50:56 PM
No there is no such variable.

Is autoremote able to listen to UDP messages as well as http?  If it is then there is a very easy solution.

Quote
I could replace my responses with XML's and chose random and use {LastResult} that way but is there an easier way?
I don't understand what you are saying here.

One option you have is to replace all your TTS actions with some other action like a python call that could do both the local TTS and send the TTS message to autoremote.  It could also select items randomly for you.  This would not be too difficult, but you would need to edit all your TTS actions to convert them.
Title: Re: My deployment of Voxcommando
Post by: Haddood on May 04, 2014, 03:27:42 PM
This would not be too difficult, but you would need to edit all your TTS actions to convert them.

that is exactly why I do not engage TTS.speak directly... rather I built a macro called feedback and I pass the text as payload ... the feedback will speak, osd.show and soon VFD ... one place to control it all ... or it would be a nightmare
Title: Re: My deployment of Voxcommando
Post by: rebelmaveric19 on May 04, 2014, 10:07:20 PM
Is autoremote able to listen to UDP messages as well as http?  If it is then there is a very easy solution.
No. Autoremote works by receiving "messages" in http format like this "ip/apikey/jarvistalk=:=%arcomm", It is just looking for the message to say jarvistalk and issues an action (in my case tts) and says/does what ever %arcomm is.

I don't understand what you are saying here.
Make and payloadxml that is named "Jarvis is Here" and put random phrases for responses (i am here/online and ready/etc) and use payloadxml.getrandomphrase and then i could use {LastResult} as a tts/last spoken payload.....Nevermind its a stupid idea....(lot of work/time).

One option you have is to replace all your TTS actions with some other action like a python call that could do both the local TTS and send the TTS message to autoremote.  It could also select items randomly for you.  This would not be too difficult, but you would need to edit all your TTS actions to convert them.
I am smart enough to use plugins and programs that other people write and suit them for my needs (sometimes need help) but not smart enough to write my own code.....I know python is about the easiest language to learn but I tried and got frustrated severely......I learn by examples and I know there is alot of examples out there but here is how I learn them, I ask you to do something simple and write it in code and I will try to decipher it and make sense in relating it to something I do know and 99% of the time you never have to teach me again.....but would love to learn how to write a script to make it easier on me

that is exactly why I do not engage TTS.speak directly... rather I built a macro called feedback and I pass the text as payload ... the feedback will speak, osd.show and soon VFD ... one place to control it all ... or it would be a nightmare
This makes alot of sense but you cant select random phrases right because its just whats in the text variable correct? and what is VFD?
Title: Re: My deployment of Voxcommando
Post by: Haddood on May 05, 2014, 12:01:47 AM
In fact yes you can have random phrases ...  I pass 2 payloads, one is either a specific phrase or a value, the second is the method ... If method one look for a random phrase from XML file with value passed...

VFD = http://en.wikipedia.org/wiki/Vacuum_fluorescent_display
Title: Re: My deployment of Voxcommando
Post by: nime5ter on May 05, 2014, 09:24:54 AM
I ask you to do something simple and write it in code

It's difficult for a 'teacher' to determine what is simple from the learner's point of view, but still enough so that the learner doesn't come back again 5 minutes later asking for another example, since that ends up being a full-time voluntary job in which we are writing custom configurations for every user, and it's not clear that the lessons are being applied more broadly.

Here are several solutions that should allow you to generate random TTS, OSD and Autoremote messages. Hopefully these examples will be helpful to VC users in general.

I was not able to test the Autoremote line. You'll have to test that yourself and maybe debug a bit if I screwed something up there (quick morning effort -- there may be typos or I may have overlooked something in the Python version).

VC Only Method:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.3.2-->
<commandGroup open="True" name="VC only tts tests" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="261" name="tts to multiple locations 01" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>myTTS</param>
        <param>hello|greetings|hi there</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>test random feedback</phrase>
  </command>
  <command id="271" name="doMyTTS" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>([^|]+)</param>
        <param>--</param>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetLastResult</cmdType>
      <params>
        <param>{Match.Rnd}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://autoremotejoaomgcd.appspot.com/sendmessage?key={M:maveric.autoremoteKey}&amp;message=jarvistalk=:={LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>myTTS</event>
  </command>
</commandGroup>

Per our earlier discussion, the {M:maveric.autoremoteKey} is a variable that refers to a map table in VC where you've stored your API key for Autoremote. The name of the map variable will depend on what you've named your map and what you've named the API key variable. http://voxcommando.com/mediawiki/index.php?title=Maps
Title: Re: My deployment of Voxcommando
Post by: nime5ter on May 05, 2014, 09:31:31 AM
Python version as follows. You need to enable the Python plugin in VoxCommando for this to work.

VC commands group:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.3.2-->
<commandGroup open="True" name="python random" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="1151" name="load python script" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <params>
        <param>PY\randomMsg.py</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
  <command id="1152" name="test tts message" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetLastResult</cmdType>
      <params>
        <param>My name is Simon|Hello there|4|5|6|7|8</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>randomMsg("{LastResult}")</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
</commandGroup>

Python script (randomMsg.py) attached. It needs to go in the PY folder of your VC directory (or you need to change the file path in the VC command).

The lines that start with '#' are not code, but comments to the reader.

Pasted here for other users who may be interested in the code:
Code: [Select]
import urllib
import random

def randomMsg(tts):
    mavericAPIkey= "Enter your API KEY here in quotes (in quotes defines it as a string in Python)"
    ttsList=tts.split("|")
    myMsg=random.choice(ttsList)
    vc.callAction("TTS.Speak",myMsg, None)
    vc.callAction("OSD.ShowText",myMsg, None)
    #if you want to use VC, uncomment (remove #) the following line:
    #vc.callAction("Scrape","http://autoremotejoaomgcd.appspot.com/sendmessage?key="+mavericAPIkey+"&message=jarvistalk=:="+myMsg,None)
    #the line below calls the URL directly from python. You'll need to test this.
    urllib.urlopen("http://autoremotejoaomgcd.appspot.com/sendmessage?key="+mavericAPIkey+"&message=jarvistalk=:="+myMsg)
Title: Re: My deployment of Voxcommando
Post by: jitterjames on May 05, 2014, 11:01:50 AM
So if you are using the python method.  Any time you want to do TTS, instead of using TTS.Speak you replace it with the PY.ExecString action and call the function named randomMsg(), passing it the same text that you would have used for your TTS action.  See the attached image for an example.
Title: Re: My deployment of Voxcommando
Post by: jitterjames on May 05, 2014, 01:24:31 PM
I just noticed that I made a small boo boo there...

because my text to speak contains an apostrophe (same as a single quote) in the word what's, my call to the python function will fail because it will read up to the end of the word what, see the quote, and think the string is finished, and then it won't know what the rest of the stuff is for and will throw an error!

So in this case I can pass the whole string wrapped in double quotes instead of using single quotes (same as apostrophe).

Python doesn't care if you use double or single quotes to wrap your string.  If you need to pass TTS text that contains both for some reason you will need to escape the quotes.  You can probably do this by writing \"

So your could write your PY.ExecString parameter like this
Code: [Select]
randomMsg("Oh no! What's \"wrong\" with you?")
Title: Re: My deployment of Voxcommando
Post by: rebelmaveric19 on May 05, 2014, 10:07:29 PM
Thank you both very much for starting a sample for me to get random responses. I can only work on my computer stuff between 9pm till when I get tired (usually around 12am). I suck at written tutorials so I want to make a video tutorial for people about integrating tasker with VC before I move ahead (it takes me a little longer to do stuff because i am learning as i am creating). I want to get it working before the end of the week. BTW using tasker with autovoice yields me about a 90-95% accuracy with my phrases and it is really practical to use at the same time. Again thank you!
Title: Re: My deployment of Voxcommando
Post by: rebelmaveric19 on May 08, 2014, 11:42:06 PM
Alright I have rethought the whole using tts locally on my computer and sending it to my phone. I am going to cut out tts locally. The way I want to do it is just send it to the phones........here is my question, Jarvis (VC) already knows who sent the last message by an event that is triggered everytime I command something and that value is stored in a table (WhosIsTalkingtoMe)....in your python script I will just add two scrape addresses to send to, but when my wife talks to Jarvis (VC) I dont want my phone going off at the same time. I am not asking you to rewrite the code for me but tell me if I am going in the right direction. My thoughts on how to write this in python are as follows:
1-Python calls on the map table and gets value to who just sent him a command (me)
2-if value =(me) send to my api key
3-if value =(wife) send to her api key

am I correct in the direction I am going or thinking all wrong?
Title: Re: My deployment of Voxcommando
Post by: rebelmaveric19 on May 09, 2014, 12:13:05 AM
Alright this is what I came up with........am I anywhere near close

Code: [Select]
import urllib
import random

def randomMsg(tts):
    RogersS4APIKey= "Enter your API KEY here in quotes (in quotes defines it as a string in Python)"
    HeathersAPIKey= "Enter your API KEY here in quotes (in quotes defines it as a string in Python)"
    ttsList=tts.split("|")
    myMsg=random.choice(ttsList)
    #vc.callAction("TTS.Speak",myMsg, None)
    vc.callAction("Map.Get",WhoisTalkingtoJarvis,who is talking to me)
    myLastResult = vc.getObject("LastResult","")
    if myLastResult==roger
vc.callAction("Scrape","http://autoremotejoaomgcd.appspot.com/sendmessage?key="+RogersS4APIKey+"&message=jarvistalk=:="+myMsg,None)
    if myLastResult==heather
vc.callAction("Scrape","http://autoremotejoaomgcd.appspot.com/sendmessage?key="+HeathersAPIKey+"&message=jarvistalk=:="+myMsg,None)
vc.callAction("OSD.ShowText",myMsg, None)
    #if you want to use VC, uncomment (remove #) the following line:
    #vc.callAction("Scrape","http://autoremotejoaomgcd.appspot.com/sendmessage?key="+RogersS4APIKey+"&message=jarvistalk=:="+myMsg,None)
    #the line below calls the URL directly from python. You'll need to test this.
    urllib.urlopen("http://autoremotejoaomgcd.appspot.com/sendmessage?key="+RogersS4APIKey+"&message=jarvistalk=:="+myMsg)
Title: Re: My deployment of Voxcommando
Post by: jitterjames on May 09, 2014, 10:27:25 AM
You are definitely on the right track.

You need to fix some syntax errors and remove the last line, which you probably just forgot to do.  You only need to use scrape, OR urllib, not both, but urllib would be better I think.

If you are going to use vc.callAction you should check the correct way to use it.  There is an example here:

http://voxcommando.com/mediawiki/index.php?title=Python#Actions

Assuming you are setting the map variables correctly then I think this will basically work.

It is possible to do it a better way though (IMO).  Assuming that you are not worried about remembering who contacted VC last when VC is closed and restarted...

What I would do, instead of using maps, set a global variable in python which contains your api key.  Then you won't need to do a whole bunch of reading of variables, and looking up map values every time that your TTS function is being called.  The command triggered by your event which says who is calling, can set the api key.  This could either be done using logic within the command, or by actually passing the api key as a payload when you call the event.

http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them

I'm glad to see you taking the initiative here.  Give either or both methods a shot, and let us know if (when) you need help.
Title: Re: My deployment of Voxcommando
Post by: sainf on October 30, 2015, 10:05:24 PM
I like the blue iris software. Thanks
Title: Re: My deployment of Voxcommando
Post by: JonPeyton on November 11, 2015, 04:48:57 PM
this stuff is G*!amn amazing   ;D