ChatGPT is a new (and faster) way to do programming!

Currently ChatGPT is in a free “initial research preview”. One of its well known use cases at this point is generating software code. I’ve also just used it to write most of this article… Well, actually a future article about cleaning up SRT subtitle files of their metadata faster than I have been by hand with Notepad++ and its replace functionality.

Update: I recorded a screencast of writing the SRT subtitle cleaner application loading and processing portion. I relied heavily on ChatGPT for code. It was a fun process!

https://youtu.be/TkEW39OloUA

ChatGPT, developed by OpenAI, is a powerful language model that can assist developers in a variety of tasks, including natural language processing and text generation. One such task that ChatGPT can help with is creating an SRT cleaner program.

SRT, or SubRip Subtitle, files are commonly used to add subtitles to video files. However, these files can become cluttered with unnecessary information, such as timing lines or blank spaces. To clean up these files, developers can use a program that strips out the unwanted information and leaves only the subtitle text.

Using ChatGPT, developers can quickly create an SRT cleaner program in a variety of programming languages, including C#. In our previous conversation (aka. me and ChatGPT which I asked it to reference for this article), I provided an example of a C# program that uses regular expressions to strip out the timing lines from an SRT file. The program reads the entire file into a string, splits the string into an array of lines, and then iterates over the lines, keeping only the lines that do not start with a number. This effectively removes the timing lines from the file, leaving only the subtitle text.

Additionally, the program also prompts the user to select a text file using C# .NET WinForms, which makes the cleaning process more user-friendly.

ChatGPT’s ability to understand and respond to natural language prompts makes it an ideal tool for developers looking to quickly create programs like an SRT cleaner. Its ability to understand context and provide specific examples, such as the C# program for stripping out timing lines, can save developers a significant amount of time and effort in the development process.

In conclusion, ChatGPT is a valuable tool for developers looking to create programs like an SRT cleaner. Its natural language processing capabilities and ability to provide specific examples in various programming languages make it an efficient and effective tool for streamlining the development process.

Written by ChatGPT about my requests to it for small blocks of C# code.

Why am I doing this?

I saw an old PhotographyBanzai.com article that linked one of my YouTube videos but was missing the transcript. I like putting the text there for people that don’t want to or can’t watch the video.

I currently use these regular expression lines of text in Notepad++ to clean up SRT files. Also something I got from ChatGPT a while back, lol…

Remove timing lines from a SRT file:
^\d+:\d+:\d+,\d+ --> \d+:\d+:\d+,\d+$
or
\d+:\d+:\d+,\d+ --> \d+:\d+:\d+,\d+

Use this to remove lines that are numeric:
^\d+$

Remove empty lines:
^\r\nCode language: plaintext (plaintext)

Which is totally fine, but you can see it takes a few steps in Notepad++ once I load the SRT file and open up the replace text dialog (making sure it’s set up properly to do the replace with regular expressions).

Just incase I want to reference this in the future, here is what the Notepad++ dialog looks like for it to work with regular expressions:

The Notepad++ replace dialog setup to use regular expressions.

Now let’s take a look at what my requests have been so far to ChatGPT…

  • write a c# program that strips out the timing lines from a srt file.
  • Convert this notepad++ replace in the below line:
    ^\d+:\d+:\d+,\d+ –> \d+:\d+:\d+,\d+$
    into a C# Regex.Replace function call.
  • c# .net load a text file into a stringbuilder
  • c# .net winforms prompt the user to select a text file
  • Write be a website article about using ChatGPT to assist in creating an SRT cleaner program based on our current conversation history.
One of the more interesting prompts. Asking it to convert those notepad++ specific expressions to a different language. I haven’t tested this out yet. I do know that regular expressions can be different between applications and programming language implementations, so we will see.

The first ChatGPT prompt was unnecessary. I’ve also got a bit more processing to do to the SRT file based on what I do to it in Notepad++ currently. You’ve still got to remove the lines that start with numbers as well as any empty lines to get a clean text-only transcript without whitespace.

Most of the prompts are simply getting small blocks of functional code of things I know I need to do but don’t remember the exact way to write them. It’s been a while since I’ve done any coding and even before having access to such a powerful tool, I’d do a Google search to ultimately achieve the same thing. ChatGPT feels faster (though I wish it would stop sending one word at a time but maybe that’s how it actually functions rather than a visual choice?).

I’ve never tried to store a ton of specific programming implementation details into my memory. It’s never been very feasible and it’s the type of thing that’s easy to forget yet requires exact accuracy to be effective.

My suggestion to anyone that’s just started learning how to do programming is learn the fundamentals outside of any specific programming language. Then for each toolset/language learn what its capable of. Take note of differences or ways a given tool can help or requires you to think differently.

There are various resources that help lighten the load. Visual Studio code completion, Google, Stack Exchange, books, and other past sources help make programming viable for humans. Now we have options like “Copilot”, which I haven’t used, as well as ChatGPT.

Anyways, at some point I’ll probably write an article about the actual SRT cleaner application. I should probably make it a bit more generic and have it work with all of the subtitle formats that YouTube supports and then release it as an open source project rather than a code snippet…

I’ve always hoped more and more of the actual programming step can be obscured away because much of it can be monotonous. I see the true value of humans in design and all of its intricacy. This is an exciting future for developers that love the high level design side. Of course it won’t apply to all forms of software, but many can benefit when perfection of implementation is not necessary (aka. NASA launch and rover code, airplane systems, or whatever else like that won’t apply for the time being).