Has anyone tried using ChatGPT (or other AI tools) to write AppleScripts for QLab? Or to help with questions about OSC?
(Not that we really need it with Mic, Rich, and Sam around)
I've been playing with it a little lately because the idea seems intriguing to me. I've asked it to write code for some simple tasks that I already have scripts for, but it has taken a few back-and-forth interactions before it comes up with something that works with QLab without getting an error.
It seems to understand AppleScript well as a language, but for example it was using:
->set volume of thisCue to newVolume
instead of something like:
->thisCue setLevel row 0 column 0 db newVolume
I was able to teach it to create scripts that would use the setLevel command correctly, but then asking the same request in a different chat thread showed that it hadn't (yet) applied the setLevel knowledge to anything other than the one chat thread. (And telling it to learn from the QLab 5 online documentation didn't seem to accomplish much).
Not sure if it will eventually apply that learning to other chats, or to others using ChatGPT.
I also tried sharing some scripts with it to learn my style or learn something from my examples, but some of them were too long for ChatGPT to accept (which were the ones I was more curious about what it might have to say about).
I also asked it if it understood other languages, and it mentioned a few. I gave it a request in Spanish which took a while for it to respond to, but it eventually answered in coherent Spanish with a working AppleScript (applying the principles it learned earlier in the chat)
It seems like it could be a really interesting tool in the future. But for now it seems like it has a good ways to go, or at least requires a significant amount of interactions with an experienced user to catch on. (If I hadn't learned a lot over the years from the forum here already, it would have taken a while still to come up with working scripts.)
Also curious if others have insights into the security or ethics of it, since I still don't know all that much about the tool as a whole (or other tools similar to it)
For anyone more curious about my tinkering, I used it to help generate this script below.
The script checks the file extensions of audio and video cues, and checks for existing files with the same name but with a preferred file extension.
For those times when you say, 'this entire workspace of 2,000 cues was all built with H.264 files in .mp4 containers and I just want to convert all of the files to ProRes files in .mov containers and replace the cue targets for everything all at once since it sounds super tedious."
tell application id "com.figure53.QLab.5" to tell front workspace
set preferredAudioExtension to "aiff"
set preferredVideoExtension to "mov"
repeat with thisCue in (every cue whose q type is "Audio" or q type is "Video")
set cueFileTarget to file target of thisCue
if cueFileTarget is not missing value then
set cueFile to POSIX path of (file target of thisCue as alias)
set thetids to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set cueFileExtension to last text item of cueFile
set AppleScript's text item delimiters to thetids
if (cueFileExtension is not preferredAudioExtension) and (thisCue's q type is "Audio") then
set newFilePath to (text 1 thru -((length of cueFileExtension) + 2) of cueFile) & "." & preferredAudioExtension
set file target of thisCue to newFilePath
if cueFile is not newFilePath then
set the flagged of thisCue to true
end if --if the file with preferred extension was not successfully found and targeted
else if (cueFileExtension is not preferredVideoExtension) and (thisCue's q type is "Video") then
set newFilePath to (text 1 thru -((length of cueFileExtension) + 2) of cueFile) & "." & preferredVideoExtension
set file target of thisCue to newFilePath
if cueFile is not newFilePath then
set the flagged of thisCue to true
end if -- if the file with preferred extension was not successfully found and targeted
end if -- if the cue's file extension is not already the preferred extension
end if -- if the cue target is not missing
end repeat -- repeat with every audio and video cue
end tell
- ChatGPT kept recommending I use "set cueFileExtension to name extension of cueFile" which didn't work (and what I found online said that should have worked) but I ended up just splitting it using text item delimiters.
- I had asked ChatGPT to flag cues that didn't have a target file with the preferred extension, but it was only flagging cues that were missing a file target, so I just removed that and added the "if cueFile is not newFilePath" statements.
- I ended up just throwing in "set cueFile to POSIX path of (file target of thisCue as alias)" from my past experience.
- At first it kept using "cue whose type is" instead of "cue whose q type is"
- I then added the comments after the "end if"s at the end. I had requested to ChatGPT earlier that it do that, but it didn't stick.
- It took some back and forth for it to come up with listing the preferredExtensions at the top to be set by the user, instead of having dialog prompts.
- ChatGPT also reverted back to [tell application id "com.figure53.QLab.4"] a few times, and I had to tell it twice to refer to QLab 5.
- The current script still doesn't have logic in it to avoid certain exceptions or allow user precautions like I prefer to do. And I still want to make it handle the way Compressor adds text to the end of the filename about the codec used (which I like for video files). So in realistic application, it still needs work to keep it from doing something potentially stupid.
And there were probably a few other things that we went back and forth about and me sharing examples with it.
I would say the one part it actually saved me time on was the:
[set newFilePath to (text 1 thru -((length of cueFileExtension) + 2) of cueFile) & "." & preferredAudioExtension]
For which I would not have come up with something as succinct.
So, I'd say ChatGPT didn't behave like an expert, but still like a somewhat helpful coworker.
Cheers,