Automatically transcribe your Evernote voice notes

I am a big believer in taking notes and working on my personal infrastructure. I find joy in polishing the “Artur OS” and removing little pockets of friction in my setup. Have a look at my automation philosophy:

Recently, we adopted a dog and I have quite a bit of time spent walking. What if I could use it for some deep thinking?

So I wrote a bot.

How does it work?

A: I record an audio note on my phone:

B: I run my magical code

C: A transcription shows underneath

D: Profit!

There are other ways to solve this problem. Particularly, Otter.AI is a great service to transcribe your notes. However, it requires extra manual steps to open the app, export recordings, etc.

If you don’t have an elaborate setup behind your Evernote account, I recommend you check out Otter.

What do you need:

  1. You need to set up the PHP (Yes) SDK for Evernote
  2. You need an API key to Google Cloud Speech API. You don’t need a client library! Just follow these steps:
    1. Enable the API for your project here
    2. Create a new “API Interface Key” here

This code assumes you already search for a note and pass it in. I tag a note with `Tools`. A cron job periodically checks the label and does certain magical things on the notes tagged with it.

Code

It finds the audio recording in your Evernote note and transcribes it:

<?php
// https://piszek.com/2020/05/27/evernote-transcriber/
function transcribe_audio_file_in_a_note( $evernoteClient, $note ) {
// This will find the place where file is embedded, so we can display the transcription underneath.
if( preg_match( '#<en-media hash="([a-z0-9]+)"[^>]+>#is', $note->content, $res ) ) {
$id = hex2bin($res[1] );
$resources = array_filter( $note->resources, function( $resource ) use ( $id ) {
return $resource->data->bodyHash === $id;
} );
if( $resources ) {
$resource = array_shift( $resources );
}
}
if ( isset( $resource->mime ) && $resource->mime === 'audio/x-m4a' ) {
// Only audio files
if ( isset( $resource->attributes->applicationData->keysOnly['transcribed'] ) ) {
$this->log( LOG_INFO, 'This resource is already transcribed.' );
return;
}
// Set for the future
$evernoteClient->client->getNoteStore()->setResourceApplicationDataEntry( $resource->guid, 'transcribed', 'true' );
// this is your Google Speech API token
$token = "tsrtrastr8astars8tras8t";
$in = tempnam(sys_get_temp_dir(), 'evernote_transcript') . '.mp4';
$out = tempnam(sys_get_temp_dir(), 'evernote_transcript') . '.wav';
$data = $evernoteClient->client->getNoteStore()->getResourceData( $resource->guid );
file_put_contents( $in, $data );
// Because Google Speech API is crap and cannot deal with other formats, we have to recode it.
system( "ffmpeg -i $in $out" );
$data = file_get_contents( $out );
$payload = array(
"audio" => array( "content" => base64_encode( $data ) ),
"config" => array(
"languageCode" => "en-US",
"alternativeLanguageCodes" => [ "pl-PL" ], // I only use English or Polish. Your mileage may vary.
"encoding" => "LINEAR16",
"sampleRateHertz" => 44100,
"maxAlternatives" => 1,
"enableAutomaticPunctuation" => true
)
);
$payload = json_encode( $payload );
$context = stream_context_create( array(
'http' => array(
'ignore_errors' => true,
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => $payload
)
) );
// Wondering about the v1p1beta1 here? You have to use this version to have alternativeLanguageCodes. This of course is not in documentation.
$result = file_get_contents( "https://speech.googleapis.com/v1p1beta1/speech:recognize?fields=results&key=$token&quot;, false, $context );
$result = json_decode( $result, true );
if ( ! isset ( $result['results'][0]['alternatives'][0]['transcript'] ) ) {
$this->log( LOG_WARNING, 'Empty transcript. ' . print_r( $result, true ) );
return;
}
$text = $result['results'][0]['alternatives'][0]['transcript'];
$this->log( LOG_INFO, 'Transcript OK: ' . $text );
$new_body = str_replace( $res[0], $res[0] . "<div style='font-style: italic'>$text</div>",$note->content );
$note->content = $new_body;
$evernoteClient->client->getNoteStore()->updateNote( $note );
}
return $note->content;
}

More of my adventures in automation:

VIPs secret weapon: the Post-It note.

In the olden days before the pandemic, there were conferences and meetings. People would gather together to discuss matters in person, looking at each other, not through the screen, but face-to-face.

Meetings, naturally, are most productive when you take notes. Without action items and concrete takeaways, there are just chit-chats between friends. So people whip out their laptops and tablets to „jot down something.”

Have you ever participated in a meeting where everybody is walled off behind a screen? I did, and it was entirely unproductive. I’m sure it had great notes, though.

Last year, during our company offsite in Orlando, I had a series of meetings regarding a feature I was responsible for. There were many stakeholders, and I wanted to use the time to discuss strategy. I met with the Head of Product, President of our product line, and the CEO of the company. And I noticed something quite interesting:

The more senior the person, the more minimalist their note-taking approach.

All the people I met used Pen&Paper. But it really clicked when we invited the amazing Stephen Wolfram on stage. He would carry a stack of post-it notes, just like our CEO!

I wanted to have something that the average theoretical physicist can use

Stephen Wolfram on why he created Mathematica. He could have been talking about post-its, too.

What is it about paper notes and post-its in particular?

Note-taking is something I take seriously. I type about 500 new notes per month and I am very fond of the search function of my Evernote account. But I have to admit – the paper is superior for note-taking.

  1. Analog (pen & paper) note-taking lets you stay present. There is no wall of screens between you and the other person,
  2. Your posture is different when you take notes on paper, making it easier for you to use body language. (With hands on the keyboard, your back is rounded, just like when your ancestors were hiding from danger. This is not the body language of successful people),
  3. It’s clear and even encouraging that you are noting things down. The other person does not have to worry, that you are playing Animal Crossing,
  4. Post-it notes are easy to carry and convenient to pull out when needed. You can keep them in your pocket,
  5. You can use them while standing, which is useful during conferences,
  6. One idea, one note is a neat, self-contained information nugget. Post-it note is big enough to note the important stuff but too small to take your bloat. Just like a tweet.
  7. You can easily re-arrange, combine, and process them after the meeting. It’s like the are made for this.

Now, that you are in on the secret, you can carry a stack of post-it notes to your high-stakes meeting. Let them know you are a professional too.

Alfred Evernote Snippets

This is sort of a plugin to a great OSX app, Alfred. It adds all notes in Evernote “Snippets” Notebook as a quick-paste snippet in Alfred.

I use both alfred and evernote extensively, so Im quite happy about this one!

Usage

  1. Provided you have Evernote, Alfred and powerpack and this workflow installed
  2. Put some snippets in “Snippets” notebook in evernote
  3. Hit afred `s your_note_title`
  4. enter
  5. note content is now pasted to your focused window

Download

Workflow on Packal

Alternative download here

Making of:

============================
Script filter:
var q = "{query}";
var values = Application('Evernote').findNotes("notebook:Snippets " + q);
var ret = '<?xml version="1.0"?><items>';
for (var i=0; i<values.length; i++ ) {
var title = values[i].title();
var val = values[i].htmlContent().replace(/<br\/>/g,'{enter}').replace(/<[^>]*?>/g,"");
var sub = values[i].htmlContent().replace(/\n/g,'').replace(/<[^>]*?>/g,"");
ret += '<item arg="'+val+'"><title>' + title + '</title><subtitle>' + sub + '</subtitle></item>';
}
ret += "</items>";
============================
You will need this to properly handle spaces (script filter has trouble with that)
NSAScript (synchronous)
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
on alfred_script(q)
return replace_chars(q, "{enter} ", "\n")
end alfred_script

Evernote: Using Online Notes for Performing Qualitative Research

In June issue of Qualitative Sociology Review (Issue here) you can find mine and Krzysztof Stachura’s paper about using Evernote platform in the course of academic research. Please, keep in mind that paper is in Polish.

Abstract

The paper is a presentation of potential ways to use Evernote as a simple and cheap alternative to professional CAQDA (Computer-Assisted Qualitative Data Analysis) software packages, along with pointing specific limitations of the tool.
The main functions useful in research and for analytic purposes are depicted, as well as techniques that enable the application of grounded theory methodology using Evernote are. Moreover, similarities and differences between Evernote and NVivo 10 are presented, and the analytical perspectives for the near future concerning the evolution of Evernote are drawn. 

KeywordsEvernote, CAQDA, qualitative research, organizing data, NVivo

Download

Warning: The paper is in Polish

You can download paper from QualitativeSociologyReview.org [PDF]

Evernote for Travel

blog-promo2
© Stolen from Evernote team.

During sightseeing, how would you like to have an interactive map with cool places to see, specifically suited to your preferences? A map with location of your airport, bus, hotel, with gps capability and tailored information about stuff you really want to see? Like opening hours, recommendations from your friends and information for YOU.

Well, you have and it’s name is (no surprise there), evernote.

Continue reading “Evernote for Travel”