Author Topic: How to trigger a TTS Greeting bassed on prefix only?  (Read 8645 times)

0 Members and 1 Guest are viewing this topic.

mparks

  • $upporter
  • Contributor
  • *****
  • Posts: 93
  • Karma: 0
    • View Profile
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #15 on: October 08, 2011, 09:58:22 PM »
Perfect, now lets see how many unique responses I can come up with.  ;)

mparks

  • $upporter
  • Contributor
  • *****
  • Posts: 93
  • Karma: 0
    • View Profile
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #16 on: October 10, 2011, 04:10:18 PM »
Hi, guys.

I am in need of help with two vbscript coding.
I have broken the time script down into hourly increments and within each hour Vox has 3 greetings to choose from.

Code:

elseif hour(now)<6 then
  if (myrand=1) then
    ttsmessage = "good morning, It's"  & time &  ", why are you up?"
  elseif (myrand=2) then
    ttsmessage = "Hi,  How can I assist you this morning"
  else
    ttsmessage = "good morning."
  end if

The code works fine but  & time &  gives me the full time format. HH:MM:SS which includes the seconds. How do I remove the seconds so that I only get hours and minuets.


Question #2:

I would also like the greetings to depend on the Day of the week:
So if the time is 6am and the day of the week is between Monday and Friday then say this, this or this
but if the time is 6am and the day is Saturday or Someday then say this, this or this.

Thanks again.

 

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #17 on: October 10, 2011, 04:20:36 PM »
none of us is an expert in vbscript as far as I know.  At this point I would recommend that you do some google searches to find some resources on this topic.

Looking at the exising script we are using hour(now), in our if-then-else, to get the hour so I assume we can do something similar for minutes.  The other option would be to see if vbscript has some string methods that would allow us to strip the end off of the HH:MM:SS

mparks

  • $upporter
  • Contributor
  • *****
  • Posts: 93
  • Karma: 0
    • View Profile
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #18 on: October 10, 2011, 04:51:13 PM »
Thanks jitterjames,

I found a few sources I am currently researching, I will update you guys if i solve it.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #19 on: October 10, 2011, 04:55:42 PM »
Thanks jitterjames,

I found a few sources I am currently researching, I will update you guys if i solve it.
You can also write a PM to member "rudmei" I'm sure he can help you with VBS-scripting.

Kalle
***********  get excited and make things  **********

Bleazle

  • $upporter
  • Contributor
  • *****
  • Posts: 60
  • Karma: 1
    • View Profile
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #20 on: April 23, 2014, 06:27:32 PM »
I appreciate that this is an old thread but it pointed me in the right direction so I figured I'd share a couple of things I added:

