Is there a simple list of options one can use with "do_command"?

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Emerogork
Posts: 314
Joined: Wed May 18, 2011 11:56 pm
Operating System: Windows 10

Re: Is there a simple list of options one can use with "do_command"?

Post by Emerogork » Sat Sep 05, 2020 6:38 am

steve wrote:
Thu Sep 03, 2020 8:32 pm
Emerogork wrote:
Thu Sep 03, 2020 6:52 pm
After making three corrections in the command line interface code, I finally got it to work.
What were they?
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....
Last edited by steve on Sat Sep 05, 2020 9:43 am, edited 1 time in total.
Reason: fix quote tags

Emerogork
Posts: 314
Joined: Wed May 18, 2011 11:56 pm
Operating System: Windows 10

Re: Is there a simple list of options one can use with "do_command"?

Post by Emerogork » Sat Sep 05, 2020 7:08 am

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("Record1stChoice")
do_command("AddLabel: Text = ThisList[T]")
time.sleep(10)
do_command("Stop")

print(" Done")
-----------------------------------------

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?)

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

Re: Is there a simple list of options one can use with "do_command"?

Post by steve » Sat Sep 05, 2020 9:46 am

Emerogork wrote:
Sat Sep 05, 2020 7:08 am
Apparently a file with a .py extension will not attach.
You will be able to attach it by adding ".txt" to the file name. For example: "my_program.py.txt"
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Is there a simple list of options one can use with "do_command"?

Post by steve » Sat Sep 05, 2020 10:26 am

Emerogork wrote:
Sat Sep 05, 2020 7:08 am
What is wrong with my AddLabel command?
Your label command:

Code: Select all

"AddLabel: Text = ThisList[T]"
but the manual says:
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.

Code: Select all

SelectTime:End="5" RelativeTo="ProjectStart" Start="5"
AddLabel:
SetLabel:Label="0" Text="Hello"
SelectTime:End="16" RelativeTo="ProjectStart" Start="15"
AddLabel:
SetLabel:Label="1" Text="World"

(Note that double quotes, if used, will probably need to be escaped in your script)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Emerogork
Posts: 314
Joined: Wed May 18, 2011 11:56 pm
Operating System: Windows 10

Re: Is there a simple list of options one can use with "do_command"?

Post by Emerogork » Mon Sep 07, 2020 7:13 am

SelectTime:End="5" RelativeTo="ProjectStart" Start="5"
AddLabel:
SetLabel:Label="0" Text="Hello"
SelectTime:End="16" RelativeTo="ProjectStart" Start="15"
AddLabel:
SetLabel:Label="1" Text="World"

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.
Insights welcome.

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

Re: Is there a simple list of options one can use with "do_command"?

Post by steve » Mon Sep 07, 2020 11:09 am

Emerogork wrote:
Mon Sep 07, 2020 7:13 am
This doesn't seem to work for me
What's happening?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Is there a simple list of options one can use with "do_command"?

Post by steve » Mon Sep 07, 2020 11:11 am

Perhaps worth trying the commands using pipeclient's command line interface - by default, it prints Audacity's response to each command, so you can see immediately if a command fails.

This is what I get:

pipeclient.png
pipeclient.png (181.5 KiB) Viewed 101 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Emerogork
Posts: 314
Joined: Wed May 18, 2011 11:56 pm
Operating System: Windows 10

Re: Is there a simple list of options one can use with "do_command"?

Post by Emerogork » Mon Sep 07, 2020 2:59 pm

steve wrote:
Mon Sep 07, 2020 11:09 am
Emerogork wrote:
Mon Sep 07, 2020 7:13 am
This doesn't seem to work for me
What's happening?
Oop. sorry for the lame entry.
I get the track note but no wording in the label.
It is as if all I did was hit ^b.
No "Hello" and no "World".

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

Re: Is there a simple list of options one can use with "do_command"?

Post by steve » Mon Sep 07, 2020 4:40 pm

Emerogork wrote:
Mon Sep 07, 2020 2:59 pm
I get the track note but no wording in the label.
Does your project already have some labels? If it does, then the label index number will not be correct in
SetLabel:Label="0" Text="Hello"

If you're using "pipe_test.py", you will need to escape the double quotes:

Code: Select all

"SetLabel:Label=\"0\" Text=\"Hello\""
Have you tried from the command line with pipeclient? Can you reproduce my results if you start with a new, empty project?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Emerogork
Posts: 314
Joined: Wed May 18, 2011 11:56 pm
Operating System: Windows 10

Re: Is there a simple list of options one can use with "do_command"?

Post by Emerogork » Mon Sep 07, 2020 7:51 pm

I will explore pipeclient but it may take a while to report back. I have two other large projects taking stage.
Thanks..
P.S., I did try the "\" escapes in the line pipe_test.py but still no text being sent to the label. So close.....

Post Reply