Snippets

Furhat Robotics Example state for listening extended (for more than one utterance)

Created by Ludvig Linse
fun listenExtended(timeout: Int, rounds : Int) : State = state {
    var silenceCount = 0
    val responses = mutableListOf<Response<*>>()

    onEntry {
        if (silenceCount < rounds) {
            furhat.listen(timeout = timeout)
        }
        else {
            terminate(responses)
        }
    }

    onResponse {
        // Could do a feedback token here, if voice has one
        silenceCount = 0
        responses.add(it)
        reentry()
    }

    onNoResponse {
        silenceCount++
        reentry()
    }
}
val responses = call(listenExtended(8000, 2)) as MutableList<Response<*>>

if (responses.isEmpty()) {
	furhat.say("You said nothing")
}
else {
	furhat.say("you said")
	responses.forEach {
		furhat.say(it.text)
	}
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.