Transcribing your iOS Voice Memos to Markdown with Whisper
Tags: programming, ai, notes, markdown
Published: 2022-10-23 14:57:53

---
title: Transcribing your iOS Voice Memos to Markdown with Whisper
published: true
date: 2022-10-23 14:53:27 UTC
tags: Programming,AI,Notes,Markdown
canonical_url: https://piszek.com/2022/10/23/voice-memos-whisper/
---

Open AI has recently introduced an [Open-Source library to transcribe voice recordings](https://github.com/openai/whisper), and it immediatelly caught my eye. I like [automating things](https://piszek.com/2019/11/14/y-u-bots/), 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.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0she7vvbgsz9zwq8isfn.png)

### 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.](https://github.com/openai/whisper)

### 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:

> I wrote a bunch of scripts to import everything to my [@logseq](https://twitter.com/logseq?ref_src=twsrc%5Etfw), and it is glorious.  
> I have an overview of every day, including today.  
> It prevents me from opening a bunch of apps to check notifications and puts me in a more proactive frame of mind.  
>   
> Here is what syncs hourly:
> 
> — Minimum Viable Polish (@artpi) [August 2, 2022](https://twitter.com/artpi/status/1554566274151170048?ref_src=twsrc%5Etfw)

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

The post [Transcribing your iOS Voice Memos to Markdown with Whisper](https://piszek.com/2022/10/23/voice-memos-whisper/) appeared first on [Artur Piszek](https://piszek.com).