本页面描述了如何在 macOS 上构建 sherpa-ncnn

    提示
    有关 Python API,请参考 Python API

    你只需要运行以下命令:

    1. git clone https://github.com/k2-fsa/sherpa-ncnn
    2. cd sherpa-ncnn
    3. mkdir build
    4. cd build
    5. cmake -DCMAKE_BUILD_TYPE=Release ..
    6. make -j6

    构建完成后,你将在 bin 目录中找到两个可执行文件:

    1. $ ls -lh bin/
    2. total 24232
    3. -rwxr-xr-x 1 fangjun staff 5.9M Dec 18 12:39 sherpa-ncnn
    4. -rwxr-xr-x 1 fangjun staff 6.0M Dec 18 12:39 sherpa-ncnn-microphone

    就这样!

    请阅读 预训练模型 了解生成的二进制文件的使用方法。

    如果你想了解更多,请继续阅读。

    你可以通过以下命令剥离二进制文件:

    1. $ strip bin/sherpa-ncnn
    2. $ strip bin/sherpa-ncnn-microphone

    剥离后,每个二进制文件的文件大小是:

    1. $ ls -lh bin/
    2. total 23000
    3. -rwxr-xr-x 1 fangjun staff 5.6M Dec 18 12:40 sherpa-ncnn
    4. -rwxr-xr-x 1 fangjun staff 5.6M Dec 18 12:40 sherpa-ncnn-microphone

    提示
    默认情况下,所有外部依赖项都是静态链接的。这意味着生成的二进制文件是自包含的。

    你可以使用以下命令检查,并且你会发现它们只依赖于系统库:

    1. $ otool -L bin/sherpa-ncnn
    1. bin/sherpa-ncnn:
    2. /usr/local/opt/libomp/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
    3. /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
    4. /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
    1. $ otool -L bin/sherpa-ncnn-microphone
    1. bin/sherpa-ncnn-microphone:
    2. /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
    3. /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
    4. /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
    5. /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1677.104.0)
    6. /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1069.24.0)
    7. /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
    8. /usr/local/opt/libomp/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
    9. /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)

    如果遇到任何问题,请在 https://github.com/k2-fsa/sherpa-ncnn/issues 创建一个问题。