Author Topic: Save the audio file from VoxWav to a custom folder.  (Read 20637 times)

0 Members and 1 Guest are viewing this topic.

thesystemera

  • $upporter
  • Sr. Member
  • *****
  • Posts: 125
  • Karma: 0
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #45 on: August 06, 2013, 02:18:24 AM »
One small problem.  The variable I have to use is {1} not {LastResult}.  How would I transfer {1} to {LastResult}?

thesystemera

  • $upporter
  • Sr. Member
  • *****
  • Posts: 125
  • Karma: 0
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #46 on: August 06, 2013, 02:28:26 AM »
Don't worry worked it out!  Results.SetLastResult :D

thesystemera

  • $upporter
  • Sr. Member
  • *****
  • Posts: 125
  • Karma: 0
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #47 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!!!  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

  • $upporter
  • Sr. Member
  • *****
  • Posts: 125
  • Karma: 0
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #48 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.

Code: [Select]
<?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

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #49 on: August 06, 2013, 04:02:13 AM »
yes exactly, that is the way how you can replace the hole stuff from your lastresult step by step - (multiple replace actions)
« Last Edit: August 07, 2013, 06:21:59 PM by Kalle »
***********  get excited and make things  **********

thesystemera

  • $upporter
  • Sr. Member
  • *****
  • Posts: 125
  • Karma: 0
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #50 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?

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #51 on: August 06, 2013, 06:44:25 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"?
« Last Edit: August 06, 2013, 06:56:47 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Save the audio file from VoxWav to a custom folder.
« Reply #52 on: August 06, 2013, 10:39:10 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.

Code: [Select]
<?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.

Code: [Select]
<?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>
« Last Edit: August 06, 2013, 10:46:14 AM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Save the audio file from VoxWav to a custom folder.
« Reply #53 on: August 06, 2013, 10:54:07 AM »
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:

Code: [Select]
<?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

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Save the audio file from VoxWav to a custom folder.
« Reply #54 on: August 06, 2013, 11:04:32 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

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Save the audio file from VoxWav to a custom folder.
« Reply #55 on: August 06, 2013, 11:12:35 AM »
Here's an example demonstrating how to grab paths, filenames and extensions
Code: [Select]
<?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

  • $upporter
  • Sr. Member
  • *****
  • Posts: 125
  • Karma: 0
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #56 on: August 07, 2013, 10:33:34 AM »
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

  • $upporter
  • Sr. Member
  • *****
  • Posts: 125
  • Karma: 0
    • View Profile
Re: Save the audio file from VoxWav to a custom folder.
« Reply #57 on: August 07, 2013, 11:08:03 AM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Save the audio file from VoxWav to a custom folder.
« Reply #58 on: August 10, 2013, 10:23:07 AM »
I am beefing up the savenextwav action and adjusting the payloads somewhat:

Here's the new documentation for the action:
Quote
The 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