本页面描述了如何在 macOS 上构建 sherpa-ncnn。
提示
有关 Python API,请参考 Python API。
你只需要运行以下命令:
git clone https://github.com/k2-fsa/sherpa-ncnn
cd sherpa-ncnn
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j6
构建完成后,你将在 bin
目录中找到两个可执行文件:
$ ls -lh bin/
total 24232
-rwxr-xr-x 1 fangjun staff 5.9M Dec 18 12:39 sherpa-ncnn
-rwxr-xr-x 1 fangjun staff 6.0M Dec 18 12:39 sherpa-ncnn-microphone
就这样!
请阅读 预训练模型 了解生成的二进制文件的使用方法。
如果你想了解更多,请继续阅读。
你可以通过以下命令剥离二进制文件:
$ strip bin/sherpa-ncnn
$ strip bin/sherpa-ncnn-microphone
剥离后,每个二进制文件的文件大小是:
$ ls -lh bin/
total 23000
-rwxr-xr-x 1 fangjun staff 5.6M Dec 18 12:40 sherpa-ncnn
-rwxr-xr-x 1 fangjun staff 5.6M Dec 18 12:40 sherpa-ncnn-microphone
提示
默认情况下,所有外部依赖项都是静态链接的。这意味着生成的二进制文件是自包含的。
你可以使用以下命令检查,并且你会发现它们只依赖于系统库:
$ otool -L bin/sherpa-ncnn
bin/sherpa-ncnn:
/usr/local/opt/libomp/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
$ otool -L bin/sherpa-ncnn-microphone
bin/sherpa-ncnn-microphone:
/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1677.104.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1069.24.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
/usr/local/opt/libomp/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
如果遇到任何问题,请在 https://github.com/k2-fsa/sherpa-ncnn/issues 创建一个问题。