如果你想直接在你的开发板上构建 sherpa-ncnn,可以按照此部分进行操作
有关 Python API,请参考 Python API。
你只需要运行以下命令:
x86/x86_64
git clone https://github.com/k2-fsa/sherpa-ncnncd sherpa-ncnnmkdir buildcd buildcmake -DCMAKE_BUILD_TYPE=Release ..make -j6
32位 ARM
git clone https://github.com/k2-fsa/sherpa-ncnncd sherpa-ncnnmkdir buildcd buildcmake \\-DCMAKE_BUILD_TYPE=Release \\-DCMAKE_C_FLAGS="-march=armv7-a -mfloat-abi=hard -mfpu=neon" \\-DCMAKE_CXX_FLAGS="-march=armv7-a -mfloat-abi=hard -mfpu=neon" \\..make -j6
64位 ARM
git clone https://github.com/k2-fsa/sherpa-ncnncd sherpa-ncnnmkdir buildcd buildcmake \\-DCMAKE_BUILD_TYPE=Release \\-DCMAKE_C_FLAGS="-march=armv8-a" \\-DCMAKE_CXX_FLAGS="-march=armv8-a" \\..make -j6
构建完成后,你将在 bin 目录中找到两个可执行文件:
$ ls -lh bin/total 13M-rwxr-xr-x 1 kuangfangjun root 6.5M Dec 18 11:31 sherpa-ncnn-rwxr-xr-x 1 kuangfangjun root 6.5M Dec 18 11:31 sherpa-ncnn-microphone
就这样!
请阅读 预训练模型 了解生成的二进制文件的使用方法。
如果你想了解更多,请继续阅读。
你可以通过以下命令剥离二进制文件:
$ strip bin/sherpa-ncnn$ strip bin/sherpa-ncnn-microphone
剥离后,每个二进制文件的文件大小是:
$ ls -lh bin/total 12M-rwxr-xr-x 1 kuangfangjun root 5.8M Dec 18 11:35 sherpa-ncnn-rwxr-xr-x 1 kuangfangjun root 5.8M Dec 18 11:36 sherpa-ncnn-microphone
提示
默认情况下,所有外部依赖项都是静态链接的。这意味着生成的二进制文件是自包含的。
你可以使用以下命令检查,并且你会发现它们只依赖于系统库:
$ readelf -d bin/sherpa-ncnn
Dynamic section at offset 0x5c0650 contains 34 entries:Tag Type Name/Value0x0000000000000001 (NEEDED) Shared library: [libgomp.so.1]0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]0x0000000000000001 (NEEDED) Shared library: [libm.so.6]0x0000000000000001 (NEEDED) Shared library: [libmvec.so.1]0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]0x0000000000000001 (NEEDED) Shared library: [libc.so.6]0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN:]
$ readelf -d bin/sherpa-ncnn-microphone
Dynamic section at offset 0x5c45d0 contains 34 entries:Tag Type Name/Value0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]0x0000000000000001 (NEEDED) Shared library: [libgomp.so.1]0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]0x0000000000000001 (NEEDED) Shared library: [libm.so.6]0x0000000000000001 (NEEDED) Shared library: [libmvec.so.1]0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]0x0000000000000001 (NEEDED) Shared library: [libc.so.6]0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN:]
如果遇到任何问题,请在 https://github.com/k2-fsa/sherpa-ncnn/issues 创建一个问题。
