I have been looking throughout the scripting guides supplies by Audacity but they all seem to describe options that are normally activated in audacity menu items. They are not in any kind of format that can be used in scripting.
I accidentally entered "do_command(“NEW”) which opens a new track if Audacity is open. Also: "do_command(“Close”) which closes Audacity. I have spent at lease an hour looking for any other commands to use.
At the moment, I need to program creating a label, naming a label, Start and end record.
Is there a list?
Can someone send the do-command for the ones I listed?
I assume that you are referring to “do_command” from “pipe_test.py”?
That Python script is really only intended for testing (as the name suggests). To build a Python app that will do something useful, I’d suggest using the “pipeclient.py” module.
After making three corrections in the command line interface code, I finally got it to work. I can now see a request to enter Q to quit and it works. I also see that a READ_NAME and a WRITE_NAME files have been added to my folder and are empty.
Then I looked at the scripting URL and it sent me right back to the same page that has not made sense all along. I see not one example on how to create the command. In the test program, I saw the “do_command” line and guessed to use “NEW” and “Close”. It worked. No information from the scripting docs helped. I probably have to keep on digging.
“I assume that you are referring to “do_command” from “pipe_test.py”?
That Python script is really only intended for testing (as the name suggests). To build a Python app that will do something useful, I’d suggest using the “pipeclient.py” module.”
Well, I was able to achieve the execution of two commands using pipe_test.py and none with command line interface program from github.
This is starting to look like “Why do it in 65 lines of code when 298, with significant rework, will do?”
Again, I find that “do_command(New)” and “do_command(close)” work in the test program.
All I want is the do-command lines for record, stop, create label, name label.
Can anyone help me?
line = read_pipe.readline()
# Stop timer as soon as we get first line of response.
stop_time = time.time()
If “WRITE_NAME” file does not exist, “_write_pipe_open” will wait until it does, but that is non-blocking because it is a separate thread. “_write_thread_start” will then throw an error: “PipeClientError: Write pipe cannot be opened.”
“WRITE_NAME” is the “pipe” that allows Python to connect to Audacity (Named pipe - Wikipedia). It must be created by Audacity. If Python creates it, then it’s just a file, not a pipe into Audacity.
Forgive me, I cannot believe how much I screwed up on this one. I have three very large programs that I am working on almost simultaneously. I am linking python to Audacity, python to Excel, and a huge code in python to help me manage my insulin. All three are receiving code that is new to me.
I responded to what I thought was in error in the pipe_test not realizing that the open call was using a variable instead of a file name and “corrected” it accordingly. I made it all worse by posting the mix up.
What’s more, I then opened a different browser, attempted to log in and messed up the password enough times that I became locked out and had to use captcha numerously to get back on. YUCK…
Ok, for fear of the worst, I have made significant head way getting python to talk to Audacity.
Unless someone can suggest why the pipe_test.py is not a good choice, I plan to use it unless shown otherwise. It is short, simple, and is performing the way I want.
The loop runs as I want except for one command.
while T < 5:
T += 1
t = str(T)
print(" Track name " + t + " = " + ThisList[T])
do_command(“AddLabel: Text = ThisList[T]”)
As it is, this program will generate five tracks of 10 second recordings.
Each track will have blank labels.
Eventually, T will be 23 and time.sleep(10) will be an hour.
Right now, t = 5 and sleep is 10 seconds.
I would like to have the label for each track reflect the ThisList[T] entry in the list.
The ThisList list contains 4 letter codes for each entry.
What is wrong with my AddLabel command?
Is there a different way to do this?
(Apparently a file with a .py extension will not attach. yes?)
AddLabel: > - (Action) Add Label at Selection - (Parameters) > none > - (Description) Creates a new, empty label at the cursor or at the selection region.
“Text =” is not a valid argument (parameter), because “AddLabel:” does not take any arguments.
You will need to create an empty label (with “AddLabel:”) and then add the text to the label with “SetLabel: Label=[label number] Text=[label text]”.
For example, this will create a point label “Hello” at time = 5 seconds, and a region label “World” from 15 to 16 seconds.
This doesn’t seem to work for me. I would like to send the code to Audacity using do_command code. I am still experimenting with the pipe_test.py program because it is short and has worked up until now. Maybe I do have to use the other program.
I will explore pipeclient but it may take a while to report back. I have two other large projects taking stage.
P.S., I did try the "" escapes in the line pipe_test.py but still no text being sent to the label. So close…