Problem running Dictation.start() more than once in a script

I’m writing a script that will allow me to dictate a list, but the second invocation of Dictation.start() always seems to hang.

See this simple example:

let speech = await Dictation.start();
console.log(speech);

speech = await Dictation.start();
console.log(speech);

If you run this and hit done when the first dictation screen comes up, the second one opens but then hangs.

Anyone have any ideas?

Same result for me on latest beta release. I suspect it may be a timing issue. I tried a few things and if I get a notable delay between steps it then works.

e.g. a bit of an extreme, but succinct example.

console.log(await Dictation.start());
console.log(await Location.current());
console.log(await Dictation.start());

Maybe it is something Simon could account for in the app?

2 Likes

Interesting, I’d wondered if a delay might help, you can see that the second dictation screen hasn’t gone before the new one starts - but I coldn’t find a sleep or delay function. Good idea using Location.

I coldn’t find a sleep or delay function

Scriptable has nothing like it out of the box (because JavaScript Core doesn’t provide them), but you can set an asynchronous timer using this module.

1 Like

I’ve noted it as a bug. I’ll look into it for a future update — if all goes well, then for the next update.

Thanks for filing the bug report. It’s extremely complicated to test all cases and combinations the different APIs may be used in so I’m super happy when someone tries something out and files a bug report if it doesn’t work.

2 Likes

I have found and fixed the issue. The fix will be included in the next update.

2 Likes

Yay - fixed!

Here’s the first draft of “Dictate to OmniFocus”: