Scripting
Any scripting language that supports named pipes can be used.
- The full set of Scripting Commands is listed at Scripting Reference.
- Many of the commands in the Scriptables I and Scriptables II menus were created because they are useful in scripting.
- Alternatives to Python scripting that use the same set of commands are:
What Scripting can do
Commands that Scripting uses are the same as in the Audacity macros feature. You can for example:
- Select audio
- Apply effects
- Rearrange clips
- Export the results.
Scripting goes beyond the simpler tasks and presets of macros. Using Python scripting can for example do calculations about regions to select, or can make decisions on the basis of number and types of tracks in a project. It is also possible to build additional user interface in Python, for example an extra toolbar, and have it send commands to Audacity over the pipe.
Contents
Caveats and Warnings
Getting Started
Enable mod-script-pipe
Audacity now comes with a plug-in module called "mod-script-pipe". You enable it using the Audacity preferences.
After enabling it for the first time, you will need to restart Audacity. You can then check that it is enabled and was started by revisiting the preferences page.
- Run Audacity
- Go into edit->preferences->modules
- Choose mod-script-pipe (which should show 'New') and change that to 'Enabled'.
- Restart Audacity
- Check that it now does show 'Enabled'.
This establishes that Audacity is finding mod-script pipe, and that the version is compatible (compiled on the same day).
Check mod-script-pipe works
You'll also need the scripting language Python (version 3.6 or later recommended) to try out the examples.
This python script is then the best way of checking that the pipe is working:
Using Scripting
After running pipe-test.py, you can use do("") at the python command line to try out commands. Each command name ends with a colon, and may be followed by parameters. For example:
do("Help:")
Examples
More sample scripts are available here:
- 'pipe work' - Sample scripts for exercising the pipe.
Commands
A table showing all the available scripting commands is at Scripting Reference.
Most commands in Audacity that are in the Audacity menus can be accessed via Scripting. Here is one example from that table:
Automation Id | Action | Parameters | Description |
---|---|---|---|
SetLabel: | Set Label... | int Label, (default:0) string Text, (default:unchanged) |
Modifies an existing label. |
The following command in Python would set the first label in a project to the word 'Foo'.
do("SetLabel: Text='Foo'")