batch command not recognized

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:

startUp();
menuCommand("Play");
finish()

and this is the error message I get

[MenuCommand: CommandName=Play]
Your batch command of MenuCommand was not recognized.
BatchCommand Finished: Failed!

I also tried to use

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!

Which version of Audacity?
Which operating system?
Did you build Audacity with mod-script-pipe enabled?

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

Are you at all familiar with Python?
Perl “should” still work, but I am not at all familiar with it.

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

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/man/Scripting_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:

>>>
  1. 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:
>>> import os
>>> print(os.getcwd())

That will print the current working directory.

  1. Import the module “pipeclient” from the pipeclient.py file that is in /scripts/piped-work/
>>> import pipeclient
  1. Create a client instance:
>>> client = pipeclient.PipeClient()
  1. Send a command, for example, to start playback:
>>> client.write("Play:")
  1. Read the last reply:
>>> 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.

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’”

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!

This is a trick one. If you’ve looked in the pipe_test.pl file, you may have noticed:

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: PyAutoGUI · PyPI

Hi,
I tried to run the piped python script(pipe_test.py) on a windows10 machine with python 3.4.2 and mod-script enabled in audacity, but it is showing the following message “Your batch command of XXXX was not recognized”. Can anyone please help me with this?

Please start a new topic (this topic refers to an old version of Audacity and things have changed).
In your new topic, please describe step-by-step how to reproduce the problem, including the exact commands that you are attempting to send.

I’m locking this topic to avoid confusion with the current version of Audacity.