Skip to main content

Python package for the Audacity scripting interface

Project description

Python package for issuing scripting commands to Audacity.

This comprises a set of Command classes, each of which represents a single Audacity scripting command. These can be issued to a running Audacity process with the cheek.commands.do() function.

There is also a command-line interface which has a subcomand for each scripting command. This allows you to drive Audacity using a shell or other non-Python interface.

Command classes

The scripting command classes are implemented in the cheek.commands submodule as subclasses of cheek.commands.Command. These use pydantic to express their arguments. NB: we automatically generate these classes based on the output of Audacity’s GetInfo command. See below for more details.

At the time of writing, not all Audacity scripting commands are fully implemented. In particular, those which require parameters are not all done. Those without parameters are generally complete, though there may be bugs or gaps.

Basic programmatic use of a command is something like this:

from cheek.commands import AddLabel, SetLabel, do

do(
    AddLabel(),
    SetLabel(Label=0, Text="Label text", Start=123.456)
)

From the command line that might look like this:

cheek AddLabel
cheek SetLabel --Label 0 --Text "Label text" --Start 123.456

Tests

There are a few tests, though we’re very, very far from comprehensive. Really, since real testing would require determing that Audacity was doing the right thing, it’s probably not practical to really test this too fully. But if you’ve got ideas about testing, we could merge them in.

Re-generating the Command subclasses

We can use the output from the scripting command “GetInfo” to regenerate all of the Command subclasses. Right now this is a bit rough, but here’s what to do.

First, execute “GetInfo(‘Commands’, ‘JSON’)” and capture the output. You can do this with cheek itself, or pyaudacity, or whatever. The JSON you get is likely to be invalid at first, so you’ll need to clean it up. It should be clear how to do this.

Save this cleaned-up JSON to a file, e.g. “commands.json”. Then run:

python -m cheek.extract commands.json > src/cheek/commands.py

That should do it. You may want to run this generated Python through a formatter, though it should be valid Python as-is. Commit the new commands.py to git and you’ll have an updated command set. Copyright (c) 2024 Austin Bingham

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cheek-0.0.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

cheek-0.0.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file cheek-0.0.1.tar.gz.

File metadata

  • Download URL: cheek-0.0.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for cheek-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cfb5096a621b6d4b49a2a3b79c46c0ef3cff4b767a4bb7780845a22ca5e5df87
MD5 aba98152bbefef97fb097e78abac1f21
BLAKE2b-256 33b0b1f09e5f3e406c27ba627d425d305a023f7080792c8f8e0355d4e46ecea3

See more details on using hashes here.

File details

Details for the file cheek-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cheek-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for cheek-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c591c956503b1405cce3a0fbbaf46d66129e08c379b2b8dd225c96a0229afa36
MD5 fe1bfaa10381fd76d32c25bb529e1a20
BLAKE2b-256 33832faa6d1af9b007576a8c107bacf71e7d4c28df8df83249774b38247871b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page