Author Topic: tell me a story tell me a joke tell me a puzzle  (Read 10072 times)

0 Members and 4 Guests are viewing this topic.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #15 on: May 12, 2014, 11:46:19 AM »
Haha, funny  :biglaugh

But here is a solution with which you run never in "head ... head" with your jokes, but it required two text files and a map table with jokes  :P

create first a map table with digits as key and the joke as value like the attached picture "jokemap.png" and then copy the attached oldjokes.txt file to you VC main folder (the second text file "jokes.txt" will create automatically when you execute the command). After that copy and paste the command group to your VC command tree and see what happen - have fun.
The command select a random joke from the map, compares with the joke which is in the "oldjokes.txt" stored. It's the same joke, it starts the process again until it is a other joke as stored in the "oldjokes.txt" file. If it is a other joke, it shows and stored it in the "oldjokes.txt" file. In this case you will never hear the same joke successively.

here the command group:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.2.2-->
<commandGroup open="True" name="jokes special command" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="308" name="read jokes" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Map.Get</cmdType>
      <params>
        <param>jokes</param>
        <param>{Rnd.1.5}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.Write</cmdType>
      <params>
        <param>{Path.VC}\jokes.txt</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>JOKE</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.read</cmdType>
      <params>
        <param>{Path.VC}\oldjokes.txt</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.JOKE}&amp;&amp;{LastResult}</ifParams>
      <then>
        <action>
          <cmdType>VC.TriggerEvent</cmdType>
          <params>
            <param>jokeloop</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>File.read</cmdType>
          <params>
            <param>{Path.VC}\jokes.txt</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>{LastResult}</param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>{LastResult}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>File.Write</cmdType>
          <params>
            <param>{Path.VC}\oldjokes.txt</param>
            <param>{LastResult}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>tell me a joke, tell me an other joke</phrase>
    <event>jokeloop</event>
  </command>
</commandGroup>

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

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #16 on: May 12, 2014, 03:35:59 PM »
And last but not least - final the best solution (in my eyes) which comes really in the near for what you looking for.
This command group contain a command which read the first joke which is stored in your text file. Then the command cut it out and place it at the end of the file. In this way you will never have a joke twice, unless you have all heard.

You can use my testjoke.txt file to have a first start (put it in the VC mainfolder). All jokes written in a line without a carriage return, only the last line has a carriage return, because I use the "file.AppendLine" action which insert a carriage return after insert the joke, which is important.
You must also enable in VC the DxInput plugin which allowed us keyboard inserts (that was the trick).

Note: If Notepad is not your default txt editor, remove the Window.Focus action. (thanks to James for the hint)

Have fun and let me know how it works  ;)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.2.2-->
<commandGroup open="True" name="final jokes command" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="321" name="read jokes without doubles" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.OpenFile</cmdType>
      <params>
        <param>{Path.VC}\testjoke.txt</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>150</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Window.Focus</cmdType>
      <params>
        <param>notepad</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>150</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyDown</cmdType>
      <params>
        <param>shift</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>50</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyPress</cmdType>
      <params>
        <param>downarrow</param>
        <param>leftarrow</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>50</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyUp</cmdType>
      <params>
        <param>shift</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>50</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyDown</cmdType>
      <params>
        <param>control</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyPress</cmdType>
      <params>
        <param>x</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyUp</cmdType>
      <params>
        <param>control</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyPress</cmdType>
      <params>
        <param>delete</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>50</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyDown</cmdType>
      <params>
        <param>leftalt</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyPress</cmdType>
      <params>
        <param>f4</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyUp</cmdType>
      <params>
        <param>leftalt</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>50</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>DxInput.KeyPress</cmdType>
      <params>
        <param>return</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>System.GetClipboardText</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.AppendLine</cmdType>
      <params>
        <param>{Path.VC}\testjoke.txt</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>tell me a joke, tell me an other joke, one more joke please</phrase>
  </command>
</commandGroup>
« Last Edit: May 13, 2014, 02:35:14 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: tell me a story tell me a joke tell me a puzzle
« Reply #17 on: May 12, 2014, 09:48:07 PM »
Hey Kalle.

