let { scripts } = await db("scripts")
let escapedScripts = scripts.map(script => ({
name: `"${script.name.replace(/"/g, '\\"')}"`,
value: script.filePath,
}))
let speakableScripts = escapedScripts
.map(({ name }) => name)
.join(",")
let speech = await applescript(String.raw`
tell application "SpeechRecognitionServer"
listen for {${speakableScripts}}
end tell
`)
let script = escapedScripts.find(
script => script.name == `"${speech}"`
)
await run(script.value)