SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.
見出し画像

Programming with ChatGPT! ~This is going to change the world!!~

Since the Zoom transcription data is redundant,
I decided I wanted to convert the text format.

In the past, I would have written it using something like awk, but that's a bit of a hassle.

What would happen if I asked ChatGPT?
When I tried it, the results were amazing!


Script Sample

Please follow the rules below to
process the text in the attached file,generate a Python program,and then
save the processing results in a text file format..

##Input Example 1
1
00:00:03.440 --> 00:00:04.960
Shigeki Kawahara @ Future Realization Partner: Yes.

##Output Example 1
00:00:03 Kawahara Yes.

##Input Example 2
3140
02:48:14.930 --> 02:48:15.500
xxx: As I thought

##Output Example 2
02:48:14 xxx As I thought

##Other Rules
・Delete blank lines (containing only spaces)
・Delete lines containing only numbers
・Output should be tab (\t) separated and combined into one line

The instructions I gave were something like this

It's a process to simplify a set of 4 lines,
including blank lines, into a single line.


At the beginning, show the overall picture of what you want done

  1. Generate a Python program

  2. Execute it,

  3. Output the results to a file

For the processing instructions,
I just provided two samples comparing input and output.
I didn't give specific instructions on what to do or how.
This is where it differs significantly from traditional programming.

Other rules were just bullet points,
written as they came to mind.

It's like giving instructions to a human subordinate.


Generated program

import re

def process_transcript(input_file, output_file):
with open(input_file, 'r', encoding='utf-8') as file:
lines = file.readlines()

output_lines = []
timestamp = ""
speaker = ""
content = ""

for line in lines:
line = line.strip()

if not line or line.isdigit():
continue # Skip blank lines or lines with only numbers

timestamp_match = re.match(r"(\d{2}:\d{2}:\d{2})\.\d{3} -->", line)
if timestamp_match:
timestamp = timestamp_match.group(1) # Extract timestamp
continue

speaker_match = re.match(r"([^:]+): (.+)", line)
if speaker_match:
speaker = speaker_match.group(1).split('@')[0] # Cut speaker name before @
content = speaker_match.group(2) # Get content
output_lines.append(f"{timestamp}\t{speaker}\t{content}")

with open(output_file, 'w', encoding='utf-8') as file:
file.write("\n".join(output_lines))

# File name settings
input_filename = "/mnt/data/Recording.transcript.txt"
output_filename = "/mnt/data/processed_transcript.txt"

# Execute script
process_transcript(input_filename, output_filename)
print(f"Processing complete. Output file: {output_filename}")

I've never used Python, but this is beautiful code. lol

  • Readable and efficient

    • It even includes proper comments

  • It correctly recognized the data meaning without me even instructing it

    • Timestamp, speaker, and content, all of it!

  • Text processing is impressive, as expected!

    • It handled it perfectly with regular expressions

This is surprising!

For simple programming like this,
there really might be no need for humans anymore


And it even handled the program execution and file output all at once,
and the processing results were perfect!

From the moment I thought of it until now,
it didn't even take 5 minutes

If I had done it myself, I might not have even finished debugging in a whole day💦
(Though I don't have that kind of time lol)


This is going to change the world!
Could even elementary school students do programming!?

The things AI can do are increasing rapidly
I've become a bit more interested in trying out various things ^^)/



This article was written by
Future Realization Partner for Increasing Revenue Streams, Shigeki Kawahara
https://mousoubiz.com/
https://twitter.com/mousoubiz


いいなと思ったら応援しよう!