16375| 23
|
【行空板教程】语音识别助手 |
本帖最后由 Hockel 于 2022-4-18 19:50 编辑 前言过去五年,受到智能音箱,车载助手,手机语音小助手等设备及消费和互联网增值服务的影响,中国智能语音识别技术需求不断增长。语音识别貌似再也不是什么神秘的东西,深深的融入到我们的生活中来。那么我们是不是可以从零开始搭建我们的语音识别助手呢?好了,废话不多说,就让我们用行空板来完成的需求吧。 项目原理本项目进行语音识别主要调用了百度的语音识别接口进行完成的:
课前准备1、百度语音API接口的申请打开百度的语音识别网站(https://ai.baidu.com/tech/speech) 进行语音识别的申请,登录账户后,没有应用的读者,可以点击创建应用。进行应用的创建。 对我们的应用进行命名,步骤如下: 点击创建完成后,点击查看应用详情。 就可以看到我们应用(APPID,APIKEY,SECRET KEY)等信息,这个要留着我们后面会用到 注意:如果是新用户一定要领取一下我们语音识别的额度啊,不领取没有办法调用 2、行空板设置2.1行空板的进行联网设置我们用电脑来连接行空板,然后打开浏览器输入:10.1.2.3,来到行空板的网页菜单。 点击网络设置,然后扫描附近的WiFi ,选择你要用的WiFi输入密码,进行连接 2.2 打开Jupyter服务程序的编写,使用的是jupyter notebook,一个非常好用的编译器,所以我们要确保自己的应用是否打开此项服务。 同样我们可以在行空板上,进行打开此服务。 3、安装baidu-aip的python 版本的sdk我们需要启用终端来进行安排,这里我用jupyter的终端进行,首先在行空板的应用开关界面打开页面。 在新建下拉框中找到终端选项,进行安装。 终端第一次登录的读者,需要输入账号: 然后在终端输入:
(PS:因为我这边已经安装了,所以提示安装文件已存在。) 4、上传素材文件到行空板你们看到我们界面的按钮,背景,实际上是图像素材,在使用它之前我们需要他们导入到我们的行空板上,如何把素材上传到我们的板子上呢?这里我使用的是行空板菜单界面进行传输,当然还有些其他方法,我这里就不一一赘述。 选择我们上传的文件上传到root/目录下面, (PS:当然你也可以闲着其他目录下,但是我们调用的时候,路径一定要对哈) 好了,至此我们的所有准备工作已经完成。能坚持看到这里的读者,给你点个赞。 相关知识点学习行空板屏幕分辨率为240*320,因此unihiker库分辨率也为240320,坐标原点为屏幕左上角,向右为x轴正方向,向下为y轴正方向。 1-文字 draw_text语法:
2-图片 draw_image语法:
3-按钮 add_button语法:
程序编写1、布局我们的UI界面
效果: 2、添加相应事件
效果: 3、美化界面
效果 总结ok!到这里我们本次的行空板教程:语音识别助手就结束了,我们通过此教程学会了:行空板的基础空间的使用,相关环境的安装,百度api接口的调用,文件的上传等操作。不知道屏幕前的读者学会了吗?相关素材和源码。关注公众号:跟着hockel玩科创,回复”语音助手“即可获得哈。 |
错误提示:Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/urllib3/connection.py", line 175, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "/usr/local/lib/python3.7/dist-packages/urllib3/util/connection.py", line 72, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -3] Temporary failure in name resolution During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 710, in urlopen chunked=chunked, File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 1040, in _validate_conn conn.connect() File "/usr/local/lib/python3.7/dist-packages/urllib3/connection.py", line 358, in connect conn = self._new_conn() File "/usr/local/lib/python3.7/dist-packages/urllib3/connection.py", line 187, in _new_conn self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f921d1080>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 450, in send timeout=timeout File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 786, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "/usr/local/lib/python3.7/dist-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='aip.baidubce.com', port=443): Max retries exceeded with url: /oauth/2.0/token?grant_type=client_credentials&client_id=nsog0FXfPV8SI7fO4rajQdyN&client_secret=CSWcIau1IzrTIfOuxXerFzuiG5jclc0M (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f921d1080>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.7/tkinter/__init__.py", line 1705, in __call__ return self.func(*args) File "/root/ctuy/cut.py", line 14, in <lambda> gui.add_button(text="按钮",origin='center',onclick=lambda:Record(),x=120,y=110,w=100,h=30) File "/root/ctuy/cut.py", line 42, in Record msg = voiceToText() File "/root/ctuy/cut.py", line 33, in voiceToText 'dev_pid': 1537, File "/usr/local/lib/python3.7/dist-packages/aip/speech.py", line 78, in asr return self._request(self.__asrUrl, data) File "/usr/local/lib/python3.7/dist-packages/aip/base.py", line 89, in _request authObj = self._auth() File "/usr/local/lib/python3.7/dist-packages/aip/base.py", line 168, in _auth ), proxies=self._proxies).json() File "/usr/local/lib/python3.7/dist-packages/requests/api.py", line 75, in get return request('get', url, params=params, **kwargs) File "/usr/local/lib/python3.7/dist-packages/requests/api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 529, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 645, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 519, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='aip.baidubce.com', port=443): Max retries exceeded with url: /oauth/2.0/token?grant_type=client_credentials&client_id=nsog0FXfPV8SI7fO4rajQdyN&client_secret=CSWcIau1IzrTIfOuxXerFzuiG5jclc0M (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f921d1080>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))怎么办,求大佬 |
>>> /Users/xiaoling/Documents/mindplus-py/environment/Python3.8.5-64/lib/python3.8/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning) Traceback (most recent call last): File "/Users/xiaoling/Documents/mindplus-py/user/2023-12-29-21-11-20/baidu-ai.py", line 1, in <module> from unihiker import GUI,Audio #导入包 File "/Users/xiaoling/Documents/mindplus-py/environment/Python3.8.5-64/lib/python3.8/site-packages/unihiker/__init__.py", line 2, in <module> from unihiker.Audio import Audio File "/Users/xiaoling/Documents/mindplus-py/environment/Python3.8.5-64/lib/python3.8/site-packages/unihiker/Audio.py", line 22, in <module> c_error_handler = ERROR_HANDLER_FUNC(py_error_handler) MemoryError 运行的时候提示这个,跑不起来,请问啥原因 |
提示错误:File "/usr/local/mindplus/cache/新建项目-2022-4-15-11-12-57/YUNXING.py", line 15, in <module> gui.draw_image(x=0, y=0, w=240, h=320, image='beijing.png') File "/usr/local/lib/python3.7/dist-packages/unihiker/GUI.py", line 444, in draw_image return GUI.CanvasImage(self, **kw) File "/usr/local/lib/python3.7/dist-packages/unihiker/GUI.py", line 426, in __init__ self.preprocess(kw) File "/usr/local/lib/python3.7/dist-packages/unihiker/GUI.py", line 408, in preprocess image = Image.open(image) File "/usr/local/lib/python3.7/dist-packages/PIL/Image.py", line 2953, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: 'beijing.png' root@unihiker:/usr/local/mindplus/cache/新建项目-2022-4-15-11-12-57# |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed