VoxCommando

New Features and Feature Requests => Feature Requests => Topic started by: zizos on November 29, 2011, 06:00:41 AM

Title: tell me a story tell me a joke tell me a puzzle
Post by: zizos on November 29, 2011, 06:00:41 AM
i think that we can make VC tell us a story or a joke or a puzzle  just by puting a coomand by the name

tell me a story

tell me a joke

tell me a puzzle 

i hop that you got my idea
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle on November 29, 2011, 06:49:23 AM
i think that we can make VC tell us a story or a joke or a puzzle  just by puting a coomand by the name

tell me a story

tell me a joke

tell me a puzzle 

i hop that you got my idea
Yes, you can use the TTS.speak command and put any text as command. Don't forget punctuation marks  ;)
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: zizos on November 29, 2011, 07:22:24 AM
thanks  Kalle

but can we add to VC for example a book of jokes or puzzles and its will read it for us   

why there is no option in VC to read from a file ?


Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle on November 29, 2011, 08:11:29 AM
thanks  Kalle

but can we add to VC for example a book of jokes or puzzles and its will read it for us   

why there is no option in VC to read from a file ?



I'm not sure that is possible with the "scrape" (copy and paste) commmand? I, will test it.
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: jitterjames on November 29, 2011, 11:11:22 AM
thanks  Kalle

but can we add to VC for example a book of jokes or puzzles and its will read it for us   

why there is no option in VC to read from a file ?




Zizos, I am not really understanding what you are looking for.  Where does this book come from?  What format is it in?  Do you want VC to read the whole thing from beginning to end?

I can add an action to read a complete .txt file and store it in {LastResult}. Then it would be up to you to do something with it.
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: jitterjames on November 29, 2011, 11:19:11 AM
actually Kalle is correct, you can use scrape action.  To read a text file called joke1.txt that is in the jokes folder of your F drive write.

Scrape    file:\\f:\jokes\joke1.txt

then you can use TTS.Speak  {LastResult}  or OSD.ShowText   {LastResult}.

or if you need to you can use regEx actions etc.

Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: zizos on November 29, 2011, 04:06:21 PM
thanks  jitterjames

thats exactly what i mean  :)
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: sirs2k on May 10, 2014, 02:22:32 PM
Having Jarvis tell a joke and puzzle are great for me, I wanted to ask something though.

Can we somehow put a PAUSE in the txt document somehow for ivona's Brian to pause when telling a joke for example?

Cheers
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: jitterjames on May 10, 2014, 03:08:28 PM
Yes.  Your TTS parameter should look something like this:

<volume level="100">hello <silence msec="1500"/> there</volume>

Here is an example:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.4.0-->
<command id="781" name="tts pause example" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>&lt;volume level="100"&gt;hello &lt;silence msec="1500"/&gt; there&lt;/volume&gt;</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>tts pause example</phrase>
</command>

and a reference:
http://msdn.microsoft.com/en-us/library/ms717077(v=vs.85).aspx

or you can also probably do it with a series of commas.

Hi there , , , ,  what's up. 

but it may vary depending on your TTS engine.

Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: nime5ter on May 10, 2014, 04:57:19 PM
Since this is reviving a very old thread, I just wanted to mention that in addition to the "scrape" action mentioned above, another that may be preferable for tasks such as reading aloud individual jokes from a text file is File.Read. http://voxcommando.com/mediawiki/index.php?title=Actions#Read

Particularly with the {Rnd.#.#} variable as a second parameter. http://voxcommando.com/mediawiki/index.php?title=Variables#Misc._variables

Might be helpful info for newer VC users.
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: sirs2k on May 12, 2014, 02:57:10 AM
Thanks guys,

James that worked great.
Although there were some things like the Pronunciation and Emphasize didn't work. They would be great to pronounce names etc. How would you write them in a txt file or in XML?

nime5ter,
Unfortunately I don't understand how I would do that, I tried to put the action to File.Read, then pointed it to the txt file but nothing is being read out.
Also I don't it would be better than the scrape method.

Personally I don't like the scrape method because sometimes it can repeat the same joke 5 times before moving on to another "random" joke.

Cheers,
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle on May 12, 2014, 07:13:24 AM
Hi sirs2k, let me try to explain nime5ter's solution:

Create a text file with some jokes (at best you use the windows editor). It is important that each joke is written in one line without carriage return between, because the action "file.read" can read the whole text when you insert no parameter, or specified lines what nime5ter suggest with the {Rnd.#.#} as parameter. So the parameter {Rnd.0.10} means a random line between 1 and 10 (depends on how much joke lines you have in this text file).

here is a example command group which show you how it works and also a attached demo joke text file which you must stored in VC mainfolder.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.2.2-->
<commandGroup open="False" name="jokes" 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>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>1</cmdRepeat>
    </action>
    <phrase>tell me a joke</phrase>
  </command>
</commandGroup>

I hope this example make it more clear  ;)

TIP: The IVONA Brian TTS for english is really good for such things, because it pronounce the jokes at best. (Ups, I noticed in a post above that you allready use IVONA Brian)
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: nime5ter on May 12, 2014, 10:35:03 AM
Unfortunately I don't understand how I would do that, I tried to put the action to File.Read, then pointed it to the txt file but nothing is being read out.
Also I don't it would be better than the scrape method.

Without seeing your command xml, and perhaps the file itself that you're trying to read and what messages you got back in your history window, I can't begin to speculate.

One reason for users in general to be aware of File.Read is that if they're not comfortable with regular expressions they can still use the simple trick of dividing their jokes or trivia snippets or whatever by line in order to achieve the same effect, without needing to use regex.

Both Scrape and File.Read are reasonable options that can be combined with regular expressions and variables such as {rnd.#.#} or {match.rnd} to do some powerful things. I was mainly just putting the alternative option out there for anyone who came across the thread, to point out to them actions they may not already be familiar with.

Quote
Personally I don't like the scrape method because sometimes it can repeat the same joke 5 times before moving on to another "random" joke.

That would have nothing to do with the Scrape action. Random is random. Flip a coin 20 times and see how many times in a row you see heads. Possibly, if you have more jokes, you'll have better luck not running into that scenario.



Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: nime5ter on May 12, 2014, 10:51:11 AM
Attached is a command group and text file to demonstrate 3 different methods for accomplishing the exact same thing. Note that one of those does not require regex, but for that one users will want to know how many lines there are in their file.

My command group expects the qi.txt file to be in the main VC directory. ... I'm using OSD.ShowText, but obviously you can change that to a TTS action instead.

That raises one other advantage of using File.Read with a {rnd.#.#} parameter rather than a regex solution: you are then just calling {LastResult}, so that you can have both TTS and an OSD window, without having to first save your random match as a variable. It's a simple, 2 or 3 action command.

... OK. Now back to my day job. :)

P.S. How to copy a command group xml file to your tree: Just drag'n'drop the file itself into your tree.
http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum#Importing_XML_files
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: jitterjames on May 12, 2014, 11:10:24 AM
That would have nothing to do with the Scrape action. Random is random. Flip a coin 20 times and see how many times in a row you see heads. Possibly, if you have more jokes, you'll have better luck not running into that scenario.

http://youtu.be/T4SVVKuOr0c?t=3m20s
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle 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>

Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle 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>
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: jitterjames 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.
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: sirs2k 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
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle 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.
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: jitterjames 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>
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle on May 17, 2014, 06:08:59 AM
Great  ::bow
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: sirs2k 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?
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: Kalle 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.
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: jitterjames 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.
Title: Re: tell me a story tell me a joke tell me a puzzle
Post by: keithj69 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.