batch command not recognized

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
perlAudacity
Posts: 7
Joined: Fri Jul 20, 2018 5:54 pm
Operating System: Windows 10

batch command not recognized

Post by perlAudacity » Mon Aug 27, 2018 4:50 pm

hi all, I am trying to use the perl script in pipe_test.pl. Whenever I try to implement a command in a subroutine, I get an error message that the batch command isn't recognized. so far, my code is just this:

Code: Select all

startUp();
menuCommand("Play");
finish()
and this is the error message I get

Code: Select all

[MenuCommand: CommandName=Play]
Your batch command of MenuCommand was not recognized.
BatchCommand Finished: Failed!
I also tried to use

Code: Select all

getMenuCommands(); 
and I get the same error message. I have reviewed the commands in the documentation here (https://manual.audacityteam.org/man/scripting.html) and I can't figure out why these simple commands don't seem to work.

Also, I wonder if what I am trying to script in audacity is even possible with scripting. I'd like to use audacity's noise reduction feature. Thank you!

steve
Site Admin
Posts: 48678
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: batch command not recognized

Post by steve » Mon Aug 27, 2018 10:45 pm

Which version of Audacity?
Which operating system?
Did you build Audacity with mod-script-pipe enabled?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

perlAudacity
Posts: 7
Joined: Fri Jul 20, 2018 5:54 pm
Operating System: Windows 10

Re: batch command not recognized

Post by perlAudacity » Tue Aug 28, 2018 2:43 pm

Sorry!
Audacity version 2.3.0-alpha-May 17 2018
Window 7 Professional (6.1.7601)
Mod-script-pipe is enabled

steve
Site Admin
Posts: 48678
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: batch command not recognized

Post by steve » Tue Aug 28, 2018 3:15 pm

Are you at all familiar with Python?
Perl "should" still work, but I am not at all familiar with it.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

perlAudacity
Posts: 7
Joined: Fri Jul 20, 2018 5:54 pm
Operating System: Windows 10

Re: batch command not recognized

Post by perlAudacity » Tue Aug 28, 2018 7:08 pm

No, unfortunately I am not familiar with Python :(
Is that scripting better supported? Perhaps I could learn. Also, is it even possible to automate the process I want (noise reduction)?

steve
Site Admin
Posts: 48678
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: batch command not recognized

Post by steve » Tue Aug 28, 2018 8:43 pm

Yes, Python scripting is better supported, though basically any language that supports named pipes should work.

There's a lot of new scripting features in Audacity 2.0.3.
Here's some links to relevant sections in the 2.0.3 alpha manual:
https://alphamanual.audacityteam.org/man/Scripting
https://alphamanual.audacityteam.org/ma ... _Reference

The easiest way to get started with scripting from Python:

1) Install Python 3 (https://www.python.org/downloads/)
I don't use Python on Windows (my main OS is Linux), so I'll hand over to the Python "Beginners Guides" to help you install and get started: https://wiki.python.org/moin/BeginnersGuide

I'm going to assume that you are able to get as far as a Python prompt. It looks like:

Code: Select all

>>>
2) In the Audacity source code there is a folder /scripts/piped-work/
Open a Python prompt from that folder.
To check that you are in the correct folder:

Code: Select all

>>> import os
>>> print(os.getcwd())
That will print the current working directory.

3) Import the module "pipeclient" from the pipeclient.py file that is in /scripts/piped-work/

Code: Select all

>>> import pipeclient
4) Create a client instance:

Code: Select all

>>> client = pipeclient.PipeClient()
5) Send a command, for example, to start playback:

Code: Select all

>>> client.write("Play:")
6) Read the last reply:

Code: Select all

>>> print(client.read())
For more information about pipeclient, open the pipeclient.py file in a text editor and read the docfiles at the top of the page.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

perlAudacity
Posts: 7
Joined: Fri Jul 20, 2018 5:54 pm
Operating System: Windows 10

Re: batch command not recognized

Post by perlAudacity » Wed Sep 05, 2018 12:37 pm

Hi! I can follow your instructions - thank you!! I have two further questions.

1. How do I give these commands input? So for example, if I want to automatically set the left boundary to 1min 25.670seconds, how could I use the "SetLeftSelection:" command?

2. I understand how to use the command line, but how do I put all these commands into a python script to be run automatically? I tried running mod-script-pipe but I get an error that says "FileNotFoundError: [Errno 2] No such file or directory: '\\\\.\\pipe\\ToSrvPipe'"

perlAudacity
Posts: 7
Joined: Fri Jul 20, 2018 5:54 pm
Operating System: Windows 10

Re: batch command not recognized

Post by perlAudacity » Wed Sep 05, 2018 4:18 pm

Hi again,

I figured some more things out. I can use the "SelectTime:" command to get what I want. Now my question is, when I use the "Get NoiseReduction...:" command, how do I access the dialog box to set the noise profile or (after I've selected all the audio) to click "ok" to get the noise reduction to run?

Thanks!

steve
Site Admin
Posts: 48678
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: batch command not recognized

Post by steve » Wed Sep 05, 2018 5:34 pm

perlAudacity wrote:
Wed Sep 05, 2018 4:18 pm
ow my question is, when I use the "Get NoiseReduction...:" command
This is a trick one. If you've looked in the pipe_test.pl file, you may have noticed:

Code: Select all

sub getEffects{

   # (These ones will need special handling)
   # AutoDuck
   # Bass and Treble
   # Repair
   # NoiseRemoval
   # ClickRemoval
   # Paulstretch
I think you will need to look outside of Audacity's commands and emit keystrokes directly from Python.

Here we get into murky platform specific issues because Windows, Mac and Linux have different ways of handling key events. Fortunately (I hope), there is a " cross-platform GUI automation Python module" called "PyAutoGUI". I've not used this myself, but it looks like a good bet: https://pypi.org/project/PyAutoGUI/
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply