编译snowboy 笔记

1.安装依赖

sudo apt-get install pulseaudio sox python3-pyaudio swig libatlas-base-dev python3-dev

2.获取源代码

git clone https://github.com/Kitt-AI/snowboy.git

3.编译

PS:官方源代码使用 Python3 测试有报错,经测试需修改

目录下的 snowboydecoder.py 文件。
将第 5 行代码 from * import snowboydetect 改为 import snowboydetect 即可直接运行。


备注:网上很多教程是make之后再修改,这种情况是不成功的,因为make后会生成配置文件,你这时候改了不起效果,因此先修改,在执行下一步的make。

编译 Python3 绑定:

cd snowboy/swig/Python3 && make

4.测试
进入官方示例目录 snowboy/examples/Python3 并运行以下命令:

$ python3 demo.py resources/models/snowboy.umdl

5. 常见错误

  5.1  …/…/lib/ubuntu64/libsnowboy-detect.a:error adding symbols: File in wrong format

  此错误是Makefile中没有使用正确版本的libsnowboy-detect.a

  在snowboy/lib下一共有

  aarch64-ubuntu1604/    --对应arm64 ubuntu1604,经验证ubuntu1804也可以使用
  android/                         --对应android系统
  ios/                                 --对应ios系统
  node/
  osx/                                 --对应macos
  rpi/                                   --对应树莓派32位arm
  ubuntu64/                        --对应PC Ubuntu64

  其它系统,查询电脑类型就可以知道用上面哪个了

uname -m

  因此按下面修改该目录下的Makefile就可以解决这个问题了

查看代码
 SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/ubuntu64/libsnowboy-detect.a
ifneq (,$(findstring arm,$(shell uname -m)))
  SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/rpi/libsnowboy-detect.a
  ifeq ($(findstring fc,$(shell uname -r)), fc) 
    #fedora25-armv7这个没看到
    SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/fedora25-armv7/libsnowboy-detect.a
    LDLIBS := -L/usr/lib/atlas -lm -ldl -lsatlas
  endif
endif
 
#以下修改内容请根据系统选择,这里环境为ubuntu1804
ifneq (,$(findstring aarch64,$(shell uname -m)))
  SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/aarch64-ubuntu1604/libsnowboy-detect.a
endif
 
或者前面全部注释,用下面这句
SNOWBOYDETECTLIBFILE = $(TOPDIR)/lib/aarch64-ubuntu1604/libsnowboy-detect.a
posted @ 2023-01-22 21:34  贤者无解  阅读(331)  评论(0编辑  收藏  举报