Labels from Text File

Hello all,

I apologize in advance for the long post. The requirements for the plug-in that I’m about to describe are fairly specific so I’m including as much detail as possible.

I work for a company that does quite a bit of voice over work for Flash-based training. The voice-over scripts are generally recorded straight through and then cut up later for use in Flash. Recently, we came up with the idea of using labels in Audacity to mark up the original audio file and then use the “Export Multiple” feature to automatically save out each section. This works very well but we have found that there are a few areas that could help us save more time.

Each audio file ends up with a special name or “slate” that specifies where it falls within the training. We can easily dump a list of these slates to a text file. We’d like to be able to turn these slates into “label” for each…er…label. :wink:

Example: Let’s say that we’re dealing with 5 slates (though we usually deal with many more than that.) We would like to have a text file with each slate on it’s own line (much like in the text files that Audacity generates when exporting labels.) When the user adds a label, our “dream plug-in” would then pull the slate from the text file based on the number of labels in the project. So in our example, if the selected label track had 3 labels and we added a fourth, the plug-in would look on the fourth line in the specified text file and copy the text from that line into the new label’s name.

I know that it is currently possible to export a list of labels to a text file, even if none of them have names. We’ve even considered marking the labels, exporting them, creating/running a script to copy the names onto each appropriate line and then re-importing the labels. Needless to say, this is not the ideal workflow. Instead, we’d like to have each slate named automatically.

So ultimately, my question is this: Is this the sort of thing that is possible to implement using Nyquist?

If you’ve made it this far, thank you very much for your time!

So you want to import a list of text into labels - one line of text into each label in sequence. If that’s right, then it sounds very possible to implement in Nyquist.
One thing that could be a potential problem is that Audacity becomes extremely slow when there is a lot of label text, though that is not usually a problem until there are hundreds of words/labels.

So where do you want to go from here? Do you have any experience with Nyquist or Lisp or any other programming?

Hey Steve,

So you want to import a list of text into labels - one line of text into each label in sequence.

Yep, that’s exactly right. I do have some programming experience but not with Nyquist or Lisp. I’m currently reading everything I can find on the subject so I can implement this feature (assuming that it’s possible with Audacity’s API.) Using some other scripts that I’ve found, I’ve been able to come up with a (very) basic script that adds a label to the active label track. From looking at the Nyquist/Audacity documentation (Nyquist Reference Manual and linked items at the top) it looks like I should be able to load data from a text file, so that shouldn’t be a problem.

However, I’m not at all sure how to get a list of labels that currently exist. Ultimately, I’ll need to be able to count the number of labels that exist (so I know which line in the text file to pull the label’s name from) and then target a specific label object so I can add/modify it’s name. I’ve done some searching but I haven’t been able to find much aside from this (http://audacity.238276.n2.nabble.com/Label-tracks-Lists-td238486.html), which doesn’t sound promising.

Does anyone know if there is a way to get a list of existing labels and modify them using Nyquist? If not, is there a better way to go about adding a feature like this (short of digging into the Audacity source?)

Thanks!

Now for the bad news - you can’t do that in Audacity-Nyquist as the only data to be sent to Nyquist from Audacity is the audio data (Labels are not accessible to Nyquist).

Probably the closest that you could get would be to manually export the labels as a text file from Audacity, then with your Nyquist plug-in, read that text file.

Ha! I’ve just read the second post in that link :smiley:

Hey Steve,

Aw, that’s what I thought :frowning:. I’ve also been playing around with the idea of creating an AppleScript (this must eventually run on a Mac…yeah, I’m not happy about it either :wink:) that will automate the process of exporting the labels, add the slate numbers to the exported text file and then re-import the labels. While this would work, it’s definitely not as slick as having the label names pulled in as you add them. Honestly, part of the reason I would like to have them pulled in “on-demand” is for the sake of organization. That way it would be easier to see which chunks you’ve already added and where.

Do you know if Audacity supports any other methods of automation that might be able to do what we’re looking for?

Thanks again for all of your help!

Not without digging deep into the code.

Just a thought about your Nyquist idea - could the “slates” begin with a number? (slate id number = label number)
I think it would be possible for Nyquist to read through a text file and look for a number at the beginning of a line.

Actually, the slates are just made up of a string of 5 digits. I’m not as concerned with getting the slate numbers from a text file into Audacity since the docs seems to say that reading from text-based files isn’t terribly difficult. It looks like the main hang-up is going to be lack of access to existing labels.

Busted,
I think it’s possible to make a plug-in to do what you want. I need to think about it a little more, and then I’ll post an outline of how it would work. Then you can tell me whether that will do the trick without messing up your workflow too badly.

The only problem I see is getting at a good directory to contain the original text file. The only directory which Audacity-Nyquist knows about right now is the default sound directory which is a temporary file. I’ve worked around a problem like this before, by using a separate setup plug-in where you can specify the directory containing the text file your other program has created.

Dave