Author Topic: random line read for TTS  (Read 6233 times)

0 Members and 1 Guest are viewing this topic.

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
random line read for TTS
« on: December 20, 2013, 12:49:46 PM »
i have been using tasker for android up until now and i got to the point where i was able to get the phone to read a file, pick a random line from that file and then say it.
i was wondering if a similar thing could be done with voxcommando?

hopefully i can read the same files as i do from tasker, so i can keep my phone configured the way it is.
thanks.
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: random line read for TTS
« Reply #1 on: December 20, 2013, 12:54:11 PM »
Where is the file located?  If the file is on your phone, then how would VC be able to read it?

Anyway if VC can access the file then yes it can be done.

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #2 on: December 20, 2013, 01:00:44 PM »
the file is in my dropbox folder, which is synced to my laptop through the dropbox app and synced to my phone through dropsync.
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: random line read for TTS
« Reply #3 on: December 20, 2013, 01:12:47 PM »
« Last Edit: December 20, 2013, 01:14:55 PM by jitterjames »

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #4 on: December 20, 2013, 01:27:53 PM »
is it possible to do it without knowing the number of lines? part of my reasoning for having it as a simple .txt file is so that i can easily and quickly add entries to the bottom.
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #5 on: December 20, 2013, 01:50:44 PM »
so far i have set it up like this...

file.read - C:\Users\Ryan\Documents\Dropbox\Public\L.U.C.A.S\Statements\intro.txt - {Rnd. 1. 8.}
TTS.Speaksync - LastResult

instead of saying one of my 8 commands, it says a percentage, followed by the time, and a bunch of other numbers?
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #6 on: December 20, 2013, 02:11:41 PM »
Your solution works for me as described. Maybe James will have thoughts on the odd result you're getting. (Possibly a "last result" still in memory from an earlier command?).

The following code will allow you to add new lines in your text file and select randomly no matter how many lines. You can select and then copy the code below and paste it directly into your command tree. (http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="726" name="tts random read" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>C:\Users\Ryan\Documents\Dropbox\Public\L.U.C.A.S\Statements\intro.txt</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>(.+)</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>{Match.Rnd}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>
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: random line read for TTS
« Reply #7 on: December 20, 2013, 02:16:26 PM »
so far i have set it up like this...

file.read - C:\Users\Ryan\Documents\Dropbox\Public\L.U.C.A.S\Statements\intro.txt - {Rnd. 1. 8.}
TTS.Speaksync - LastResult

instead of saying one of my 8 commands, it says a percentage, followed by the time, and a bunch of other numbers?

I don't have an opinion on this without seeing the actual text file and the actual result that is being returned.

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #8 on: December 20, 2013, 02:32:13 PM »
my creation was:

<macro>
<action actiontype="File.Read" repeat="1" logic="False"><paramstring>C:\Users\Ryan\Documents\Dropbox\Public\L.U.C.A.S\Statements\Intro.txt&amp;&amp;{Rnd.1.8}</paramstring></action>
<action actiontype="VC.Pause" repeat="1" logic="False"><paramstring>100</paramstring></action>
<action actiontype="TTS.SpeakSync" repeat="1" logic="False"><paramstring>{LastResult}</paramstring></action>
</macro>

nime5ter, is that suppose to be a new macro, or should it go under the current one? copying it as a standalone macro brings back the tts.speak "match.rnd"
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #9 on: December 20, 2013, 02:53:50 PM »
My code was for its own command. It is meant to be used *instead* of the command code you initially tried.

The main advantage is that my code allows you to select a line randomly from a file that may change over time without having to change your command all the time.

A command macro is made up of 'actions'. In your code above, it looks as though you copied the actions from within the logical command builder (aka the LCB, which is the macro builder), rather than right-clicking on the command itself directly in the command tree editor and copying from there.  (http://voxcommando.com/mediawiki/index.php?title=Customizing_Commands)

In general, on the forum we copy entire commands or entire command groups. This is done directly from the command tree window rather than from within the macro builder (LCB). This is the easiest way to share commands, whereas if you share the xml from the actions in the LCB it is more difficult for others to integrate into their own trees.
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)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #10 on: December 20, 2013, 02:58:40 PM »
nime5ter, is that suppose to be a new macro, or should it go under the current one? copying it as a standalone macro brings back the tts.speak "match.rnd"

It sounds like it is not finding matches in your text file. If it's not too private, it would be best if you could share your intro.txt file with us on the forum (i.e. attach it to a post).

Our advice is assuming that your txt file simply has a list of strings like this:

Code: [Select]
hello how are you
my name is joe
what time is it
bob's your uncle
take that sticky wicket
blah blah

Without other header info or other elements.
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)

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #11 on: December 20, 2013, 03:04:34 PM »
i have attached a copy of my file, i understand that all of my lines have "/" before the information however this is so that tasker can split the text into variables.

when doing it with the way i posted before, it was able to generate the line, it just said the / at the beginning
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #12 on: December 20, 2013, 03:13:15 PM »
If this is the way you intend to continue formatting your text file, the only thing you need to change is the string pattern in the Results.Regex action.

My command used the pattern (.+)

Change that to /(.+)

Should work.

[edit: it should have still worked with the original pattern, but as you say, announcing the / at the beginning (the new way cancels out the /). Not sure why it didn't work unless it couldn't find the file at the file path specified.]
« Last Edit: December 20, 2013, 03:19:43 PM 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)

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #13 on: December 20, 2013, 03:22:30 PM »
so it would become:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="735" name="tts random read" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>C:\Users\Ryan\Documents\Dropbox\Public\L.U.C.A.S\Statements\Intro.txt</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>/(.+)</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>{Match.Rnd}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

this still replies with "matchrnd"

