My Own Transcription Service

thanks for the speedy help, Tom!

I use it in conjunction with a macro I got here:
the "latest file". Here is a screenshot:

in the above script that Peter provides the result is diplayed as text in a box. I disabled it, but if enabled it gives me the correct result. (name and path of the latest file) The next part doesn't work:

it seems to be related to file managent, because this part at the very end of the macros also fails to work:

(deleting files)

Any ideas what I am doing wrong?

For some reason the screenshots are mixed up, sorry about that.

The only thing I can see in this screenshot is that you are resetting two variables. The For Each Item action is collapsed. So, what is not working?
(As mentioned, it would be helpful if you upload the macro.)

because this part at the very end of the macros also fails to work:

You don’t have to script the UI for this. There are dedicated actions for this kind of things:

This will work reliably.

ok, figured out how to export the macros. Here they are. I broke it down into several, because it was too difficult for me to figure out which parts work/dont work otherwise. I hope that makes sense...?

1 New Voice Recording.kmmacros (8.5 KB)
2 Transcribe Files.kmmacros (6.5 KB)
3 Evernote Import.kmmacros (7.6 KB)
<a class="attachment"href="/uploads/default/original/2X/d/dec3d4e592f913c1250a4cab4a306110d5890bb8.kmmacros">4 Cleanup.kmmacros (3.6 KB)

thank for the delete action. i’ll try it out.

ok, figured out how to export the macros.

Sorry, I haven’t seen that you downloaded KM only yesterday.


Apart from the technical things, I have some questions for better understanding:

  • What is the mouse click in macro 2 for?
  • I don’t have Dragon. When you right-click a mp3 file in the Finder do you see Dragon in the Open With menu?
  • I think there’s a conceptual problem in the selection process in macro 1: Apparently you want to forward exactly one file (the most recent) to Dragon. But this way the remaining files —if there are any— will stay in the incoming folder forever. So, IMO, the better idea would be to run the whole macro chain through all files, one after the other, no matter how many there are. Or are there reasons not to do this?
  • Is there a specific reason why you want to forward the most recent file to the “In Progress” folder?
  • Why do you want to rename the most recent file to “1.mp3”? Or did you drop this idea, since I don’t see any correspondent renaming attempt in the macros?

Ok, here is a “prototype” macro. It does not exactly what you want (I don’t have Dragon) but it demonstrates how to do some things, and I think it goes roughly in the direction you want:

  1. It watches a folder.
  2. It opens a newly arrived file in TextEdit
  3. It does some stuff in TextEdit (exports it as PDF, just to show)
  4. It tags the PDF.
  5. It imports the PDF to Evernote.
  6. It goes on with the next file in the watched folder…

Of course, to try it out you have to use .txt files, not .mp3! And you have to adapt the folder paths to the ones on your Mac.

This macro can still be seriously optimized, for example the whole UI stuff in TextEdit should be done with AppleScript. But this to show you how to press buttons, open menus, open files with specified applications, etc.

It shouldn’t be too hard now to figure out how to do the part with Dragon.

Try to put the Dragon part before the TextEdit stuff, or, if you don’t need to open the output in TextEdit (for previewing or whatever) you can just replace the whole TextEdit group with something equivalent for Dragon. I’m sure Dragon can save the output as .txt/.rtf/.pdf, so it will work flawlessly with the last part (Evernote).

[Prototype] Transcription Service.kmmacros (13.6 KB)


1 Like

Hi Tom,
thank you so much for looking at this. Macro 2 and 3 work. Its a bit cumbersome, because I use the GUI for all of this, but it was easiest and fastest to make it happen. I will adjust this and run it on a mac I mainly use as media server and backup, so that isn’t such a big deal though.

Where I run into trouble are the file processing actions in Macro 1 and 4.

I am looking at your prototype macro in more detail, and still need to understand it (I have no programming background of any kind) I thought I’d attempt to explain what I am trying to accomplish conceptually.

Macro 1 starts the process if a new file arrives in the folder.

  • Yes, I haven’t figured out the part yet what happens if I upload more than one file at a time. I tried to accomplish this that it pauses while the other macros are running. But the Semaphore is probably more elegant, I’ll change that around and see how it works. This also means I don’t need to identify the newest file. If I understand correctly, this means it fires off for every new file added to the folder, but will wait until the process has run its course before continuing?

Macro 2 opens dragon and starts the transcription.

  • This is done with a mouse click, as dragon does not let you do this with keyboard shortcuts, and I couldnt get KM to recognise the button. But it works.
  • You are right, I can only send one file at a time to Dragon. It goes through the transcription process and spits out the rtf file in textEdit. TExtEdit opens automatically with the result.

Macro 3 copies everything into Evernote

  • at this point I simply want to copy and paste the text into Evernote.
  • the other thing is I want to select the MP3 file that was just processed and append/attach it to the same evernote note I just created. Again, doing all of this over the GUI with Keyboard shortcuts maybe isnt the most beautiful and efficient way to accomplish the result, but it gets the job done and it works. With more than one file in the folder I nee to figure out how to ensure the right file gets selected…

Macro 4 cleans up: closes TextEdit, deletes the mp3 file and RTF file from the hard drive
The problem I was facing is mainly the processing of files, that doesn’t seem to do anything. I move and rename the file, but it doesn’t work. I try to delete the file, but it doesn’t work either. Your other post about the deleting of all the files in a folder was helpful though (“for each item in a collection”) and should take care of this. No way I would have found that on my own. That works nicely.

I will go through the macro you sent me and adjust it a bit for using it with Dragon and try it again. I’ll post back here if I could get to to work!

If I understand correctly, this means it fires off for every new file added to the folder, but will wait until the process has run its course before continuing?

Yes. Also when two files arrive almost at the same time it will process one after the other. Without the semaphore lock the instances of the macro would interfere with each other, especially with the “For each” loop you had in the original macro.

To see what I mean: open the debugger (in the KM menu) and drop 2 or more files into the watched folder. You’ll see that for each file one instance of the macro will run. (Without the semaphore lock.)

This is done with a mouse click, as dragon does not let you do this with keyboard shortcuts, and I couldnt get KM to recognise the button. But it works.

Please have a look at my macro. It should be possible to open the file in Dragon with an “Open file with Dragon” action. (The same as I have done it with TexTEdit and Evernote.)

at this point I simply want to copy and paste the text into Evernote.

If you just want to get the text and don’t have any need for previewing or editing in TextEdit, then there is no need to pass the file through TextEdit. The same as above: use an “Open file with…” action.

the other thing is I want to select the MP3 file that was just processed and append/attach it to the same evernote note I just created. Again, doing all of this over the GUI with Keyboard shortcuts maybe isnt the most beautiful and efficient way to accomplish the result, but it gets the job done and it works. With more than one file in the folder I nee to figure out how to ensure the right file gets selected…

No, for opening the mp3 in Evernote, you should not need UI scripting either. “Open with…” should also work here. The path of the original mp3 file is still in the variables! So, no need for guess-work or mouse clicking on files in the Finder!

Once the file is open in Evernote you may use some keypresses to attach it to the correct note. Not sure, I don’t use Evernote. But Evernote is also AppleScript-able, I’ve seen.

The problem I was facing is mainly the processing of files, that doesn’t seem to do anything. I move and rename the file, but it doesn’t work.

This definitively works now in the prototype macro.

Your other post about the deleting of all the files in a folder was helpful though

Oh, yes. I forgot about this. Just attach it at the end, with the appropriate path variables. But, please don’t use automated mouse clicking in the Finder to select files for deletion :sweat:

I will go through the macro you sent me and adjust it a bit for using it with Dragon and try it again. I’ll post back here if I could get to to work!

I think the prototype macro contains almost everything you need for doing it in a cleaner way. Just take your time and try to understand how it works.

Once you have your final workflow working, or almost working, we can optimize it, for example by replacing remaining keystroke / mouse click commands with AppleScript, if possible.

But now you already have the tools to avoid 90% of the keystrokes and clicks from your original macros.

Hi Tom,
thanks for your extensive reply.

  • Dragon does not provide any Menu at the top like other mac apps.
  • As far as I can tell, and I have investigated, it also doesn't provide
    any keyboard shortcuts. Seems like I am stuck with a mouse action.
  • It is also not my choice to run the text through TextEdit. Dragon lets me chose
    TextEdit or MS Word as output option. Word takes forever to load in comparison.
  • I saw another option to copy the text to the clipboard so will try that out tomorrow, but either way a TextEdit File opens and is in focus.

Here is my latest revision.
Transcription Service.kmmacros (18.5 KB)

A few notes:

The Semaphore lock is deactivated because I have the impression, that if the macro doesn't run its full course, it is 'stuck'. I saw the option to time out, but takes too much time during testing...

I am not quite sure what the variables are supposed to be for these two actions: "read File to clipboard" and "trash File". I tried %TriggerValue%, %Variable%TS__In folder%/%Variable%TS__File%, %Variable%TS__File%, TS_File, %TS_File%, they all don't seem to work and I just don't have the programming knowledge to make enough sense of it...

Regarding input into Evernote, yes, this is doable with AppleScript, and I see the benefit of not having to go through the GUI. But I have no clue how that works. This is quick and dirty, but if I can select the mp3 file, copy and paste and delete it, the process should work as desired and be fine.

Dragon does not provide any Menu at the top like other mac apps.
As far as I can tell, and I have investigated, it also doesn’t provide
any keyboard shortcuts. Seems like I am stuck with a mouse action.
It is also not my choice to run the text through TextEdit. Dragon lets me chose
TextEdit or MS Word as output option.

Are you sure that this a serious program? :hushed:

The Semaphore lock is deactivated because I have the impression, that if the macro doesn’t run its full course, it is ‘stuck’. I saw the option to time out, but takes too much time during testing…

Of course. As long as the 1st macro runs (or is “stuck” without being aborted) the 2nd won’t start. If it would start you would end up with 2 stuck macros :wink:

Every action has a gear icon at the right-hand side. There you also can set how long it should take to time out, and whether the macro should be cancelled on action failure.

I am not quite sure what the variables are supposed to be for these two actions: “read File to clipboard” and “trash File”. I tried %TriggerValue%, %Variable%TS__In folder%/%Variable%TS__File%, %Variable%TS__File%, TS_File, %TS_File%, they all don’t seem to work

You’re moving too fast :wink: You really should take a bit of time to understand how it works. Instead of “trying” the variables, look at the beginning of my macro, where you can see how to set up the variables. I’ve made the macro to show you how to do it…

For example: In your last action you are looping through all files (‘For each “File”’) in the directory. If you want to trash each file you have to use the variable %Variable%File%. If you use %TriggerValue% you will only trash the one file that has triggered the macro.

Or, the other way round, if you only want to trash this trigger file (what I suspect), you don’t need to loop through all files in the directory. In this case the file to trash would be [directory]+[file name], that is

/Users/david/Dropbox/Apps/Voice Record Pro/%TriggerValue%

or, expressed by means of variables:

%Variable%TS__In folder%/%TriggerValue%

or

%Variable%TS__In folder%/%Variable%TS__File%

The variables TS__In folder and TS__File have been declared in the first two active actions in your macro. Bingo.

[quote]
Every action has a gear icon at the right-hand side. There you also can set how long it should take to time out, and whether the macro should be cancelled on action failure.[/quote]
can’t find ‘cancelled on action failure’ but haven’t had time to dig through any documentation yet…

yes. you are right. OK got this one.

Like I said, I am not a programmer of any kind the most complicated thing I did was do some html, like 20 years ago… I just wasn’t sure about the syntax (e.g. where to put % or %Variable% etc and where to leave it away…)

I went with %Variable%TS__In folder%/%Variable%TS__File% … but alas, it doesn’t work… The file doesn’t get copied, or trashed…

BTW I did some research and apparently there is some applescript possibilities with Nuance Dragon, but it is very poorly documented, and it is similar to what I just said, I don’t really know how to do it, so will stick with this rather crude approach for now.

David

That’s rather self-explaining. This, for example, is the gear popup of the mouse action:


I just wasn't sure about the syntax (e.g. where to put % or %Variable% etc and where to leave it away...)

The %Variable%…% notation serves to mark a variable explicitly as variable, and as such it is only needed when it is not clear wether it’s text or variable. For example:

  • In field #1 only variables are accepted (“Set variable”). No need for %Variable%…% stuff.
  • Field #2 is primarily a text field (see the title of the action: “Set variable to Text“). With the %Variable%…% notation you are telling KM that it has to treat this as variable, and not as literal text.

That’s all :smile:

ok, thanks for explaining the syntax. I don’t have that option in my context menu ‘failure Aborts Macro’. Still can’t seem to get any of the file operations to work as intended… Is there something I am missing, maybe I need to give KM permissions to handle files somewhere?

Sorry, just saw ‘failure aborts macro’ is available for the mouse movement. So it aborts if the mouse fails to click where it is supposed to… which isn’t really the problem at this point.

I feel like the Semaphore Lock part makes it unreliable. I paste a new file into the folder, one time it works, the next 10 it doesn’t. I made another macro triggered by a shortcut to reset the Semaphore Lock, but don’t see it making any difference either.

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?

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.