Author Topic: Python TTS.SpeakSync lastresult help  (Read 2589 times)

0 Members and 2 Guests are viewing this topic.

xtermin8r

  • $upporter
  • Sr. Member
  • *****
  • Posts: 366
  • Karma: 9
  • Crunchie
    • View Profile
Python TTS.SpeakSync lastresult help
« on: April 22, 2014, 01:47:31 PM »
Hi
vc.callAction("TTS.SpeakSync",lastresult, None) = not working

What is the correct syntax ?
thanks.
« Last Edit: April 22, 2014, 01:55:49 PM by xtermin8r »
Neural Net Based Artificial Intelligence.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Python TTS.SpeakSync lastresult help
« Reply #1 on: April 22, 2014, 02:00:59 PM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Python TTS.SpeakSync lastresult help
« Reply #2 on: April 22, 2014, 02:07:58 PM »
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:
Code: [Select]
print vc.getObject("LastResult","")
so you could adapt this to grab the lastresult from vc and store it in your variable:
Code: [Select]
myLastResult = vc.getObject("LastResult","")
vc.callAction("TTS.SpeakSync", myLastResult, None)
« Last Edit: April 22, 2014, 02:10:38 PM by jitterjames »

xtermin8r

  • $upporter
  • Sr. Member
  • *****
  • Posts: 366
  • Karma: 9
  • Crunchie
    • View Profile
Re: Python TTS.SpeakSync lastresult help
« Reply #3 on: April 22, 2014, 02:48:09 PM »
this is what I was trying to do

Code: [Select]
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 ?

Code: [Select]
myTime = vc.getObject("ShortTime","")
vc.callAction("TTS.SpeakSync", myTime, None)

I get that ShortTime is not a strObject, so what is the correct format ?
« Last Edit: April 22, 2014, 02:58:17 PM by xtermin8r »
Neural Net Based Artificial Intelligence.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Python TTS.SpeakSync lastresult help
« Reply #4 on: April 22, 2014, 02:59:11 PM »

but why doesn't this work ?

Code: [Select]
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:
Code: [Select]
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:

Code: [Select]
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Python TTS.SpeakSync lastresult help
« Reply #5 on: April 22, 2014, 03:01:39 PM »
To code in Python, why not use Python methods?

The following returns a "short time" string in Python speak:
Code: [Select]
import time
myTime= time.localtime(time.time())
print time.strftime("%H:%M", myTime)
« Last Edit: May 05, 2014, 10:39:19 AM 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)

xtermin8r

  • $upporter
  • Sr. Member
  • *****
  • Posts: 366
  • Karma: 9
  • Crunchie
    • View Profile
Re: Python TTS.SpeakSync lastresult help
« Reply #6 on: April 22, 2014, 03:16:14 PM »
It makes total sense now thank you both.
Neural Net Based Artificial Intelligence.