i have verified that the file path is correct too.
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #14 on: December 20, 2013, 03:35:09 PM »
I'm officially flummoxed.

Can you copy your text file to your desktop for now, change the file path accordingly and test again?

(I assume you're using "save and execute" to test the command, since there's currently no trigger phrase or event associated with the command ...)
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)

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #15 on: December 20, 2013, 03:42:58 PM »
i have copied the file to desktop and changed the file path in the scrape. i also added a pause seeing as this is what i needed to do this to get the read random line 1-8 earlier.

it now reads
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="735" name="tts random read" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>C:\Users\Ryan\Desktop\Intro.txt</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>/(.+)</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>1000</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>{Match.Rnd}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Read Random</phrase>
</command>

i was using save and execute, however now i have added the "read random", still isnt working though :S have you had any luck?
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #16 on: December 20, 2013, 03:52:40 PM »
i was using save and execute, however now i have added the "read random", still isnt working though :S have you had any luck?

:) I have had no problems reading random statements from my text file or from the file you uploaded, either in a public dropbox folder, my desktop, wherever, using the initial xml that I shared. Hence my confusion.
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: random line read for TTS
« Reply #17 on: December 20, 2013, 03:56:24 PM »
Testing this last version exactly as is with your text file and it works perfectly.

You are probably using an old version, or possibly a cracked version of VC (which we do not recommend ;))

If you are using an uncracked version of VC version 1.1.8.2 it should work just fine exactly as you have posted it, as long as the path matches that of the file.

If you still can't get it to work, please turn on VC logging, test the command and then upload the log file.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: random line read for TTS
« Reply #18 on: December 20, 2013, 03:58:08 PM »
... i also added a pause seeing as this is what i needed to do this to get the read random line 1-8 earlier...

I can't think of any reason why a pause would be needed with either method.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #19 on: December 20, 2013, 04:00:12 PM »
when doing it with the way i posted before, it was able to generate the line, it just said the / at the beginning

Initially you said that you were getting a gibberish response using the file.read action:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="736" name="read file line" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>File.Read</cmdType>
    <cmdString>C:\YourPath\intro.txt&amp;&amp;{Rnd.1.8}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.SpeakSync</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

I just noticed here that it sounds like at some point this changed? When were you able to get the command to work, but saying "slash" at the beginning? Using which code?
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)

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #20 on: December 20, 2013, 04:06:18 PM »
looks like i was running an old version of voxcommando. when i installed it the other day, i used CNET downloads because i was having a problem getting onto the voxcommando website. just downloaded straight from vox.

finally getting somewhere. turned the /(.+) into (.+) and now i have a bit more success, saying the entire command, but including the / at the moment.
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #21 on: December 20, 2013, 04:07:18 PM »
i was getting gibberish because during the {Rnd.1.8} i had wrote {Rnd .1 8.}
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #22 on: December 20, 2013, 04:10:10 PM »
huge thank you nime5ter, all working and complete.
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: random line read for TTS
« Reply #23 on: December 20, 2013, 04:14:16 PM »
Glad it's working. I should have asked which version you were using earlier. Both {Rnd.1.x} and {Match.Rnd} were variables added in version 1.163.

(It's one thing we always ask users to state upfront--version number, for just this reason!  :bonk)
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: random line read for TTS
« Reply #24 on: December 20, 2013, 04:17:36 PM »
i was getting gibberish because during the {Rnd.1.8} i had wrote {Rnd .1 8.}
This is where the history window can come in handy (or the log file).

I created your command again using the incorrect parameter as you did: {Rnd .1 8.}

See the attached.  When you focus the main window, look at the history window and hover your mouse over the red item you can see that there is a problem with the parameter... it is expecting an integer and not getting one.  This would be a clue that you formated the random variable string incorrectly.  At the very least you should check to see if there are actions in your macro that are generating errors (and mention it when seeking support).

Thanks for the heads up about download.com

I will see about getting them to update to the latest version.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: random line read for TTS
« Reply #25 on: December 20, 2013, 04:25:34 PM »
Did you restart VC after changing the command? If not, tried it.
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: random line read for TTS
« Reply #26 on: December 20, 2013, 04:40:20 PM »
Hi Kalle, I think you did not read the whole thread...

huge thank you nime5ter, all working and complete.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: random line read for TTS
« Reply #27 on: December 20, 2013, 04:44:12 PM »
Hi James, you've right  :bonk
I've read only the first page - sorry  ::duh
***********  get excited and make things  **********

ryz4eva

  • Jr. Member
  • **
  • Posts: 40
  • Karma: -2
  • Chasing The Tech Dragon
    • View Profile
Re: random line read for TTS
« Reply #28 on: December 20, 2013, 04:48:22 PM »
can anybody tell me if its possible to ping an ip address from voxcommando?
Rocking:
Lenovo Ideapad Z580
Samsung Galaxy Note 10.1
LG Nexus 4
Voxcommando
Eventghost
XBMC Frodo
Vera Lite

View my site to see what im up to with vox...

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: random line read for TTS
« Reply #29 on: December 20, 2013, 05:00:30 PM »
Yes, you just use scrape.

but please try not to start new topics in an unrelated thread.  (we all do it, but anyway... please try  :P)

Sorry, I see that you started another thread here: http://voxcommando.com/forum/index.php?topic=1301.0

If you wanted to bump it that's OK.  Sometimes we miss stuff when there is a lot of other activity.
« Last Edit: December 20, 2013, 05:05:31 PM by jitterjames »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: random line read for TTS
« Reply #30 on: December 20, 2013, 05:04:39 PM »
Yes it is possible with a short python code.

Maybe James can help you  ::hmm
My english is not good enough to explain the steps  :bonk
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: random line read for TTS
« Reply #31 on: December 20, 2013, 05:09:40 PM »
I will respond on the other thread...