OpenASR / idiolect

🎙️ Handsfree Audio Development Interface
https://arxiv.org/pdf/2305.03089.pdf
Apache License 2.0
93 stars 10 forks source link

Add more slots to `command.gram` and re-use Intent logic in `idear-lambda` #41

Closed nalbion closed 1 year ago

nalbion commented 7 years ago

As I work through the commands in ASRControlLoop and convert to code for Lambda it occurred to me that a better way of going forward would to adapt the CMU Sphinx impl to re-use the logic that I'm writing for Lambda.

There are a couple of patterns which use slots, eg:

<jump_command> = jump <number> | end of line | beginning of line;

but fun applyAction(c: String): Any ignores the slot values.

Example - OpenView

class OpenView(val slots: Map<String, String>?): Intent {
    override fun handleRequest(): LexFulfillmentResponse {
        val view = slots?.get("View")
        return when (view) {
            "settings" -> openView(view, "ShowSettings")
            "recent", "recent files" -> openView(view, "RecentFiles")
            "terminal" -> openView(view, "ActivateTerminalToolWindow")
            else -> elicitSlot(this.javaClass.simpleName!!,
                    "View",
                    "I know how to open \"settings\", \"recent files\" and the \"terminal\"")
        }
    }

    private fun openView(view: String, action: String): LexFulfillmentResponse {
        return fulfilled("opening" + view, mapOf("invokeAction" to action))
    }
}