Morse code bootup tune generator
Posted: Sun Feb 11, 2024 7:36 pm
Evening folks,
I wanted to put my callsign in morse as a bootup tune in my new DM-1701, so I asked ChatGPT to write a script to help me out. It failed miserably, so I got really annoyed with it and decided to teach it a lesson by showing it how it's done
Here's the resulting script. If you don't have Python installed, you can run it online on this link and just change the morse_code string to whatever you want: Online Python.
Output:
If you're interested you can see ChatGPT's attempts at the same here. It's good to know human coders aren't obsolete yet
ChatGPT KO'd in coding challenge
73, Thomas OZ5TN
I wanted to put my callsign in morse as a bootup tune in my new DM-1701, so I asked ChatGPT to write a script to help me out. It failed miserably, so I got really annoyed with it and decided to teach it a lesson by showing it how it's done
Here's the resulting script. If you don't have Python installed, you can run it online on this link and just change the morse_code string to whatever you want: Online Python.
Code: Select all
def morse_code_to_boot_tune(morse_code, pitch=38, speed=1):
symbols = {
'.': (1, 1),
'-': (3, 1),
' ': (0, 3),
'/': (0, 7)
}
tune = []
gap = 0
for symbol in morse_code:
if symbol not in symbols:
continue
if gap:
tune.append((0, gap))
tone_length, gap = symbols[symbol]
if (tone_length):
tune.append((pitch, tone_length))
return ','.join([f'{tone},{duration*speed}' for (tone,duration )in tune])
# Morse code for "CQ DMR"
# We use space to denote a gap between letters and slash for gaps between words.
morse_code = "-.-. --.-/-.. -- .-."
pitch = 38
speed = 2
tune_str = morse_code_to_boot_tune(morse_code, pitch, speed)
print(tune_str)
Code: Select all
38,6,0,2,38,2,0,2,38,6,0,2,38,2,0,2,0,6,38,2,0,2,38,6,0,2,38,2,0,2,38,2,0,2,0,6,38,2,0,2,0,6,38,2,0,2,38,6,0,2,0,6,38,6,0,2,38,2,0,2,0,6,38,2,0,2,0,6,38,2,0,2,38,6,0,2,38,2,0,2,0,14,38,6,0,2,38,2,0,2,38,6,0,2,38,2,0,2,0,6,38,6,0,2,38,6,0,2,38,6,0,2,0,6,38,6,0,2,38,2,0,2,38,2,0,2,0,6,38,2,0,2,0,6,38,2,0,2,38,2,0,2,38,6,0,2,38,6,0,2,38,2,0,2,38,2
ChatGPT KO'd in coding challenge
73, Thomas OZ5TN