Convert Label text to LRC file

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.
steve
Site Admin
Posts: 80677
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Convert Label text to LRC file

Post by steve » Wed Feb 12, 2020 9:17 am

bigboss97 wrote:
Wed Feb 12, 2020 6:20 am
(with-open-file ...
Where did that come from?

bigboss97 wrote:
Wed Feb 12, 2020 6:20 am
error: unbound function - WITH-OPEN-FILE
That means that the function "with-open-file" is unknown. It's not a valid function name.
The function you need for opening a file is "open". See: https://www.audacity-forum.de/download/ ... ef-190.htm
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

bigboss97
Posts: 42
Joined: Sat Feb 08, 2020 6:28 am
Operating System: Windows 10

Re: Convert Label text to LRC file

Post by bigboss97 » Wed Feb 12, 2020 10:48 pm

All good now. Thank you so much for your time.
steve wrote:
Wed Feb 12, 2020 9:17 am
bigboss97 wrote:
Wed Feb 12, 2020 6:20 am
(with-open-file ...
Where did that come from?
This is a macro in Lisp because I googled for Lisp commands :D

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

Re: Convert Label text to LRC file

Post by steve » Wed Feb 12, 2020 11:12 pm

Although Nyquist is a form of Lisp, it is based on a very small version of Lisp called XLisp. Other, bigger versions of Lisp (such as "Common Lisp") have many language features that are not part of XLisp.

The XLisp manual is here: https://www.audacity-forum.de/download/ ... -index.htm
The part of the XLisp manual that you will use most frequently is the Language Reference: https://www.audacity-forum.de/download/ ... -index.htm

Virtually all XLisp commands are valid in Nyquist. The (very few) XLisp commands that don't work in Nyquist are noted to that effect.
The XLisp manual is particularly helpful as it includes lots of examples.

Nyquist also has additional command that aren't part of XLisp. These are nearly all audio related functions, and can be found in the Nyquist Index: https://www.cs.cmu.edu/~rbd/doc/nyquist/indx.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

bigboss97
Posts: 42
Joined: Sat Feb 08, 2020 6:28 am
Operating System: Windows 10

Re: Convert Label text to LRC file

Post by bigboss97 » Fri Feb 14, 2020 12:06 am

Thank you so much, Steve.
I've bookmarked this thread. I'm sure I'll revisit all these information.

bigboss97
Posts: 42
Joined: Sat Feb 08, 2020 6:28 am
Operating System: Windows 10

Re: Convert Label text to LRC file

Post by bigboss97 » Sun Feb 23, 2020 2:50 am

Sorry, I have to come back and ask for help again :-) I did try to google and couldn't find any usable results.
My plug-in is now working, but it can't handle Unicode. How can I make it write Unicode file?

Code: Select all

(setq f (open fName :direction :output :if-exists :supersede))
*snip*
    (format f (if (string= (third label) "^") "~%[~a]" "<~a>~a<~a>") timeS (third label) timeE)))
(close f) 
I can see Export Labels have no problems in Unicode. I also tried to locate that plug-in without success. Is Export Labels a plug-in?

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

Re: Convert Label text to LRC file

Post by steve » Sun Feb 23, 2020 10:32 am

Nyquist doesn't support Unicode, only ASCII.
If you really must have Unicode support, then it may be possible to use read-byte and write-byte, but there are lots of ways that the code can trip up with Unicode.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

bigboss97
Posts: 42
Joined: Sat Feb 08, 2020 6:28 am
Operating System: Windows 10

Re: Convert Label text to LRC file

Post by bigboss97 » Mon Feb 24, 2020 4:13 am

steve wrote:
Sun Feb 23, 2020 10:32 am
Nyquist doesn't support Unicode, only ASCII.
Does that mean when I retrieve the label (using Nyquist) the dual-byte information already lost? Which means I have no chance to write the unicode to a binary file. Is that correct?

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

Re: Convert Label text to LRC file

Post by steve » Mon Feb 24, 2020 10:00 am

bigboss97 wrote:
Mon Feb 24, 2020 4:13 am
Does that mean when I retrieve the label (using Nyquist) the dual-byte information already lost?
I had to check. The answer is yes. The "aud-get-info" command returns ASCII characters. Audacity converts multi-byte character to underscore ("_") before sending the data to Nyquist.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

bigboss97
Posts: 42
Joined: Sat Feb 08, 2020 6:28 am
Operating System: Windows 10

Re: Convert Label text to LRC file

Post by bigboss97 » Mon Feb 24, 2020 11:53 am

steve wrote:
Mon Feb 24, 2020 10:00 am
The "aud-get-info" command returns ASCII characters. Audacity converts multi-byte character to underscore ("_") before sending the data to Nyquist.
Yes, I got underscores in my files.

That means I've no chance of building an unicode plug-in. Okay, then I need a plan B... :D
I can write a separate program to convert the exported label file to LRC. Is it possible to write a kind of macro to export the labels and then execute my converter? So the user can do all these in one step.

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

Re: Convert Label text to LRC file

Post by steve » Mon Feb 24, 2020 1:12 pm

You can get multi-byte characters from labels using "GetInfo: Type=Labels Format=JSON" via Python.
See here for the latest information about scripting with Python: https://alphamanual.audacityteam.org/man/Scripting
(That is actually the manual for Audacity 2.4.0, which is not yet released, but it's more up to date than the equivalent page in the 2.3.3 manual).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply