News:

There is a soft-mute function which we use with the commands like "What song is this?" There is one for system volume, one for each of: MediaMonkey, XBMC, iTunes, MediaPortal.

Main Menu

Save the audio file from VoxWav to a custom folder.

Started by thesystemera, May 06, 2013, 11:18:30 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

thesystemera

One small problem.  The variable I have to use is {1} not {LastResult}.  How would I transfer {1} to {LastResult}?

thesystemera

Don't worry worked it out!  Results.SetLastResult :D

thesystemera

Okay I've got it but how do I replace with nothing!  If I ender nothing in to the second field it treats it as if to do nothing!!!  AARRGG!

I'm just using Replace, not RegExReplace.  That stuff is way too confusing.  Unlesss some one can help me.  I just want

Z:\Library\ShoutOuts\Processing\Shoutout123.wav   

to become

Shoutout123

so to remove the [Z:\Library\ShoutOuts\Processing\] and the [.wav]

thesystemera

Finally done it!  I looked up how to remove invalid characters and YUS! 

If I can simplify this, do tell me, but it works, that's the important thing.

<?xml version="1.0" encoding="utf-16"?>
<command id="647" name="Process ShoutOut" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetVar</cmdType>
    <cmdString>ShoutFile&amp;&amp;{1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <cmdString>{var.ShoutFile}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <cmdString>[^\w\.@-]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <cmdString>ZLibraryShoutoutsProcessing</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <cmdString>[.wav]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <cmdString>ShoutFile</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{var.ShoutFile}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Launch.RawParam</cmdType>
    <cmdString>C:\Program Files (x86)\sox-14-4-1\sox.exe&amp;&amp;"z:\library\shoutouts\processing\{var.ShoutFile}.wav" "z:\library\shoutouts\{var.ShoutFile}.wav" gain -n -3 silence 1 0.1 0.8% -1 0.5 0.8% contrast 50</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>TcpMic.WavSaved</event>
</command>

Kalle

yes exactly, that is the way how you can replace the hole stuff from your lastresult step by step - (multiple replace actions)
***********  get excited and make things  **********

thesystemera

I still have a weird issue.  The [^\w\.@-] is successfully removing the "\" symbol but it's also removing the letter "A".  Any idea's?

Kalle

Quote from: thesystemera on August 06, 2013, 06:02:11 AM
I still have a weird issue.  The [^\w\.@-] is successfully removing the "\" symbol but it's also removing the letter "A".  Any idea's?
Which "A"? I can't see any "A" in your file name, only the "a" in the word "Library" and "wav"

By the way, did you have tried first to replace "Z:\Library\ShoutOuts\Processing\" and as next ".wav"?
***********  get excited and make things  **********

jitterjames

#52
Quote from: thesystemera on August 06, 2013, 03:19:26 AM
Finally done it!  I looked up how to remove invalid characters and YUS!  

If I can simplify this, do tell me, but it works, that's the important thing.

<?xml version="1.0" encoding="utf-16"?>
<command id="647" name="Process ShoutOut" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
 <action>
   <cmdType>Results.SetVar</cmdType>
   <cmdString>ShoutFile&amp;&amp;{1}</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>Results.SetLastResult</cmdType>
   <cmdString>{var.ShoutFile}</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>Results.RegExReplace</cmdType>
   <cmdString>[^\w\.@-]</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>Results.RegExReplace</cmdType>
   <cmdString>ZLibraryShoutoutsProcessing</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>Results.RegExReplace</cmdType>
   <cmdString>[.wav]</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>Results.SetVar</cmdType>
   <cmdString>ShoutFile</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>OSD.ShowText</cmdType>
   <cmdString>{var.ShoutFile}</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>Launch.RawParam</cmdType>
   <cmdString>C:\Program Files (x86)\sox-14-4-1\sox.exe&amp;&amp;"z:\library\shoutouts\processing\{var.ShoutFile}.wav" "z:\library\shoutouts\{var.ShoutFile}.wav" gain -n -3 silence 1 0.1 0.8% -1 0.5 0.8% contrast 50</cmdString>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <event>TcpMic.WavSaved</event>
</command>


Wow.  This really confuses me.  It seems like you take all that extra stuff away, only to put it back in again in the Launch action.

By the way, if you only want the filename without the path you can use payload 3.  Look at the history window.  If you mouse over the event you will see the payloads associated with it.  At this point I'm a bit confused as to the difference between payload 1 and payload 2 and need to look at the code again to see what's up with that.

It seems like you just need to move the file from the processing folder up to the folder above.

<?xml version="1.0" encoding="utf-16"?>
<command id="664" name="Process ShoutOut James 01" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <cmdString>{1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.Replace</cmdType>
    <cmdString>shoutouts\processing&amp;&amp;shoutouts</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Launch.RawParam</cmdType>
    <cmdString>C:\Program Files (x86)\sox-14-4-1\sox.exe&amp;&amp;"{1}" "{lastresult}" gain -n -3 silence 1 0.1 0.8% -1 0.5 0.8% contrast 50</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>TcpMic.WavSaved</event>
</command>

jitterjames

As I mentioned, the {3} should contain the filename, but with the extension.

In any case, I think this example will help you a lot and give you some idea of how to use the regex replace action to your advantage:

<?xml version="1.0" encoding="utf-16"?>
<command id="665" name="replace" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Extract just the filename with no extension from a path.">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <cmdString>Z:\Library\ShoutOuts\Processing\Shoutout123.wav   </cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <cmdString>.*\\(.*)\.wav&amp;&amp;file name is: $1</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

jitterjames

Quote from: thesystemera on August 06, 2013, 02:54:11 AM
Okay I've got it but how do I replace with nothing!  If I ender nothing in to the second field it treats it as if to do nothing!!!

You are right, you can't do this with the standard replace action.  I should modify this to allow it!  You can do it with regex replace though.

jitterjames

Here's an example demonstrating how to grab paths, filenames and extensions
<?xml version="1.0" encoding="utf-16"?>
<command id="36" name="fun with paths and filenames" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <cmdString>c:\test\path\myfile.jpg</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>original: {LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <cmdString>^(.*)\\(.*?)\.(.*?)$&amp;&amp;path: $1\{CR}file: $2{CR}extension: $3</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

thesystemera

Thanks so much James.  I do want to cry a little though, I never knew about payload 3. 

One hell of a learning curve.  Thank you for your time guys.  Will have a play with this example now..:)

thesystemera

OMG!  It's that simple!  A few days on 13 ASCII characters!

Nah but seriously thankyou.  Going to have to read up on how to use these strings, will most likely need it in the future..

jitterjames

I am beefing up the savenextwav action and adjusting the payloads somewhat:

Here's the new documentation for the action:
QuoteThe next incoming audio stream will be saved to <Path> instead of being analyzed as speech.  If Path specified a folder that does not exist the folder will be created immediately.
If <AddTimeStamp> is True, then the filename will be modified to add a timestamp to the end of the filename.
If <AutoIncrement> is True, then an existing filename will have an index added to the end in brackets, starting at (1)
If <AutoIncrement> is False, and the file exists, it will be overwritten with the new wav file
After the new audio stream is saved an event will be generated with the following payloads
{1}  Full path and filename of the wav with extension (.wav)
{2}  Folder path only where the file was saved
{3}  Filename only with no extension