### Install dependencies and run VAD example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/dart-api-examples/vad/README.md This snippet shows the commands to get the Dart dependencies, download necessary model and audio files, and then run the VAD example to remove silences from an audio file. ```bash dart pub get wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/lei-jun-test.wav dart run \ ./bin/vad.dart \ --silero-vad ./silero_vad.onnx \ --input-wav ./lei-jun-test.wav \ --output-wav ./lei-jun-test-no-silence.wav ``` -------------------------------- ### Install Dependencies Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Before running the examples, install the necessary npm packages. ```bash cd ./nodejs-examples npm i ``` -------------------------------- ### Install dependencies and run the example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/dart-api-examples/speech-enhancement-dpdfnet/README.md This command installs the necessary Dart dependencies and then runs the speech enhancement example using a DPDFNet model. ```bash dart pub get dart run ./bin/speech_enhancement_dpdfnet.dart --model ./dpdfnet_baseline.onnx --input-wav ./inp_16k.wav --output-wav ./enhanced-16k.wav ``` -------------------------------- ### Installation Configuration Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/windows/CMakeLists.txt Configures installation paths and components for the application runtime. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Create a new example project Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/README.md This command creates a new Flutter project for streaming ASR and installs dependencies. ```bash flutter create --platforms windows,macos streaming_asr cd streaming_asr flutter pub get ``` -------------------------------- ### Installation rules Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/streaming_asr/linux/CMakeLists.txt Defines the installation process for creating a relocatable bundle, including copying the executable, data, libraries, and native assets. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files ``` -------------------------------- ### Install dependencies and run the speech enhancement example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/dart-api-examples/speech-enhancement-gtcrn/README.md This command installs the necessary Dart packages and then runs the speech enhancement script using GTCRN models. ```bash dart pub get dart run ./bin/speech_enhancement_gtcrn.dart --model ./gtcrn_simple.onnx --input-wav ./inp_16k.wav --output-wav ./enhanced-16k.wav ``` -------------------------------- ### cmake-js Usage Examples Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/scripts/node-addon-api/CMakeLists.txt Examples of how to install and use cmake-js for building the sherpa-onnx project. ```bash # See also https://github.com/cmake-js/cmake-js # npm install cmake-js # ./node_modules/.bin/cmake-js --help # ./node_modules/.bin/cmake-js --version # ./node_modules/.bin/cmake-js compile --help # ./node_modules/.bin/cmake-js compile --log-level # ./node_modules/.bin/cmake-js compile --log-level verbose ``` -------------------------------- ### Installation paths Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/linux/CMakeLists.txt Defines the installation paths for data and libraries within the bundle. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Package Configuration File Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/CMakeLists.txt Installs the generated sherpa-onnx.pc file to the root of the installation directory. ```cmake install( FILES ${PROJECT_BINARY_DIR}/sherpa-onnx.pc DESTINATION . ) ``` -------------------------------- ### Compile Sherpa-onnx and MFC Examples Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/mfc-examples/README.md This bash script outlines the steps to compile sherpa-onnx and the MFC examples using CMake and MSBuild. Ensure Visual Studio 2022 is installed. The script also shows how to run the compiled executables. ```bash mkdir -p $HOME/open-source cd $HOME/open-source git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./install .. cmake --build . --config Release --target install cd ../mfc-examples msbuild ./mfc-examples.sln /property:Configuration=Release /property:Platform=x64 # now run the program ./x64/Release/StreamingSpeechRecognition.exe ./x64/Release/NonStreamingSpeechRecognition.exe ``` -------------------------------- ### Installation bundle directory Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/linux/CMakeLists.txt Sets the directory for the build bundle and ensures it's the default install prefix. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Run Version Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/rust-api-examples/README.md Execute the version example script. This script automatically downloads necessary model files if they are not present. ```bash ./run-version.sh ``` -------------------------------- ### Kitten-nano-en-v0_1 Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Demonstrates how to use kitten-nano-en-v0_1-fp16 for text-to-speech. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/kitten-nano-en-v0_1-fp16.tar.bz2 tar xf kitten-nano-en-v0_1-fp16.tar.bz2 rm kitten-nano-en-v0_1-fp16.tar.bz2 node ./test-offline-tts-kitten-en.js ``` -------------------------------- ### Kokoro-en-v0_19 Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Shows how to use kokoro-en-v0_19 for text-to-speech. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/kokoro-en-v0_19.tar.bz2 tar xf kokoro-en-v0_19.tar.bz2 rm kokoro-en-v0_19.tar.bz2 node ./test-offline-tts-kokoro-en.js ``` -------------------------------- ### PocketTTS Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Shows how to use PocketTTS for Zero-shot TTS. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-pocket-tts-int8-2026-01-26.tar.bz2 tar xf sherpa-onnx-pocket-tts-int8-2026-01-26.tar.bz2 rm sherpa-onnx-pocket-tts-int8-2026-01-26.tar.bz2 node ./test-offline-tts-pocket-en.js ``` -------------------------------- ### Install bundled libraries Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/linux/CMakeLists.txt Installs any bundled libraries provided by plugins to the library directory. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Installation Targets Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/c-api/CMakeLists.txt Installs the built libraries and header files. ```cmake install( TARGETS sherpa-onnx-c-api sherpa-onnx-cxx-api DESTINATION lib ) install( FILES c-api.h cxx-api.h DESTINATION include/sherpa-onnx/c-api ) ``` -------------------------------- ### Install WebSocket Binaries Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/csrc/CMakeLists.txt Installs the built `sherpa-onnx-online-websocket-server`, `sherpa-onnx-online-websocket-client`, and `sherpa-onnx-offline-websocket-server` executables to the `bin` directory. ```cmake install( TARGETS sherpa-onnx-online-websocket-server sherpa-onnx-online-websocket-client sherpa-onnx-offline-websocket-server DESTINATION bin ) ``` -------------------------------- ### Create a new Dart example project Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/dart-api-examples/README.md Steps to create a new Dart project for a sherpa-onnx example, including adding the dependency and running the application. ```bash dart create vad cd vad # Edit pubspec.yaml and add sherpa_onnx to dependencies dart pub get dart run ``` -------------------------------- ### Install Sherpa-ONNX Binaries Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/csrc/CMakeLists.txt Installs the main executables and the version executable to the 'bin' directory. This installation is conditional on SHERPA_ONNX_ENABLE_BINARY being set. ```cmake if(SHERPA_ONNX_ENABLE_BINARY) install( TARGETS ${main_exes} sherpa-onnx-version DESTINATION bin ) endif() ``` -------------------------------- ### Audio tagging Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/java-api-examples/README.md Examples for audio tagging from a file. ```bash ./run-audio-tagging-zipformer-from-file.sh ./run-audio-tagging-ced-from-file.sh ``` -------------------------------- ### Run Version Example with Cargo Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/rust-api-examples/README.md Run the version example directly using Cargo, which is the standard Rust build tool. ```bash cargo run --example version ``` -------------------------------- ### Kokoro-multi-lang-v1_0 Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Demonstrates how to use kokoro-multi-lang-v1_0 for text-to-speech in Chinese and English. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/kokoro-multi-lang-v1_0.tar.bz2 tar xf kokoro-multi-lang-v1_0.tar.bz2 rm kokoro-multi-lang-v1_0.tar.bz2 node ./test-offline-tts-kokoro-zh-en.js ``` -------------------------------- ### Run Script Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/ffmpeg-examples/README.md This script demonstrates how to run the sherpa-onnx FFmpeg examples. ```shell ./run.sh ``` -------------------------------- ### Install Executables Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/csrc/CMakeLists.txt Installs the specified executable targets to the 'bin' directory. This command is typically used to make the built executables available in the final installation. ```cmake install( TARGETS ${exes} DESTINATION bin ) ``` -------------------------------- ### Install Dependencies Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-addon-examples/README.md Installs project dependencies using npm or pnpm. ```bash npm install # or pnpm install ``` -------------------------------- ### Fix for Linux Build Errors Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/README.md Command to install necessary development libraries for gstreamer on Linux. ```bash sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev ``` -------------------------------- ### Keyword spotter Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/java-api-examples/README.md Example for keyword spotting from a file. ```bash ./run-kws-from-file.sh ``` -------------------------------- ### Matcha-icefall-zh-baker Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Shows how to use matcha-icefall-zh-baker for text-to-speech in Chinese. ```bash wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/matcha-icefall-zh-baker.tar.bz2 tar xvf matcha-icefall-zh-baker.tar.bz2 rm matcha-icefall-zh-baker.tar.bz2 wget https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/vocos-22khz-univ.onnx node ./test-offline-tts-matcha-zh.js ``` -------------------------------- ### SupertonicTTS 3 Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Demonstrates how to use SupertonicTTS 3 for text-to-speech, supporting 31 languages. This example specifically shows English, Japanese, and German. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-supertonic-3-tts-int8-2026-05-11.tar.bz2 tar xf sherpa-onnx-supertonic-3-tts-int8-2026-05-11.tar.bz2 rm sherpa-onnx-supertonic-3-tts-int8-2026-05-11.tar.bz2 node ./test-offline-tts-supertonic.js ``` -------------------------------- ### C++ API Examples Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/c-api/mainpage.md List of example C++ files for various features. ```cpp #include "sherpa-onnx/cxx-api/sherpa-onnx.h" int main(int argc, char *argv[]) { // ... implementation details ... return 0; } ``` -------------------------------- ### Installation - Runtime destination Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/streaming_asr/windows/CMakeLists.txt Installs the main executable to the runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Punctuation Examples Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Commands to download models and run offline and online punctuation tests. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2 tar xvf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2 rm sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2 curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-online-punct-en-2024-08-06.tar.bz2 tar xvf sherpa-onnx-online-punct-en-2024-08-06.tar.bz2 rm sherpa-onnx-online-punct-en-2024-08-06.tar.bz2 node ./test-offline-punctuation.js node ./test-online-punctuation.js ``` -------------------------------- ### Run Version Example with Shared Libraries Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/rust-api-examples/README.md Execute the version example using Cargo, explicitly enabling shared libraries instead of the default static linking. This requires disabling default features and enabling the 'shared' feature. ```bash cargo run --no-default-features --features shared --example version ``` -------------------------------- ### Install AOT Library Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/linux/CMakeLists.txt Installs the AOT library on non-Debug builds. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Manage local NuGet packages Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/dotnet-examples/README.md These commands list and clear local NuGet packages. ```bash dotnet nuget locals all --list dotnet nuget locals all --clear ``` -------------------------------- ### AOT Library Installation Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/streaming_asr/linux/CMakeLists.txt Installs the AOT library on non-Debug builds. ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Download and Setup Model Files Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/android/SherpaOnnxJavaDemo/README.md Commands to download, extract, and organize the necessary model files for the demo. ```bash # Assume we are inside # /Users/fangjun/open-source/sherpa-onnx/android/SherpaOnnxJavaDemo cd app/src/main/assets/ wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2 tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2 rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2 mv sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.int8.onnx ./ mv sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx ./ mv sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.int8.onnx ./ mv sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt ./ rm -rf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/* mv encoder-epoch-99-avg-1.int8.onnx sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/ mv decoder-epoch-99-avg-1.onnx sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/ mv joiner-epoch-99-avg-1.int8.onnx sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/ mv tokens.txt sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/ ``` -------------------------------- ### Install native assets Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/linux/CMakeLists.txt Installs native assets provided by build.dart to the library directory. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Running the Streaming Speech Enhancement Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/dart-api-examples/streaming-speech-enhancement-dpdfnet/README.md This command shows how to get the Dart dependencies and run the streaming speech enhancement example using a DPDFNet model. ```bash dart pub get dart run ./bin/streaming_speech_enhancement_dpdfnet.dart --model ./dpdfnet_baseline.onnx --input-wav ./inp_16k.wav --output-wav ./enhanced-online-dpdfnet.wav ``` -------------------------------- ### Clean build bundle directory Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/linux/CMakeLists.txt Removes the build bundle directory before installation to ensure a clean state. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/asr-microphone-example/CMakeLists.txt This snippet shows how to configure the build for a C-API example using ALSA, including linking necessary libraries and handling environment variables for ALSA library paths. ```cmake add_executable(c-api-alsa c-api-alsa.cc alsa.cc) target_link_libraries(c-api-alsa sherpa-onnx-c-api cargs) if(DEFINED ENV{SHERPA_ONNX_ALSA_LIB_DIR}) target_link_libraries(c-api-alsa -L$ENV{SHERPA_ONNX_ALSA_LIB_DIR} -lasound) else() target_link_libraries(c-api-alsa asound) endif() ``` -------------------------------- ### Build Required Libraries on macOS Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter/notes2.md Commands to clone the sherpa-onnx repository, create a build directory, configure CMake, and install the libraries. ```bash git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" .. make install cd ../sherpa-onnx/flutter/ cp -v ../../build/install/lib/lib* ./macos/ ``` -------------------------------- ### Run Keyword Spotting with Microphone Input Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-addon-examples/README.md This snippet demonstrates how to set up and run keyword spotting using live audio input from a microphone. It requires installing the 'node-cpal' package. ```bash npm install node-cpal node ./test_keyword_spotter_transducer_microphone.js ``` -------------------------------- ### Build Executable: qwen3-asr-c-api Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/CMakeLists.txt Defines the qwen3-asr-c-api executable and links it with the sherpa-onnx-c-api library. ```cmake add_executable(qwen3-asr-c-api qwen3-asr-c-api.c) target_link_libraries(qwen3-asr-c-api sherpa-onnx-c-api) ``` -------------------------------- ### Running the Flutter App in Release Mode Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/README.md Command to run the Flutter application in release mode on a specific iOS device, useful if the app doesn't start after disconnecting from the computer. ```bash flutter run --release -d 00008030-001064212E85802E ``` -------------------------------- ### Build for Windows Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/tts/README.md Command to build for Windows. ```bash flutter build windows ``` -------------------------------- ### Installing the Sherpa-ONNX Python Module Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/python/csrc/CMakeLists.txt Installs the compiled Sherpa-ONNX Python module target to the 'lib' directory of the installation prefix. This makes the module available for use by Python applications after installation. ```cmake install(TARGETS _sherpa_onnx DESTINATION lib) ``` -------------------------------- ### Install Sherpa-ONNX JNI Library Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/jni/CMakeLists.txt Installs the built sherpa-onnx-jni shared library to the 'lib' directory during the installation phase. ```cmake install(TARGETS sherpa-onnx-jni DESTINATION lib) ``` -------------------------------- ### Qwen3 ASR C++ API Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/cxx-api-examples/CMakeLists.txt Defines an executable for the Qwen3 ASR C++ API example and links it against the Sherpa-onnx C++ API library. ```cmake add_executable(qwen3-asr-cxx-api ./qwen3-asr-cxx-api.cc) target_link_libraries(qwen3-asr-cxx-api sherpa-onnx-cxx-api) ``` -------------------------------- ### Run the streaming speech enhancement example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/dart-api-examples/streaming-speech-enhancement-gtcrn/README.md This command downloads GTCRN models and test wave files, then runs the Dart example. ```bash dart pub get dart run ./bin/streaming_speech_enhancement_gtcrn.dart --model ./gtcrn_simple.onnx --input-wav ./inp_16k.wav --output-wav ./enhanced-online-gtcrn.wav ``` -------------------------------- ### Text-to-Speech with MatchaTTS (Chinese, Async) Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-addon-examples/README.md Download and run a Chinese text-to-speech example using MatchaTTS models with an asynchronous API. Ensure you have the necessary model files and the Node.js script. ```bash wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/matcha-icefall-zh-baker.tar.bz2 tar xvf matcha-icefall-zh-baker.tar.bz2 rm matcha-icefall-zh-baker.tar.bz2 wget https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/vocos-22khz-univ.onnx node ./test_tts_non_streaming_matcha_icefall_zh_async.js ``` -------------------------------- ### VITS-piper-en_US-amy-low Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Shows how to use vits-piper-en_US-amy-low.tar.bz2 for text-to-speech. ```bash wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-amy-low.tar.bz2 tar xvf vits-piper-en_US-amy-low.tar.bz2 node ./test-offline-tts-vits-en.js ``` -------------------------------- ### Speaker identification Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/java-api-examples/README.md Example for speaker identification. ```bash ./run-speaker-identification.sh ``` -------------------------------- ### Install PortAudio on macOS Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/go-api-examples/real-time-speech-recognition-from-microphone/README.md Instructions for installing the portaudio library on macOS using Homebrew. ```bash brew install portaudio ``` -------------------------------- ### Test Offline Qwen3 ASR Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Demonstrates how to decode a file with a Qwen3 ASR model. ```bash wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-qwen3-asr-0.6B-int8-2026-03-25.tar.bz2 tar xvf sherpa-onnx-qwen3-asr-0.6B-int8-2026-03-25.tar.bz2 rm sherpa-onnx-qwen3-asr-0.6B-int8-2026-03-25.tar.bz2 node ./test-offline-qwen3-asr.js ``` -------------------------------- ### Build Executable: funasr-nano-c-api Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/CMakeLists.txt Defines the funasr-nano-c-api executable and links it with the sherpa-onnx-c-api library. ```cmake add_executable(funasr-nano-c-api funasr-nano-c-api.c) target_link_libraries(funasr-nano-c-api sherpa-onnx-c-api) ``` -------------------------------- ### Funasr Nano C++ API Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/cxx-api-examples/CMakeLists.txt Defines an executable for the Funasr Nano C++ API example and links it against the Sherpa-onnx C++ API library. ```cmake add_executable(funasr-nano-cxx-api ./funasr-nano-cxx-api.cc) target_link_libraries(funasr-nano-cxx-api sherpa-onnx-cxx-api) ``` -------------------------------- ### Install Dependencies and Export Model Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/scripts/nemo/nemotron-3.5-asr-streaming-0.6b/README.md Installs necessary Python packages and exports the NeMo model to ONNX format. Ensure NeMo is installed from git main as stable releases may lack required components. ```bash pip install Cython packaging pip install "nemo_toolkit[asr] @ git+https://github.com/NVIDIA/NeMo.git@main" pip install onnxruntime ipython sentencepiece pip install kaldi-native-fbank pip install soundfile librosa python3 ./export_onnx.py ``` -------------------------------- ### Verify ONNX Runtime Installation on macOS Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/java-api/readme.md Use 'otool' to verify that the native library is correctly linked. ```bash otool -L /Users/ping/lib/darwin_arm64/libsherpa-onnx-jni.dylib ``` -------------------------------- ### Download and Run Async Qwen3 ASR Model Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-addon-examples/README.md Download and extract the Qwen3 ASR model for asynchronous non-streaming recognition, then run the test. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-qwen3-asr-0.6B-int8-2026-03-25.tar.bz2 tar xvf sherpa-onnx-qwen3-asr-0.6B-int8-2026-03-25.tar.bz2 rm sherpa-onnx-qwen3-asr-0.6B-int8-2026-03-25.tar.bz2 node ./test_asr_non_streaming_qwen3_asr_async.js ``` -------------------------------- ### Install sherpa_onnx using ohpm Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/harmony-os/SherpaOnnxHar/sherpa_onnx/README.md Use this command to install the sherpa_onnx package in your HarmonyOS project. ```bash ohpm install sherpa_onnx ``` -------------------------------- ### Test Offline FunASR Nano Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Demonstrates how to decode a file with a FunASR Nano model. ```bash wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-funasr-nano-int8-2025-12-30.tar.bz2 tar xvf sherpa-onnx-funasr-nano-int8-2025-12-30.tar.bz2 rm sherpa-onnx-funasr-nano-int8-2025-12-30.tar.bz2 node ./test-offline-funasr-nano.js ``` -------------------------------- ### Sense Voice Simulate Streaming ALSA C++ API Example with ALSA Library Path Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/cxx-api-examples/CMakeLists.txt Configures linking for the Sense Voice ALSA example, including dynamic linking to the ALSA library if SHERPA_ONNX_ALSA_LIB_DIR is defined. ```cmake if(DEFINED ENV{SHERPA_ONNX_ALSA_LIB_DIR}) target_link_libraries(sense-voice-simulate-streaming-alsa-cxx-api -L$ENV{SHERPA_ONNX_ALSA_LIB_DIR} -lasound) target_link_libraries(fire-red-asr-ctc-simulate-streaming-alsa-cxx-api -L$ENV{SHERPA_ONNX_ALSA_LIB_DIR} -lasound) target_link_libraries(zipformer-ctc-simulate-streaming-alsa-cxx-api -L$ENV{SHERPA_ONNX_ALSA_LIB_DIR} -lasound) else() target_link_libraries(sense-voice-simulate-streaming-alsa-cxx-api asound) target_link_libraries(fire-red-asr-ctc-simulate-streaming-alsa-cxx-api asound) target_link_libraries(zipformer-ctc-simulate-streaming-alsa-cxx-api asound) endif() ``` -------------------------------- ### Matcha-icefall-en_US-ljspeech Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Demonstrates how to use matcha-icefall-en_US-ljspeech for text-to-speech in American English. ```bash wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/matcha-icefall-en_US-ljspeech.tar.bz2 tar xf matcha-icefall-en_US-ljspeech.tar.bz2 rm matcha-icefall-en_US-ljspeech.tar.bz2 wget https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/vocos-22khz-univ.onnx node ./test-offline-tts-matcha-en.js ``` -------------------------------- ### Build Executable: add-punctuation-online-c-api Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/CMakeLists.txt Defines the add-punctuation-online-c-api executable and links it with the sherpa-onnx-c-api library. ```cmake add_executable(add-punctuation-online-c-api add-punctuation-online-c-api.c) target_link_libraries(add-punctuation-online-c-api sherpa-onnx-c-api) ``` -------------------------------- ### Useful Flutter and Dart Commands Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter/notes2.md A collection of common Flutter and Dart commands for publishing, running, building, and analyzing projects across different platforms. ```bash flutter pub publish --dry-run flutter run -d macos flutter run -d linux flutter run -d windows flutter build macos flutter run --release -d macos # add platform to an existing project flutter create --platforms=windows,macos,linux . dart analyze FLUTTER_XCODE_ARCHS=arm64 FLUTTER_XCODE_ARCHS=x86_64 ``` -------------------------------- ### Installation - Flutter library Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/streaming_asr/windows/CMakeLists.txt Installs the Flutter library file. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### VAD with a microphone Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/java-api-examples/README.md Example for Voice Activity Detection (VAD) from a microphone. ```bash ./run-vad-from-mic.sh ``` -------------------------------- ### Non-Streaming text-to-speech Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/java-api-examples/README.md Examples for running non-streaming text-to-speech with various models. ```bash ./run-non-streaming-tts-coqui-de.sh ./run-non-streaming-tts-kitten-en.sh ./run-non-streaming-tts-kokoro-en.sh ./run-non-streaming-tts-kokoro-zh-en.sh ./run-non-streaming-tts-matcha-en.sh ./run-non-streaming-tts-matcha-zh.sh ./run-non-streaming-tts-piper-en-with-callback.sh ./run-non-streaming-tts-piper-en.sh ./run-non-streaming-tts-vits-zh.sh ./run-pocket-tts.sh ./run-zipvoice-tts.sh ``` -------------------------------- ### Text-to-Speech (ZipVoice) Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-examples/README.md Commands to download models and run the offline TTS test using ZipVoice for Chinese and English. ```bash curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2 tar xf sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2 rm sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2 curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/vocos_24khz.onnx node ./test-offline-tts-zipvoice-zh-en.js ``` -------------------------------- ### Create iOS Platform Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/flutter-examples/README.md Command to create the iOS platform for the Flutter project. ```bash cd streaming_asr flutter create --platforms ios ./ ``` -------------------------------- ### Streaming Speech recognition Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/java-api-examples/README.md Examples for running streaming speech recognition. ```bash ./run-streaming-asr-from-mic-transducer.sh ./run-streaming-decode-file-ctc-hlg.sh ./run-streaming-decode-file-ctc.sh ./run-streaming-decode-file-paraformer.sh ./run-streaming-decode-file-tone-ctc.sh ./run-streaming-decode-file-transducer.sh ``` -------------------------------- ### Build Executable: audio-tagging-c-api Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/CMakeLists.txt Defines the audio-tagging-c-api executable and links it with the sherpa-onnx-c-api library. ```cmake add_executable(audio-tagging-c-api audio-tagging-c-api.c) target_link_libraries(audio-tagging-c-api sherpa-onnx-c-api) ``` -------------------------------- ### Non-streaming speaker diarization Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/java-api-examples/README.md Example for running non-streaming speaker diarization. ```bash ./run-offline-speaker-diarization.sh ``` -------------------------------- ### Wenet CTC Simulate Streaming Microphone C++ API Example Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/cxx-api-examples/CMakeLists.txt Configures an executable for simulating streaming microphone input for the Wenet CTC ASR model. Requires PortAudio. ```cmake add_executable(wenet-ctc-simulate-streaming-microphone-cxx-api ./wenet-ctc-simulate-streaming-microphone-cxx-api.cc ${CMAKE_CURRENT_LIST_DIR}/../sherpa-onnx/csrc/microphone.cc ) target_link_libraries(wenet-ctc-simulate-streaming-microphone-cxx-api sherpa-onnx-cxx-api portaudio_static ) ``` -------------------------------- ### Install npm dependencies Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/tauri-examples/non-streaming-speech-recognition-from-microphone/README.md Installs the necessary npm dependencies for the Tauri application. ```bash npm install ``` -------------------------------- ### Install Doxygen and Graphviz Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/c-api/README.md Commands to install doxygen and graphviz on Ubuntu/Debian and macOS. ```bash sudo apt install doxygen graphviz # Ubuntu/Debian brew install doxygen graphviz # macOS ``` -------------------------------- ### Download and Run Async FunASR Nano Model Source: https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-addon-examples/README.md Download and extract the FunASR Nano model for asynchronous non-streaming recognition, then run the test. ```bash wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-funasr-nano-int8-2025-12-30.tar.bz2 tar xvf sherpa-onnx-funasr-nano-int8-2025-12-30.tar.bz2 rm sherpa-onnx-funasr-nano-int8-2025-12-30.tar.bz2 node ./test_asr_non_streaming_funasr_nano_async.js ```