In this particular script I turn my outside speakers on using VC and EventGhost. Once the speakers are on Bob (there's no "Jarvis" in my house..) announces that they have been turned on. The problem I had with the script as it was is that Bobs volume was set to 100% which effectively meant he yelled that the speakers were on!  :o and if music was playing when I gave the command to turn the speakers on it wasn't muted while Bob was talking.

So firstly I set up a Global Hot Key in MediaMonkey (Cntrl+Shift+M) to mute/unmute the sound. Then I added this to the top and bottom of the script:

Code: [Select]
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^+{M}"

Then to stop Bob yelling I added the following which sets the TTS volume and rate. NOTE: These settings only apply to the announcements Bob makes in this script - I use other commands to tell Bob to speak up or stop yelling if I want to change the VC's TTS level:

Code: [Select]
Dim sapi,ttsmeassage
set sapi = CreateObject("sapi.spvoice")
with sapi
       Set .voice = .getvoices.item(0)
       .Volume = 15
       .Rate = 1
     end with

So the whole thing looks like this:

Code: [Select]
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^+{M}"

Dim sapi,ttsmeassage
set sapi = CreateObject("sapi.spvoice")
with sapi
       Set .voice = .getvoices.item(0)
       .Volume = 15
       .Rate = 1
     end with
Randomize
myrand = Int((3)*Rnd+1)
if hour(now)<6 then
  ttsmessage = "wow,  your up early David! The outside speakers are now on"
elseif hour(now)<12 then
 ttsmessage = "Good morning David, The outside speakers are now on"
elseif hour(now)<17 then
  ttsmessage = "Good after noon David. The outside speakers are now on"
elseif hour(now)<22 then
  ttsmessage = "Good evening David. The outside speakers are now on"
else
  ttsmessage = "Good evening David, isn't it past your bed time? The outside speakers are now on"
end if

sapi.Speak ttsmessage

Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^+{M}"

Ideally I would like to use a "softmute" option rather than having to fully mute MediaMonkey but I haven't found a way to do that.  I tried using nircmd.exe but that didn't give me what I wanted either because I couldn't "unmute" to the previous volume level. Anyone got any ideas?

Cheers

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #21 on: April 23, 2014, 06:50:37 PM »
It is relatively straightforward to do all this using only VoxCommando actions, except for the part where you turn your speakers on which I assume is handled by EventGhost.

I'm not sure how you would do a softmute using only VBScript though.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #22 on: April 23, 2014, 07:20:32 PM »
Something like this... although it might need a snick of debugging...
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="195" name="outdoor speakers on" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>EventGhost.Send</cmdType>
    <cmdString>turn.outdoorSpeakers.on</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>MM.SoftMute</cmdType>
    <cmdString>20</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.SetVoiceName</cmdType>
    <cmdString>Paul</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.SetVolume</cmdType>
    <cmdString>20</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>03,04,05,06&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <cmdString>wow,  you're up early David!</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>11,10,09,08,07&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <cmdString>Good morning David.</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>17,16,15,14,13,12&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <cmdString>Good afternoon David. Speakers are now on</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>18,19,20,21&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <cmdString>Good evening David, isn't it past your bed time? </cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <action>
    <cmdType>TTS.SpeakSync</cmdType>
    <cmdString>The outside speakers are now on</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>22,23,00,01,02&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <cmdString>Wow, David, you're up late. Isn't it past your bedtime?</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <action>
    <cmdType>MM.SoftUnmute</cmdType>
    <cmdString />
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

[Edited xml to fix James's booboos. ;)]
« Last Edit: April 24, 2014, 08:29:10 AM by nime5ter »

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #23 on: April 24, 2014, 02:46:42 AM »
though I am an X vb guy ...

I was wondering if this can be done using python to return an hour number (3, 6, 12 etc.) then use that to fetch what tts says from a payload xml, where multiple phrases separated by commas that will give random sentences ?

In fact I was planning on digging how to do it ... but just feeling lazy to lear python  ::zzz
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #24 on: April 24, 2014, 08:32:51 AM »
In this case, there's no need to use either VB or Python to accomplish what you're describing, so the main reason to do so would be because you actually want to learn Python.  ::)

James's xml above gives an example of how to issue different TTS announcements depending on the time. And if you look at the documentation on TTS actions, you'll see that getting random TTS responses is very simple.
« Last Edit: April 24, 2014, 08:40:28 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)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #25 on: April 24, 2014, 08:54:21 AM »
Another nice way to do it would be to use payloadXML files as you suggest, but you really don't need python for this.

I have boiled this down to just 2 actions for the greeting.  You could add the other stuff back in for the speakers and the softmute if you want.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="431" name="tts based on time of day" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PayloadXML.GetPhrase</cmdType>
    <cmdString>payloads\timebasedgreetings.xml&amp;&amp;{DtCustom.HH}&amp;&amp;Random</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.SpeakSync</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

I am also attaching a sample payloadXML file which should be saved in the ".\payloads" subfolder of your VC folder.

Bleazle

  • $upporter
  • Contributor
  • *****
  • Posts: 60
  • Karma: 1
    • View Profile
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #26 on: May 01, 2014, 03:44:06 AM »
Hi James

This solution works great here, thanks  :) Bob won't be saying "top of the morning" to me though lol - I take it you've got a bit of Irish blood??  ;D

After my last few attempts (and hours spent) trying to nut things out myself only to have you guys come up with a more eloquent solution to do what I have done I think I'll have to switch to just asking how to do "such and such::hmm

Thanks again!


nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to trigger a TTS Greeting bassed on prefix only?
« Reply #27 on: May 01, 2014, 08:59:13 AM »
After my last few attempts (and hours spent) trying to nut things out myself only to have you guys come up with a more eloquent solution to do what I have done I think I'll have to switch to just asking how to do "such and such"  ::hmm

Ha. Please, keep on innovating. Inventing a new command or automation solution is at least half the fun, isn't it?

What's great (imho) about the forum is having different users demonstrating multiple solutions. It helps everyone to see the flexibility of the program, and even if an approach turns out to be not the most powerful solution for one particular challenge, it might be just the ticket to helping someone sort out something else.

... Also, you needn't assume that it's only taking James a couple minutes to come up with his solutions. Believe me, *endless* hours are spent around here, trying to come up with the best possible solutions to various user challenges. The more brains on the case, the better!  :biglaugh
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)