My Own Transcription Service

I want to paste the mp3 file into the Quicknote dropdown,so it ends up in a the same note as the transcribed text.

I know there is some applescript way to append things to an Evernote note, but thats over my head. AFAIK Applescript requires the name of the note, which would be a variable coming from this macro. I’m sure this is possible, but way, way over my general understanding of the whole subject.

But it is kind of a basic thing, I would think to be able to copy a file into the clipboard? If it is impossible to simply copy and paste a file, opening the mp3 file with Evernote, as per your suggestion, is the next best thing I’ll have to settle for…

How do you do this? When I paste something into the QuickNote dropdown it always ends up as new note. The only way to attach something to an existing note seems to be to paste it into the text of the note.

But not so important.

I had a look at Evernote’s AppleScript dictionary and it seems to be well scriptable (creating notes and attaching files to a note). I’ll integrate the AppleScripts with the KM macro later this afternoon, so you’ll be able to create a new note from the saved txt file (from TextEdit) and attach the mp3 to that note (without copy/paste).

It is that what you want, right?

In the meantime you could check if it’s really not possible to save from Dragon directly to a txt file. This would make the TextEdit part superfluous.

OK, this should work now. Please note that I couldn’t test the Dragon part and the transfer from Dragon to TextEdit (magenta in the screenshot); I copied this from your last macro.

From time to time I got an Evernote error saying “Operation would exceed monthly upload allowance.”. But I guess this is because I don’t have any subscription with this service.

Transcription with AS.kmmacros (14.6 KB)


[Edit 16:19+2h:]

I just learned on this forum that the above mentioned error message “Operation would exceed monthly upload allowance” is a bug in Evernote, and not related to any subscription.

But they also provided a fix there.

If you are experiencing this error, too, add this line…

set HTML content of destNote to HTML content of destNote

…to the Evernote AppleScript, immediately before the line “tell destNote to append…”


[Edit 19:57+2h:]

Uploaded new version:

  • TextEdit window closes now

  • Added the line above to the Evernote script. (Test if you need it; if Not, remove it.)

Wow Tom! You are awesome.
I looked at it very briefly, need to dig in a bit more as soon as I find a couple of minutes.

Is there a way with applescript to insert the text directly into the Evernote note, instead of attaching it as a txt file? Ideally I end up with an evernote note with the text in the body of the note and the mp3 file attached underneath…

instead of attaching it as a txt file?

?!

The text is not attached. The text will form a new note. It’s the mp3 that gets attached to the text (= the note).

What the script now does is:

  1. Triggered by a new mp3 file in the watched folder.
  2. mp3 should open in Dragon and the output should appear in a new and opened window in TextEdit – This part is up to you to verify, since I don’t have Dragon here!
  3. TextEdit will save the file under the same name and with a .txt extension in the Out folder (In Progress folder).
  4. The two lines (“tag:transcriptions” etc.) will be added.
  5. Evernote will create a new note, consisting of the text of that file. The note will have the file name as title.
  6. Evernote attaches the mp3 to the end of that file.
  7. txt and mp3 files are trashed.

I’ve just seen that I forgot to close the TextEdit window. I will upload a corrected version later.

Hey, you are too fast for me. :cold_sweat: I just tested it. You are right, it works wonderfully!! :sunglasses:

I uploaded the new version (see edit note above).

Thanks so much Tom! I was still on the fence regarding buying the software, but this automation already made it worthwhile to purchase it. Nuance offers a cloud service that does pretty much the same as this macro, but with less flexibility (no Evernote integration and no possibility to use 3rd party apps on the iPhone) for a monthly fee of I think 20 USD, which I wouldn’t be able to afford…

THANK YOU! I hope lots of people will be able to make use of this.

1 Like

Fine that it works now :smile:

Have you tested if you also get the occasional Evernote error (“Operation would exceed…”, see above)?

To test it —If you already have downloaded the 2nd version of the macro— you have to comment the line “set HTML content…”. (Commenting in AppleScript is done with --)

If you don’t see this error across several runs, I would recommend that you leave that line commented, because it is a workaround and as such it shouldn’t be used when not necessary.

Another little thing:

You should make sure that all your audio files have distinct names. The note in EN is created with the base name of the audio file as title. That means, if you have two or more notes with the same title in EN the audio file will likely be attached always to the same note, so you’ll end up with one note with several audio attachments and the other with none.

To avoid this you could use for example a timestamp for naming the input audio files.

Have fun!

Hi Tom,
I don’t get the error you mentioned, so I just left it alone. I’ll put in that line as a comment, just in case I end up needing it at some point in the future.

I also managed to add a tag to the note in EN! Yay.

I use an iOS App called Voice Record Pro, which does exactly what you suggest (gives files names based on date and time, so this shouldn’t become an issue in my case)

Thanks for all your help!

Apropos brute-force:

In the Dragon part of your macro there are still very ugly mouse-click and keystroke actions, supposedly to make Dragon send the text to TextEdit(?). Did you check if there really isn’t any other possibility, for example saving the text in Dragon as txt file?

the options I get through the GUI are to save as

  1. Rich Text or
  2. MS Word.

When I chose 1), I can chose between TextEdit and MS Word to open the file
When I chose MS Word (file format I guess), I can chose to open it with TextEdit, MS Word or Pages.

