is there any way in Audacity to create a GUI panel with several (around 20) text buttons, where clicking one of these buttons performs a command (or macro) on the currently selected audio fragment in a track?
The goal here would be to make labeling of audio fragments in audio tracks more easy: you would select a fragment of an audio track and then click the button with the wanted label, and a new label would be inserted for the currently selected audio fragment, with the text of that new label set to some text string setup for the clicked button (where that text string could be different from what’s shown on the button widget).
I was able to add a simple keyboard shortcut for the “Labels - Paste Text to New Label” command, which works nicely.
I also looked into a way to use macro’s to also set the text for the label for the selected audio fragment, but couldn’t find a way to do that. And in any case: doing it that way would require 20 different keyboard shortcuts (one for each label), and especially also remembering the different keyboard shortcuts… which is not very user-friendly…
So, having a simple button panel that can perform a command or macro that inserts a label with a specific text string for the currently selected audio fragment would be great.
Any idea if this is possible? And if so, how?
(If that doesn’t work, another option would be to create a simple static web page or standalone application that shows the different label buttons and copies a label string to the clipboard + then switch back to Audacity and press the keyboard shortcut for “Labels - Paste Text to New Label” mentioned above. You would need to constantly switch app focus then of course.)
Notice that the text options appear in two places.
;control text “Label Text” choice "> Hello,World,ABC,Audacity> " 0
and these lines:
(setf text (case text
Both lists must match.
By default it will create a new label in a new label track.
You will probably prefer to make all the labels in one track, so to do that, make the selection in both the audio track and the label track like this:
thanks so much for taking the time to reply with so much detail. I really appreciate it!
It also easily managed to install the plugin and get it to work in Audacity on Windows.
I also tried changing the text strings in the “setf” block, so that they are different from the ones in the “;control” line, and that does still appear to work (the number and order of the strings must still correspond of course).
This is already a good step, but I’m afraid that in practice, the way this works would still be too cumbersome for someone to annotate hundreds of files and create thousands of individual labels.
Allow me to explain (this is by no means criticism to your highly appreciated reply of course, just things I bring up that might have a solution perhaps, to make this work better):
You have to click twice each time to bring up the panel + it disappears after applying a label: the panel should stay open on top of the Audacity window (like a floating panel), or otherwise as a dockable panel. Can that be done?
Selecting and applying the right label to the current selection also takes 3 clicks: selecting the list box, choosing the label and then clicking OK. I would really like to have a panel of buttons (one for each possible label) that you can simply click. Are button controls possible too? And can you arrange them in specific positions on the panel?
The fact that you have to select both the audio track and the label track is going to be annoying for annotators: is it possible in some way to only make the selection in the audio track? When I use a keyboard shortcut for the “Paste text to new label” that seems to work fine (without having to select also in the label track).
The way it would work best is like this:
open button panel (which remains open all the time)
open sound file to annotate (via File menu)
select sound fragment in audio track (1x click and drag + maybe some fine-tuning of the selection)
click label button in panel to insert a label for the selection (1x click)
repeat from 3. for all interesting sound fragments in the audio file
export labels (via File menu, or via keyboard shortcut)
close project (via File menu, or via keyboard shortcut)
repeat from 2. for all sound files to annotate
It would be so great if this workflow would be possible with Audacity.
A bit unrelated, but maybe you have an answer nonetheless: I noticed that when I use the “Paste text to new label” command, it works nicely, but the label text box remains active / in edit mode. This also happens when you (single) click the text of another label.
If you then press the “space bar” to listen to the labeled fragment, you insert spaces in that label’s text…
So, you always need to press “escape” right after you select a label before you can press “space bar” to play the sound.
Is there a command exit the edit mode of the label text?
Perhaps annotators are too easily annoyed
With a single track of audio in a project, it is very easy to make a selection in the audio track and drag the selection down to include the label track, all in one movement. After the first few hundred labels the gesture becomes habitual.
I agree that it is not so convenient in the case of more complex projects with multiple tracks, but in this case there may also be multiple label tracks, and the plug-in needs to know which label track to use. Does the user want to use the first label track, or the last, or the first one below the selected audio track, or the label track nearest to the selected audio track, or a new label track, or some other label track?
It would be possible to use a (rather complicated) workaround so as the force all labels created by the plug-in to appear in one specific label track, but doing so is not going to please everyone (because different people are likely to want different things), and it would be a lot more work for the plug-in programmer.
The “normal” way to “close” a label’s text is to press “Enter”.
“Esc” also works because it “escapes” (jumps out of) the label’s text edit (whereas “Enter” closes the edit).
The fact that the text box remains open is very useful in some cases. For example, say that you wanted to label sections as:
Then all that you need to do is to paste "Part ", then type “1” and “Enter”.
If the label text automatically closed, then it is unnecessarily to reopen the label, ensure that the cursor is at the end of the pasted text, then type “1” and “Enter”.
Once again: thanks for you feedback and insights!
And I understand why some things are handier the way they are now in Audacity for some purposes.
About annotators: well, I’ve done that hard work myself (but in a DAW using MIDI tracks using note numbers and note lengths)
I think my conclusion is that it’s indeed not possible at the moment with what’s available in Audacity.
I considered the text window and copying pasting, but that is also very annoying…
So, I’m going for a simple static web page with all my buttons, and each button copies the label ID to the clipboard. Then I can simply press my keyboard shortcut in Audacity to “Paste text as label”. Already did a quick test, and it works nicely! Only thing is you need to switch between 2 apps all the time, but arranging them next to each other should work fine.
I didn’t know you could script Audacity via Python too (I had seen Nyquist mentioned here and there, plus the macro’s of course).
This may indeed also provide a good solution: creating a small standalone Python GUI with the buttons, connected to Audacity via that pipe.
Maybe we’ll see how far we get with the simple static web page + keyboard shortcut to paste text as label (no extra installation necessary, no need for us to build an executable from the Python code) and if we notice it’s not “fluent” enough yet that way, we will look into that option.