Transcribing your iOS Voice Memos to Markdown with Whisper

Open AI has recently introduced an Open-Source library to transcribe voice recordings, and it immediatelly caught my eye. I like automating things, and transcribing memos is a great example of a high leverage automation.

  1. Recording voice or video is much faster and easier than writing text
  2. Text is much easier to parse and consume than video or audio.

When I record a voice memo for myself and a bot transcribes it, I have something easy to produce, but also searchable and easily read.

As my current note-taking app is Logseq, it auto-imports those markdown files to my notes database.

Installing Whisper

If you have Python, pip3 and ffmpeg ready, you should be able to run a command like:

pip3 install git+https://github.com/openai/whisper.git

Then you can run it on any audio or video file:

whisper /path/to/file

More instruction in the GH repo.

iOS Voice Memos

When iCloud sync is enabled, the voice memos from your phone sync to your laptop via icloud. This will be perfect!

The recordings are stored in a directory like this: (replace artpi with your username)

/Users/artpi/Library/Application Support/com.apple.voicememos/Recordings/

Unusually accessible for an Apple product, but a win for us! Let’s put it all together. The following code will:

  1. Read all .m4a files from /Users/artpi/Library/Application Support/com.apple.voicememos/Recordings/
  2. Transcribe
  3. Save each as /Users/artpi/GIT/logseq/pages/RECORDING_NAME.md file
  4. When re-run, it will skip the files already saved.


<?php
//https://piszek.com/?p=5874

function sync_apple_voice_memos( $dir, $save_dir, $whisper_dir ) {
    foreach ( glob( dir ) as $filename ) {
        $name = basename( $filename, ".m4a" );
        $file_to_save = $save_dir . '/Voice Memo - ' . $name . '.md' ;
        // Only proceed if file not already transcribed
        if ( ! file_exists( $file_to_save ) ) {
            $lines = [];
            exec( "{$whisper_dir} \"{$filename}\"", $lines );

            $lines = array_slice( $lines, 2 ); // Some default headers.
            $lines = array_map( function( $line ){
                return preg_replace( '#\[[0-9.:]+ --> [0-9.:]+\]\s+(.*?)$#is', '- \\1', $line );
            }, $lines );

            if ( $lines ) {
                file_put_contents( $file_to_save, implode( "\n", $lines ) );
            }
        }
    }
}

sync_apple_voice_memos(
    '/Users/artpi/Library/Application Support/com.apple.voicememos/Recordings/*.m4a',
    '/Users/artpi/GIT/logseq/pages',
    '/opt/homebrew/bin/whisper'
);

More Logseq imports

Here are some other importer ideas for Logseq:

Leave a Reply