Author Topic: My deployment of Voxcommando  (Read 12465 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: My deployment of Voxcommando
« Reply #15 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.
« Last Edit: May 05, 2014, 01:16:07 PM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: My deployment of Voxcommando
« Reply #16 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?")
« Last Edit: May 05, 2014, 01:26:40 PM by jitterjames »

rebelmaveric19

  • $upporter
  • Jr. Member
  • *****
  • Posts: 41
  • Karma: 2
    • View Profile
Re: My deployment of Voxcommando
« Reply #17 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!

rebelmaveric19

  • $upporter
  • Jr. Member
  • *****
  • Posts: 41
  • Karma: 2
    • View Profile
Re: My deployment of Voxcommando
« Reply #18 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?

rebelmaveric19

  • $upporter
  • Jr. Member
  • *****
  • Posts: 41
  • Karma: 2
    • View Profile
Re: My deployment of Voxcommando
« Reply #19 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)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: My deployment of Voxcommando
« Reply #20 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.
« Last Edit: May 09, 2014, 10:36:52 AM by jitterjames »

sainf

  • $upporter
  • Jr. Member
  • *****
  • Posts: 20
  • Karma: 0
  • Living In Ireland
    • View Profile
Re: My deployment of Voxcommando
« Reply #21 on: October 30, 2015, 10:05:24 PM »
I like the blue iris software. Thanks

JonPeyton

  • $upporter
  • Jr. Member
  • *****
  • Posts: 36
  • Karma: 3
    • View Profile
Re: My deployment of Voxcommando
« Reply #22 on: November 11, 2015, 04:48:57 PM »
this stuff is G*!amn amazing   ;D