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.
- Recording voice or video is much faster and easier than writing text
- 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:
- Read all .m4a files from
/Users/artpi/Library/Application Support/com.apple.voicememos/Recordings/
- Transcribe
- Save each as
/Users/artpi/GIT/logseq/pages
/RECORDING_NAME.md file - 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, 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
The post Transcribing your iOS Voice Memos to Markdown with Whisper appeared first on Artur Piszek.
Top comments (1)
Oh, that's a great approach! I was thinking about the same problem, and ended up biulding a whole app - Whisper Memos.