My Own Transcription Service

How can I abort the whole macro, rather than the one mouse action? Is there a way to see if the macro is still running in some way? Or do I just deactivate it in KM and it stops?

When a macro is running the KM menu bar icon is animated. You can also go to the KM menu > Cancel. There you see if and which macro is running, and you can cancel it from there, too:

If nothing is running the submenu is dimmed. You can also cancel all macros by clicking the KM menu icon while holding down ⌃⌥⇧⌘.

I paste a new file into the folder, one time it works, the next 10 it doesn't.

At this point I really think it would be a good idea to read a bit the documentation and trying to get something more simple to run, step by step:

Did you manage to get my prototype macro to run? If Yes, good, if Not try to get it to run.

Then take the last version of your macro and disable all actions except the first ones. Does it run? If Yes, then enable the next action etc. When you get stuck, then insert some “debugging” messages:

For example if a file is not picked up, it may be that something with the variable is wrong. Then insert a “Display Text” action after the variable declaration, to show the content of the variable in question, like this:

Do the same for the %TriggerValue% at the beginning of the macro. The Trigger Value should hold the name of the file you dropped into the watched folder.

If a mouse click or keystroke action fails, try it with a 3s pause instead of 0.5s. Also the Debugging mode may be helpful (see the KM menu screenshot above).

If something fails in general you’ll get a notification from the action in the top right corner of your screen. Read it, and when the text is truncated open Console.app in Applications/Utilities, filter for Keyboard Maestro and read the whole message there.

Also the engine.log may contain valuable information. You can open the log folder from within KM Editor, in the Help menu > Open Logs Folder.

ok, I got everything to work properly after rebooting the computer. Thought I left that behind when I migrated from windows..haha

There is only one little thing is left over, I cannot for the life of me figure out: I want to select the file that created the %triggerValue% and paste it into the Evernote Quick Note, which is a simple matter of copy and paste.

In my earlier verison, I moved the file to its own folder and thus, could just use keyboard shortcuts to copy and paste, since it will select the file (or I think maybe I added Cntrl&A to select all files in that folder - which would only be one).

I'm struggling to select the file. KM doesn't seem to be able to copy a file into the clipboard?
I either end up with the file name as text (when using Insert Text by Typing %TriggerValue%) or gibberish (read file %TriggerValue%). Copy File gives me the option to copy a file from one location to the other, but the options given don't include the clipboard...

Once I have that sorted out, I think the whole system works nicely. The computer might need a reboot every now and then, but that is ok.

A loosely connected question: is it possible to route the notification of a failed action etc. to something else than the mac notifications (I am thinking ahead for when I put this and other scripts on a headless system).

Next time try it with relaunching the KM engine. Normally this eliminates any quirks.

There is only one little thing is left over, I cannot for the life of me figure out: I want to select the file that created the %triggerValue% and paste it into the Evernote Quick Note, which is a simple matter of copy and paste.

I’m not an Evernote user, so maybe I’m missing something:

Why do you insist in copy-pasting the files around when you can use an “Open File with…” action, as shown in the prototype macro?

I just tried this …

… and the result is exactly in the same as when I copy-paste the file from the Finder into the Evernote Quicknote dropdown from the menu icon. And it’s cleaner than half a dozen mouse click and keystroke actions.

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?