Transcribe audio locally on MacOS

14 Oct 2022 in TIL

I've been using Just Press Record on my watch to capture things that are on my mind whilst working outdoors. I'm usually pretty good at processing the recordings regularly, but recently found a folder of recordings that I may or may not have processed.

Rather than listening to all of the recordings, I wanted to batch transcribe them and read the text. There are plenty of online tools available, but I wanted a local CLI tool which lead me to hear.

The 0.1 release of hear is from March and is missing some important bugfixes. I cloned the repo and ran make to build the tool locally and it works great.

hear accepts an input file and a language, and writes the output to stdout. Here's an example that processes a file against the en-GB model and writes out transcription.txt:

bash
hear -i ./2022-01-29/10-17-46.m4a -l en-GB > transcription.txt

Important: You may see the word abort when running hear. This is due to hear needing to request microphone permissions. If you get an error, try running hear in Terminal.app rather than any other application

If you have a whole folder of recordings to transcribe, you might find this snippet useful. It produces a .txt file next to each recording with the contents of the transcription:

bash
for i in `find . -name '*.m4a'`; do hear -i $i -l en-GB > ${i/.m4a/}.txt; done

Here's what it looks like for me after running that command (with some folders removed for brevity):

❯ ls -R 2021-12-27 2022-01-29 ./2021-12-27: 14-17-39.m4a 14-19-34.m4a 14-21-18.m4a 14-21-54.m4a 14-49-09.m4a 14-53-17.m4a 14-17-39.txt 14-19-34.txt 14-21-18.txt 14-21-54.txt 14-49-09.txt 14-53-17.txt ./2022-01-29: 10-17-46.m4a 10-17-46.txt 10-56-59.m4a 10-56-59.txt