2个稳定版本
1.0.1 | 2021年7月16日 |
---|
#2903 in 解析实现
17KB
119 行
bmOS_client
bmOS_client是一个负责从stdin接收和解析JSON输入,并以足够的置信度(>0.6)将意图发送到提供的地址和端口(到bmOS_server)的可执行文件。这是运行我的自定义BMO-Boy所需软件的一部分。图像和博客文章即将推出。
期望输入
bmOS_client期望JSON字符串,格式如此处指定,并查找意图的名称和置信度,如果置信度足够,则发送它。
警告
- bmOS_client很笨。它不会检查它发送的意图是否在bmOS_server中正确定义,因此发送未定义的意图将在目标处导致panic。
- 如果发送意图时服务器不可用,或者接收到的输入不符合它期望的JSON输入,bmOS_client将panic。没有尝试恢复丢失的连接。
- 在bmOS_client开始之前,bmOS_server需要运行并监听新的连接。
推荐设置
一切设计都围绕voice2json作为意图识别的来源。文档可在此处找到。最佳结果是在默认配置文件中获得的,包括英语和西班牙语,尽管如果环境嘈杂,应预计会有一定数量的假阳性。以下是barebones sentences.ini文件的示例(这是我下载的配置文件所做的唯一修改)
[hello]
hi beemo
hello beemo
[song]
play a song beemo
[sad]
you are ugly beemo
[angry]
i hate you beemo
[surprise]
surprise beemo
[chronometer]
start a chronometer beemo
give me a chronometer beemo
[5more]
give it (five | 5) minutes more
[10more]
give it (ten | 10) minutes more
[20more]
give it (twenty | 20) minutes more
[5less]
take (five | 5) minutes less
[10less]
take (ten | 10) minutes less
[20less]
take (twenty | 20) minutes less
[done]
it is done beemo
i have finished beemo
以下是bash脚本的示例,该脚本从bmOS_server的主机设置音频流,在运行bmOS_client的本地主机上接收它,并将其通过voice2json管道到stdout(然后应该将其管道到bmOS_client)
ssh pi@[ip_address_here] "rec -c 2 -t wav -" | sox - -d -t raw -r 22.05k -b 8 - gain -5 | sudo ./voice2json.bash --profile /profile/ transcribe-stream --audio-source - | sudo ./voice2json.bash --profile /profile/ recognize-intent
其中voice2json.bash包含启动voice2json docker容器的脚本,en-us_kaldi-zamia是使用的配置文件名称,应将其更改为正在使用的任何配置文件
docker run -i \
--init \
-v "[path_to_local_dir]/voice2json/profile:/profile/" \
-v "[path_to_local_dir]/voice2json/profile:/root/.local/share/voice2json/en-us_kaldi-zamia/" \
-w "$(pwd)" \
-e "HOME=${HOME}" \
s
依赖关系
~59KB