From MAX to OPS: Running Transcription Headless and On Startup (P4)

…a vital step, because no user wants to run around with high-tech glasses connected to a giant monitor, keyboard, and mouse, completely contradicting the “portable” feature of the project. First off, what does “headless” and “on startup” even mean? Are they even the same thing? These were both questions I typed explicitly into my search engine during the research portion of this step. Running code headless means to run the code without a monitor, keyboard, or mouse, which is only possible if the code is set to run on startup, or when the Raspberry Pi turns on and “boots up.” It was difficult to run the Google Speech Recognition code on startup (according to some sources) possibly because it required Wifi, which was also connected simultaneously during the boot process, disrupting the running process of the Google Speech Recognition version of the transcription code. 

To run the Vosk version of the code on startup, I experimented with editing the boot code files, something I realized I should never do, since I had to rewrite the Raspberry Pi OS Desktop Software multiple times onto my USB drive, erasing all of my progress I’d made over the past few months. Thankfully, it was only a minor setback, since I’d saved all of my code and processes in an informal journal document, similar to this one. So, after restarting from a place similar to square one, except now with all of the prior knowledge of learning how to manipulate the Raspberry Pi, I re-coded my project back to where it was with the complete Vosk speech recognition version. A few weeks later, I revisited the important topic of running the code headless, researching the wonderful invention of Python shell scripts

Shell scripts in the Python coding language are similar to standard coding scripts, except they are additionally helpful in running certain commands automatically. For example, the commands I continuously entered into the Raspberry Pi terminal were “source myvirtualenv/bin/activate” to activate my virtual environment (granting my code access to various packages I previously installed) and “python3 trial9.py” to run my code (titled trial9.py) in the virtual environment. However, typing those commands into my new shell script enabled me to run both commands with the typing of a single new command (“source launcher.sh”) and automate the run of this shell script command by typing it into the boot script of the Raspberry Pi Desktop. Now, disconnected to the monitor, keyboard, and mouse, I could power on the Pi, which would boot and automatically run my transcription code!

This was the final step of the software development of my project, an achievement I could only dream of completing at the beginning stages of learning Python back in April of 2024. However, as I continued to persevere through the hardships of independent learning, what was only a dream gradually transformed into the reality that it is today, proving that if one dedicates the mind to anything, then anything can be possible.