Author Topic: random line read for TTS  (Read 7910 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: 7714
  • 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: 7714
  • 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: 1999
  • 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: 7714
  • 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: 1999
  • 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: 1999
  • 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: 1999
  • 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: 1999
  • 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)