Fun solution.  Of course it is no longer random but that is OK.

Just remember that not everyone has notepad set as their default for .txt files!  I just removed the focus action and it worked fine.

Those jokes are pretty funny.  Bridget reads them very well.

sirs2k

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #18 on: May 16, 2014, 03:32:30 PM »
Kalle, that's genius mate. Love it!

Only minor inconvenience if your screen is on is you'll keep seeing the notepad popping up and out every time.
Tried turning off focus but didn't do anything. I guess there's no way to do that process in the background?

Another thing I've been dying to do with the TTS system (yes it is Ivona's Brian) is I want it to emphasize some words or speak them a little louder! You know, how you usually tell a joke.
I've tried the <emph> word </emph> but there's absolutely no difference.

One more really cool thing but I don't think this one can be done, is to change the voice. Telling a joke for example from a male then changing to a female.
Imagine building a conversation between the two.  ;D

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #19 on: May 16, 2014, 03:56:01 PM »
In my case the read/write is extrem fast, so I noticed the windows only for milliseconds.
To change the voice is no problem, but to know on which part of the joke to do is the problem.
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: tell me a story tell me a joke tell me a puzzle
« Reply #20 on: May 16, 2014, 04:40:12 PM »
You can do it without using a window too.  This is still not random though, it is just reading the first joke and then moving it to the end of the file.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.4.1-->
<command id="321" name="read jokes without doubles" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>File.Read</cmdType>
    <params>
      <param>testjoke.txt</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExSingle</cmdType>
    <params>
      <param>^(.*?)\r\n</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>{Match.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{Match.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>^(.*?)\n</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>File.Write</cmdType>
    <params>
      <param>testjoke.txt</param>
      <param>{LastResult}{CR}{Match.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>tell me a joke, tell me an other joke, one more joke please</phrase>
</command>

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #21 on: May 17, 2014, 06:08:59 AM »
Great  ::bow
***********  get excited and make things  **********

sirs2k

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #22 on: May 17, 2014, 10:57:46 AM »
That done the trick James. Thanks mate.

So I'm assuming you guys can't think of a way yet to emphasize specific words or how to change voices when speaking?

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #23 on: May 17, 2014, 11:07:30 AM »
You can test    , ! ? ; " ' / -   before or after the word, some TTS voices support this.
It is not possible to change the voice during it speak.
« Last Edit: May 17, 2014, 11:10:35 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: tell me a story tell me a joke tell me a puzzle
« Reply #24 on: May 17, 2014, 11:19:00 AM »
That done the trick James. Thanks mate.

So I'm assuming you guys can't think of a way yet to emphasize specific words or how to change voices when speaking?

I think the link I sent you earlier shows how you can change the voice.  I think it works.

http://msdn.microsoft.com/en-us/library/ms717077(v=vs.85).aspx#Voice_Selection

It also tells you how to emphasize words, however not all TTS engine will implement the same "standards".  Ivona allows you to emphasize words using this standard: http://www.w3.org/TR/speech-synthesis/#S3.2.2 however it will depends on the word and which voice you are using.  You may not notice a big difference, and at some point it seems like too much work to set it up, and you might as well play a random joke audio file instead.

Note that in order to use xml markup with TTS.Speak you must have a tag at the very beginning of the text or it will assume you are not sending it xml, and it will actually just try to read the xml tags as text.

keithj69

  • $upporter
  • Sr. Member
  • *****
  • Posts: 113
  • Karma: 7
    • View Profile
Re: tell me a story tell me a joke tell me a puzzle
« Reply #25 on: May 18, 2014, 09:35:51 AM »
You all are great.  I was looking into this idea earlier this week and put it on hold.  I used Kalle's last command group with James command (i use notepad++).  
All is great,except the jokes do not complete.  It seems it makes it about 2/3 of the way through the long jokes (testjoke.txt).  Is there a limitation on length of the joke?

I figured it out.  I was having voxwav read back and the tts response box has the limit on the phone.Once i turned on the pc speaker it works as advertised. 
« Last Edit: May 18, 2014, 09:50:09 AM by keithj69 »