SimpleUI 文档描述了几种从代码触发语音识别的方法:
- hashMap.put(‘listen’, ’’) - 什么也没发生
- 语音命令(无示例)
- android.listen() – 开始等待语音识别
尝试从代码启动识别:
- 通过 hashMap,什么也没有发生,没有信号表明识别已经开始
- 尝试将语音密钥传递给 hashMap,没有结果
- android.listen() 失败并出现错误:
com.chaquo.python.PyException: TypeError: Unbound method ru.travelfood.simple_ui.SimpleUtilites.listen must be called with ru.travelfood.simple_ui.SimpleUtilites instance as first argument (got nothing instead)
at <python>.java.chaquopy.JavaMethod.check_args(class.pxi:813)
at <python>.java.chaquopy.JavaMethod.__call__(class.pxi:784)
at <python>.android.listen(android.py:86)
at <python>.runscript_base.<module>(<string>:2)
at <python>.runscript_base.runscript(runscript_base.py:92)
at <python>.chaquopy_java.call(chaquopy_java.pyx:354)
at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:326)
at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
at com.chaquo.python.PyObject.callAttr(PyObject.java:221)
at ru.travelfood.simple_ui.EventManager.RunPyScript(EventManager.java:3183)
at ru.travelfood.simple_ui.EventManager.perform(EventManager.java:531)
at ru.travelfood.simple_ui.ProcessActivity.DoNext(ProcessActivity.java:1431)
at ru.travelfood.simple_ui.ProcessActivity$98.onClick(ProcessActivity.java:21744)
at android.view.View.performClick(View.java:7448)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
APK 版本 14_35_00,但尝试了更高版本,12。
Android 11 和 13
为了测试目的,我创建了一个带有一个按钮的进程以及该按钮的一个 pythonscript 处理程序。
问题:文档是最新的吗?目前推荐的从 Python 代码运行语音识别的方法是什么?是否可以设置用户语音输入的超时时间?如果可以,如何设置?
目标是通过说话启动语音合成,并在播放完成后打开用户语音的录制,而无需按下设备上的按钮。