【发布时间】:2021-05-23 12:09:36
【问题描述】:
我正在尝试让胡椒机器人听基本的语音命令。问题是该语言不受支持,我必须为此使用谷歌语音转文本而不是机器人的默认识别库。 用模拟器测试会更方便,而不是每次都安装在真正的机器人上。但我找不到任何关于如何在模拟器中模拟出现在机器人面前的人的信息。如果这是不可能的,也许有一些解决方法?
override fun onRobotFocusGained(qiContext: QiContext) {
this.qiContext = qiContext
Utils.defaultHolderBuilder(qiContext).build().async()?.release()
qiContext.humanAwareness?.addOnHumansAroundChangedListener { humansAround ->
if (humansAround.isNotEmpty()) {
listenToHuman(qiContext, humansAround)
}
}
}
也许我可以只调用提供给addOnUpdatedListener 的那个函数,但是我应该如何调用它呢?也许从程序中模拟一些测试广播?
listenToHuman 函数:
private fun listenToHuman(qiContext: QiContext, humansAround: MutableList<Human>) {
val actuation: Actuation = qiContext.actuation
val robotFrame: Frame = actuation.robotFrame()
val closestHuman = ...get closest human
closestHuman?.headFrame?.addOnUpdatedListener {
val distance: Double = ...computeDistance
if (availableForListening) {
availableForListening = false
Qi.onUiThread {
mLastResultTextView.text = "Listening"
mSpeechRecognizer.startListening(speechIntent)
}
}
}
}
【问题讨论】: