News:

HOT TIP! Exploring the commands packaged in VC's standard configurations is a great way to learn how to build your own. You can also clone a command as a starting point: just right-click and select "Clone" (or type Alt-C).

Main Menu

Python TTS.SpeakSync lastresult help

Started by xtermin8r, April 22, 2014, 01:47:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xtermin8r

Hi
vc.callAction("TTS.SpeakSync",lastresult, None) = not working

What is the correct syntax ?
thanks.
Neural Net Based Artificial Intelligence.

nime5ter

per the wiki: void callAction(string strActionType, string strParams, List<string> payloads)

... doesn't look as though you've defined lastresult as a string?
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

#2
There are examples and explanations for python here:

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

Your second parameter should be a string, but as Nime5ter points out, you probably did not define a string variable named lastresult.  There is no way to know since you only showed us one line of your code.

One of the examples on the page I linked to above is this:
print vc.getObject("LastResult","")

so you could adapt this to grab the lastresult from vc and store it in your variable:
myLastResult = vc.getObject("LastResult","")
vc.callAction("TTS.SpeakSync", myLastResult, None)

xtermin8r

#3
this is what I was trying to do

vc.callAction("Weather.TWN.1","gbxx0037",None)
myLastResult = vc.getObject("LastResult","")
vc.callAction("TTS.SpeakSync", myLastResult, None)


working fine now, thanx for the xplanation.

but why doesn't this work ?

myTime = vc.getObject("ShortTime","")
vc.callAction("TTS.SpeakSync", myTime, None)


I get that ShortTime is not a strObject, so what is the correct format ?
Neural Net Based Artificial Intelligence.

jitterjames

Quote from: xtermin8r on April 22, 2014, 02:48:09 PM

but why doesn't this work ?

myTime = vc.getObject("ShortTime","")
...


Please see the reference material that I linked to.  That doesn't work for the same reason that the following code does not work:
myBalance = vc.getObject("HowMuchMoneyIsInMyBank","")

You can't just make up object names.  The objects are listed on the page I linked to.  More specifically they can be found here:
http://voxcommando.com/mediawiki/index.php?title=Python#getObject


I should probably point out that if you were calling a python function from within a VC macro (instead of just running python code) then you could do something like this:

py.execstring    myFunc({ShortTime})

This is because actions will look at anything in {} to see if it can be replaced with a payload, variable, map value etc. but this does not apply to python code.  And before you ask, no that isn't going to change.  However, I could probably add a new method to accept a string and do these substitutions, and return a string with the substituted values in place.


nime5ter

#5
To code in Python, why not use Python methods?

The following returns a "short time" string in Python speak:
import time
myTime= time.localtime(time.time())
print time.strftime("%H:%M", myTime)
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)

xtermin8r

It makes total sense now thank you both.
Neural Net Based Artificial Intelligence.