如果你想直接在你的开发板上构建 sherpa-ncnn,可以按照此部分进行操作

    有关 Python API,请参考 Python API

    你只需要运行以下命令:

    x86/x86_64

    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

    32位 ARM

    1. git clone https://github.com/k2-fsa/sherpa-ncnn
    2. cd sherpa-ncnn
    3. mkdir build
    4. cd build
    5. cmake \\
    6. -DCMAKE_BUILD_TYPE=Release \\
    7. -DCMAKE_C_FLAGS="-march=armv7-a -mfloat-abi=hard -mfpu=neon" \\
    8. -DCMAKE_CXX_FLAGS="-march=armv7-a -mfloat-abi=hard -mfpu=neon" \\
    9. ..
    10. make -j6

    64位 ARM

    1. git clone https://github.com/k2-fsa/sherpa-ncnn
    2. cd sherpa-ncnn
    3. mkdir build
    4. cd build
    5. cmake \\
    6. -DCMAKE_BUILD_TYPE=Release \\
    7. -DCMAKE_C_FLAGS="-march=armv8-a" \\
    8. -DCMAKE_CXX_FLAGS="-march=armv8-a" \\
    9. ..
    10. make -j6

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

    1. $ ls -lh bin/
    2. total 13M
    3. -rwxr-xr-x 1 kuangfangjun root 6.5M Dec 18 11:31 sherpa-ncnn
    4. -rwxr-xr-x 1 kuangfangjun root 6.5M Dec 18 11:31 sherpa-ncnn-microphone

    就这样!

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

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

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

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

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

    1. $ ls -lh bin/
    2. total 12M
    3. -rwxr-xr-x 1 kuangfangjun root 5.8M Dec 18 11:35 sherpa-ncnn
    4. -rwxr-xr-x 1 kuangfangjun root 5.8M Dec 18 11:36 sherpa-ncnn-microphone

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

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

    1. $ readelf -d bin/sherpa-ncnn
    1. Dynamic section at offset 0x5c0650 contains 34 entries:
    2. Tag Type Name/Value
    3. 0x0000000000000001 (NEEDED) Shared library: [libgomp.so.1]
    4. 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
    5. 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
    6. 0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
    7. 0x0000000000000001 (NEEDED) Shared library: [libmvec.so.1]
    8. 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
    9. 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
    10. 0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN:]
    1. $ readelf -d bin/sherpa-ncnn-microphone
    1. Dynamic section at offset 0x5c45d0 contains 34 entries:
    2. Tag Type Name/Value
    3. 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
    4. 0x0000000000000001 (NEEDED) Shared library: [libgomp.so.1]
    5. 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
    6. 0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
    7. 0x0000000000000001 (NEEDED) Shared library: [libmvec.so.1]
    8. 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
    9. 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
    10. 0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN:]

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