I can chose the folder where these files are saved to, and I can also opt to have the text copied to the clipboard. But it will still open the file in the program specified.

When I look in Apple Script Editor, Dragon has a Dictionary, so I assume it could be done with Applescript. But like I said earlier, I don't have any understanding of programming languages in general. Although, I did manage to get Evernote to add a tag to the Applescript you provided. :astonished:

Here is the Dragon Dictionary (if that even works?) in case you want to try your luck... :wink: Dragon.sdef.zip (4.9 KB)

David

Here is the Dragon Dictionary (if that even works?) in case you want to try your luck..

Heck, it’s all in there what we need!

We could even automatically publish the transcribed text on Facebook and then reimport to Evernote, after having tweeted an excerpt :wink:

the options I get through the GUI are to save as

  1. Rich Text or

OK, so it does save the file. Why are we going through TextEdit then? Rtf can directly be imported to Evernote. If it really forces the rtf to be opened in TextEdit, then it’s completely sufficient to simply close the TextEdit window while the Evernote import is already running. But I really can’t imagine that the force-opening of the file in TextEdit can’t be disabled somehow…

I can try to set up an AppleScript, based on the Dragon dictionary. But this will be a shot in the dark (or at least in the dusk) because I can’t run the script. But it shouldn’t be too complicated, basically:

  1. When triggered, import the audio to Dragon:
  • In AppleScript this will either be simply open or make [document] with data
  1. The transcription process, which I don’t know. But if the preferences are all set, maybe it’s as simple as doing nothing, assuming that the make with data already starts the transcription process. (According to your macro you aren’t doing big stuff here.) You’ll have to check this out and maybe fiddle around a bit…
  2. save in [filename] as [rtf], close window 1
  3. Handover to the Evernote script, etc.

Like this?

tell application "Keyboard Maestro Engine"
	set fileBase to make variable with properties {name:"TS__File base"}
	set fileBase to value of fileBase
	set inFolder to make variable with properties {name:"TS__In folder"}
	set inFolder to value of outFolder
end tell

tell application "Dragon"
	open document with data (inFolder & "/" & fileBase & ".mp3")
    save in (outFolder & "/" & fileBase & ".rtf")
	close window 1
end tell

(now add the portion about append text to file and the next script to import into Evernote, no need for the script to save to a file, since we just did that, right?)
dvd

Voilà, great! Does it work?

You see, it’s less complicated than scripting a dozen mouse clicks and keystrokes :wink:

no need for the script to save to a file, since we just did that, right?

If you mean the TextEdit part, No. You can skip this. Except if Dragon force-opens a TextEdit window, then you should simply close it via AppleScript.

Nope. I get a window Keyboard Maestro - AppleScript Results
The output of the text script is:

/var/folders/k2/5g94lc3s0_1dp78vq33krch40000gn/T/Keyboard-Maestro-Script-8A76ACBC-77BE-4651-9599-1606844228DA:386:387: 
script error: Expected “given”, “with”, “without”, other parameter name, etc. but found “(”. (-2741)

hm. I fiddled with the line “open document with data” (“open document with” and “open document”) but no result. Dragon doesn’t do anything.

I had another error before, re outFolder not being defined, so I added this line under the inFolder line:

set inFolder to make variable with properties {name:"TS__In folder"}

but still doesnt work…

For setting up AppleScripts you should use the Script Editor, which is preinstalled on your Mac.

It gives you more debug info and it autocorrects the syntax in many cases. The important info you find in the bottom part of the window; set it to Events or Replies:

You can even do this with the unmodified KM variables in the AppleScript. You just have to make sure that the variables are correctly set. Currently they will likely be deleted because of the cleanup at the end of the KM macro. Disable the cleanup and run the macro, or run the actions that initialize the variables individually.

You can check the values of the variables in KM’s preferences.

Expected “given”, “with”, “without”, other parameter name, etc. but found “(”. (-2741)

You’ll have to tell it that the expression in the parenthesis is a file. So —probably:

open document POSIX file (inFolder & "/" & fileBase & ".mp3")    

(with or w/o document )

But are you sure it isn’t the make command? Or is this for creating a new voice recording?

inFolder is already defined in your script above. What you want is:

  set outFolder to make variable with properties {name:"TS__Out folder"}
  set outFolder to value of outFolder

still won’t work. I get this error:
"Script Error:
Dragon got an error: Can’t get POSIX file “/Users/david/Dropbox/Apps/Voice Record Pro/20160329-155754 00-28-13-685b.mp3”."
I tried all sorts of combinations:

open POSIX file (inFolder & “/” & fileBase & “.mp3”)
open document POSIX file (inFolder & “/” & fileBase & “.mp3”)
open file
open document
open document file
and all the options with “make” instead.

I get this error, or (I feel like more often when I put in “make”) Dragon closes and wants me to send a bug report to the mothership.

Its ok, I think my ‘brute force’ method is workable, especially once I have moved this to a headless machine…

Well, if the file opening doesn’t work stay with the brute force. What we needed is Dragon user with some scripting experiences. I looked in the Dragon forum, but for “AppleScript” I get exactly 10 (not so competent) search results.

As a last attempt ;), I would try to do at least the save with AppleScript. According to the dictionary this seems to be unambiguous:

Well then… :roll_eyes: --> :grinning: