### Setup Dart API Example for SenseVoice Source: https://k2-fsa.github.io/sherpa/onnx/sense-voice/dart-api This sequence of commands navigates into the SenseVoice Dart API example directory within the cloned sherpa-onnx repository and fetches the necessary Dart package dependencies. The `dart pub get` command automatically downloads the `sherpa_onnx` package from pub.dev. ```bash cd sherpa-onnx cd dart-api-examples cd non-streaming-asr dart pub get ``` -------------------------------- ### Build Android Examples for Sherpa-ONNX (Android) Source: https://k2-fsa.github.io/sherpa/onnx/index Steps to build Android examples for sherpa-onnx, including pre-built APKs and a guide on how to compile the examples yourself. This involves building shared libraries, copying QNN libs, and downloading model files. ```java // Example: Building shared libraries // ... (code to be inserted) // Example: Changing code to use selected model // ... (code to be inserted) // Example: Building the demo // ... (code to be inserted) ``` -------------------------------- ### Install Ascend NPU Support (C++) Source: https://k2-fsa.github.io/sherpa/onnx/index Guide on installing the necessary components and building sherpa-onnx with support for Ascend NPU (CANN). This involves installing the CANN toolkit and compiling the sherpa-onnx library. ```c++ # Example: Building sherpa-onnx with Ascend NPU support # ... (code to be inserted) ``` -------------------------------- ### C API for SenseVoice: Build and Run Example Source: https://k2-fsa.github.io/sherpa/index Guides users through building and running the C API example for SenseVoice. This involves downloading Sherpa, the model, building the library, and compiling the C API example code. ```bash # 1. Download sherpa-onnx # git clone https://github.com/k2-fsa/sherpa-onnx.git # cd sherpa-onnx # 2. Download the model (e.g., sense-voice model) # wget # unzip # 3. Build sherpa-onnx with C API support # mkdir build && cd build # cmake .. -DBUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_PYTHON=OFF -DSHERPA_ONNX_ENABLE_WASM=OFF # make -j # 4. Build the C API example # cd ../examples/c-api # gcc sense-voice-c-api.c -o sense_voice_test $(pkg-config --cflags --libs sherpa-onnx) # 5. Run the example # ./sense_voice_test --model-dir /path/to/your/sense-voice-model --audio-file /path/to/your/audio.wav ``` -------------------------------- ### Install RKNN with Pip (Python) Source: https://k2-fsa.github.io/sherpa/onnx/index Instructions for installing sherpa-onnx for RKNN using pre-built wheels via pip. This is a straightforward method for getting started with RKNN acceleration. ```python pip install sherpa-onnx-rk ``` -------------------------------- ### Compile and Run Sherpa-onnx C API Example Source: https://k2-fsa.github.io/sherpa/onnx/tts/all/French/vits-piper-fr_FR-tjiho-model2 This section provides instructions on how to compile and run the C API example for Sherpa-onnx. It includes steps for cloning the repository, building the shared library, compiling the C code, and running the executable. Ensure you have the necessary build tools and dependencies installed. ```bash cd /tmp git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build-shared cd build-shared cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared .. make make install ``` You can find required header file and library files inside `/tmp/sherpa-onnx/shared`. Assume you have saved the above example file as `/tmp/test-piper.c`. Then you can compile it with the following command: ``` __ gcc -I /tmp/sherpa-onnx/shared/include -L /tmp/sherpa-onnx/shared/lib -lsherpa-onnx-c-api -lonnxruntime -o /tmp/test-piper /tmp/test-piper.c ``` Now you can run ``` __ cd /tmp # Assume you have downloaded the model and extracted it to /tmp ./test-piper ``` > You probably need to run > ``` > __ > # For Linux export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH # For macOS export DYLD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$DYLD_LIBRARY_PATH ``` > before you run `/tmp/test-piper`. ``` -------------------------------- ### Build and Run .NET Speech Recognition Example Source: https://k2-fsa.github.io/sherpa/onnx/csharp-api/index This snippet shows how to clone the Sherpa-ONNX repository, navigate to the .NET speech recognition example directory, build the project, and run the executable with specific model files and configurations. It requires the .NET SDK to be installed. ```bash git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx/dotnet-examples/speech-recognition-from-microphone dotnet build -c Release ./bin/Release/net6.0/speech-recognition-from-microphone --help ``` ```bash dotnet run -c Release \ --tokens ./icefall-asr-zipformer-streaming-wenetspeech-20230615/data/lang_char/tokens.txt \ --encoder ./icefall-asr-zipformer-streaming-wenetspeech-20230615/exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx \ --decoder ./icefall-asr-zipformer-streaming-wenetspeech-20230615/exp/decoder-epoch-12-avg-4-chunk-16-left-128.onnx \ --joiner ./icefall-asr-zipformer-streaming-wenetspeech-20230615/exp/joiner-epoch-12-avg-4-chunk-16-left-128.onnx \ ``` -------------------------------- ### Compile Sherpa-onnx C API Example Source: https://k2-fsa.github.io/sherpa/onnx/tts/all/Arabic/vits-piper-ar_JO-kareem-low This section provides the commands to clone the Sherpa-onnx repository, build the shared C API library using CMake, and install it. It specifies build options such as enabling the C API and setting the installation prefix. The output includes the necessary header and library files for compiling C applications. ```bash cd /tmp git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build-shared cd build-shared cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared .. make make install ``` -------------------------------- ### Start WebSocket Client (C++) Source: https://k2-fsa.github.io/sherpa/onnx/websocket/index Example command to run the C++ WebSocket client for sherpa-onnx. This client connects to the WebSocket server to send audio data for recognition and receive the results. ```shell ./sherpa-onnx/k2-fsa_github_io_sherpa/build/bin/sherpa-onnx-websocket-client --host localhost --port 5000 --filename ``` -------------------------------- ### Compile C Example with Static Libraries Source: https://k2-fsa.github.io/sherpa/ncnn/c-api/index This command compiles a C example file (`decode-file-c-api.c`) using the statically linked sherpa-ncnn libraries. It sets the `PKG_CONFIG_PATH` environment variable to include the directory where static libraries were installed and then uses `gcc` along with `pkg-config` to fetch the necessary compiler and linker flags. ```bash export PKG_CONFIG_PATH=/tmp/sherpa-ncnn/static:$PKG_CONFIG_PATH cd ./c-api-examples gcc -o decode-file-c-api $(pkg-config --cflags sherpa-ncnn) ./decode-file-c-api.c $(pkg-config --libs sherpa-ncnn) ``` -------------------------------- ### Compile C Example with Shared Libraries Source: https://k2-fsa.github.io/sherpa/ncnn/c-api/index This command compiles a C example file (`decode-file-c-api.c`) using the dynamically linked sherpa-ncnn libraries. It configures the `PKG_CONFIG_PATH` to point to the shared library installation directory and then uses `gcc` with `pkg-config` to obtain the required compiler and linker flags for dynamic linking. ```bash export PKG_CONFIG_PATH=/tmp/sherpa-ncnn/shared:$PKG_CONFIG_PATH cd ./c-api-examples gcc -o decode-file-c-api $(pkg-config --cflags sherpa-ncnn) ./decode-file-c-api.c $(pkg-config --libs sherpa-ncnn) ``` -------------------------------- ### Build and Run SenseVoice C API Example Source: https://k2-fsa.github.io/sherpa/onnx/sense-voice/c-api This snippet demonstrates the complete process of setting up and running the SenseVoice C API example. It includes cloning the sherpa-onnx repository, downloading models, building the library using CMake, compiling the C API example, and executing it. It requires Git, curl, CMake, make, GCC, and the ONNX Runtime. ```bash cd /tmp git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2 tar xvf sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2 rm sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2 ls -lh sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17 echo "---" ls -lh sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/test_wavs mkdir build cd build cmake \ -D CMAKE_BUILD_TYPE=Release \ -D BUILD_SHARED_LIBS=ON \ -D CMAKE_INSTALL_PREFIX=./install \ -D SHERPA_ONNX_ENABLE_BINARY=OFF \ .. make -j2 install ls -lh install/lib ls -lh install/include cd .. gcc -o sense-voice-c-api ./c-api-examples/sense-voice-c-api.c \ -I ./build/install/include \ -L ./build/install/lib/ \ -l sherpa-onnx-c-api \ -l onnxruntime ls -lh sense-voice-c-api export LD_LIBRARY_PATH=$PWD/build/install/lib:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=$PWD/build/install/lib:$DYLD_LIBRARY_PATH ./sense-voice-c-api ``` -------------------------------- ### Start Triton Offline Server with TorchScript Models Source: https://k2-fsa.github.io/sherpa/triton/server/index This command initiates the Triton server for offline ASR inference using TorchScript models. It assumes the TorchScript models and BPE file have been exported and placed in a specified directory, which can be mounted into the Docker container. This setup is for FP32 offline inference only. ```bash cd sherpa/triton/ bash scripts/start_offline_server_jit.sh ``` -------------------------------- ### Install Sherpa-onnx from Source (CPU) Source: https://k2-fsa.github.io/sherpa/onnx/python/install Builds and installs sherpa-onnx from its source code for CPU-only execution. This method involves cloning the repository and running the setup script. ```bash git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx python3 setup.py install ``` -------------------------------- ### Build and Run C API Example (Shell) Source: https://k2-fsa.github.io/sherpa/onnx/index Shell commands to build Sherpa-onnx with C API support and run the provided C API example. ```shell # 1. Download sherpa-onnx git clone https://github.com/k2-fsa/sherpa-onnx.git cd sherpa-onnx # 2. Download the model (example) # wget # 3. Build sherpa-onnx with C API enabled mkdir build cd build cmake .. -DBUILD_SHARED_LIBS=OFF -DSHERPA_ONNX_ENABLE_PYTHON=OFF -DSHERPA_ONNX_ENABLE_TESTS=OFF make -j # 5. Build the C API example (assuming sense-voice-c-api.c is in the root) cd .. gcc -I./build/include -L./build/lib -lsherpa-onnx -pthread ./your_c_api_example.c -o c_api_example # 6. Run it ./c_api_example ``` -------------------------------- ### Run C API Example Source: https://k2-fsa.github.io/sherpa/onnx/sense-voice/c-api Executes the compiled C API example program. This command assumes the library path has been correctly set in the previous step. ```shell ./sense-voice-c-api ``` -------------------------------- ### Troubleshoot CUDA Provider Loading Errors in Sherpa-ONNX Source: https://k2-fsa.github.io/sherpa/onnx/pretrained_models/whisper/large-v3 This section addresses common errors encountered when trying to use the CUDA execution provider with ONNX Runtime in Sherpa-ONNX. It guides users to install the correct CUDA toolkit version by referencing ONNX Runtime documentation and a provided installation guide. ```text If you get errors like below: what(): /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1426 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library libonnxruntime_providers_cuda.so with error: libcublasLt.so.11: cannot open shared object file: No such file or directory please follow https://www.google.com/url?q=https%3A%2F%2Fk2-fsa.github.io%2Fk2%2Finstallation%2Fcuda-cudnn.html to install CUDA toolkit. To determine which version of CUDA toolkit to install, please read https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html to figure it out. For instance, if onnxruntime v1.18.1 is used in sherpa-onnx, we have to install CUDA 11.8 according to https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html ``` -------------------------------- ### Compile and Run Sherpa-onnx C API Example Source: https://k2-fsa.github.io/sherpa/onnx/tts/all/English/vits-piper-en_US-bryce-medium These commands show how to compile and run the C API example. It involves cloning the Sherpa-onnx repository, building the shared library, compiling the C code with the necessary flags, and running the executable. Ensure the model files are in the expected directory. ```shell cd /tmp git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build-shared cd build-shared cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared .. make make install ``` You can find required header file and library files inside `/tmp/sherpa-onnx/shared`. Assume you have saved the above example file as `/tmp/test-piper.c`. Then you can compile it with the following command: ``` gcc -I /tmp/sherpa-onnx/shared/include -L /tmp/sherpa-onnx/shared/lib -lsherpa-onnx-c-api -lonnxruntime -o /tmp/test-piper /tmp/test-piper.c ``` Now you can run ``` cd /tmp # Assume you have downloaded the model and extracted it to /tmp ./test-piper ``` > You probably need to run > ``` > __ > # For Linux export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH # For macOS export DYLD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$DYLD_LIBRARY_PATH ``` > before you run `/tmp/test-piper`. ``` -------------------------------- ### Start Non-Streaming WebSocket Server (Transducer) Source: https://k2-fsa.github.io/sherpa/onnx/python/index Details how to start a non-streaming WebSocket server for speech recognition using a transducer model with sherpa-onnx. This server expects complete audio chunks. ```bash # Start the server (example command, actual command may vary based on model paths) sherpa-onnx-server --port 9090 --encoder-model --decoder-model --joiner-model --tokens ``` -------------------------------- ### Start Non-Streaming WebSocket Server (Whisper tiny.en) Source: https://k2-fsa.github.io/sherpa/onnx/python/index Details how to start a non-streaming WebSocket server for speech recognition using the Whisper tiny.en model with sherpa-onnx. This server is configured for the Whisper model. ```bash # Start the server (example command, actual command may vary based on model paths) sherpa-onnx-server --port 9090 --whisper-model --whisper-encoder ``` -------------------------------- ### Compile and Run C API Example for Sherpa-ONNX Source: https://k2-fsa.github.io/sherpa/onnx/tts/all/English/vits-piper-en_GB-semaine-medium These commands detail the process of compiling and running the C API example for Sherpa-ONNX. It involves cloning the repository, building the shared library, compiling the C code with appropriate flags, and setting environment variables for library paths. ```bash cd /tmp git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build-shared cd build-shared cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared .. make make install # Assume you have saved the above example file as /tmp/test-piper.c gcc -I /tmp/sherpa-onnx/shared/include -L /tmp/sherpa-onnx/shared/lib -lsherpa-onnx-c-api -lonnxruntime -o /tmp/test-piper /tmp/test-piper.c cd /tmp # Assume you have downloaded the model and extracted it to /tmp ./test-piper # For Linux export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH # For macOS export DYLD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$DYLD_LIBRARY_PATH ``` -------------------------------- ### Compile and Run Sherpa-ONNX C API Example Source: https://k2-fsa.github.io/sherpa/onnx/tts/all/Arabic/vits-piper-ar_JO-SA_miro-high Instructions for compiling and running the C API example. This involves cloning the Sherpa-ONNX repository, building the shared library with C API enabled, and then compiling the C example code using gcc. Environment variables for library paths may need to be set. ```shell cd /tmp git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build-shared cd build-shared cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared .. make make install # Compile the C example gcc -I /tmp/sherpa-onnx/shared/include -L /tmp/sherpa-onnx/shared/lib -lsherpa-onnx-c-api -lonnxruntime -o /tmp/test-piper /tmp/test-piper.c # Run the executable cd /tmp ./test-piper # Set library path (example for Linux) export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH ``` -------------------------------- ### Start Streaming WebSocket Server (Python API) Source: https://k2-fsa.github.io/sherpa/onnx/python/index Provides Python code to start a streaming WebSocket server using sherpa-onnx. This server can decode audio sent from clients, either from files or a microphone. ```python from sherpa_onnx.websocket import SherpaOnnxWebsocketServer # Initialize server with desired configurations server = SherpaOnnxWebsocketServer(port=9090) # Start the server server.start() print("Streaming WebSocket server started on port 9090") # To send a file for decoding: # server.send_file_for_decoding("audio.wav") # To send audio samples from a microphone for decoding: # server.send_audio_from_microphone_for_decoding() ``` -------------------------------- ### Build and Run Online Decode Files Example (C#) Source: https://k2-fsa.github.io/sherpa/onnx/csharp-api/index This snippet demonstrates how to clone the Sherpa-ONNX repository, build the .NET online-decode-files example, and execute it with specific parameters for decoding audio files using pre-trained streaming models. It requires .NET SDK and the Sherpa-ONNX repository. ```bash git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx/dotnet-examples/online-decode-files dotnet build -c Release ./bin/Release/net6.0/online-decode-files --help ``` ```bash dotnet run \ --tokens=./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt \ --encoder=./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx \ --decoder=./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx \ --joiner=./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx \ --num-threads=2 \ --decoding-method=modified_beam_search \ --debug=false \ --files ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs/0.wav \ ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs/1.wav ``` -------------------------------- ### Start Non-Streaming WebSocket Server (NeMo CTC) Source: https://k2-fsa.github.io/sherpa/onnx/python/index Provides instructions to start a non-streaming WebSocket server for speech recognition using a CTC model from NeMo with sherpa-onnx. This server handles audio input for CTC-based recognition. ```bash # Start the server (example command, actual command may vary based on model paths) sherpa-onnx-server --port 9090 --nemo-ctc-model --tokens ``` -------------------------------- ### Run Sherpa-ONNX C Example Source: https://k2-fsa.github.io/sherpa/onnx/tts/all/English/matcha-icefall-en_US-ljspeech This command executes the compiled Sherpa-ONNX C application. Before running, ensure that the necessary model files (acoustic model, vocoder, tokens) are downloaded and placed in the expected directory (e.g., `/tmp`). The `LD_LIBRARY_PATH` (Linux) or `DYLD_LIBRARY_PATH` (macOS) environment variable must be set to include the directory containing the Sherpa-ONNX shared libraries. ```bash cd /tmp # Assume you have downloaded the acoustic model as well as the vocoder model and put them to /tmp ./test-en ``` -------------------------------- ### Decode Wave Files with int8 Models using Sherpa-ONNX Source: https://k2-fsa.github.io/sherpa/onnx/pretrained_models/offline-transducer/conformer-transducer-models This example demonstrates how to use the `sherpa-onnx-offline` command-line tool to perform speech recognition on wave files using int8 quantized ONNX models. It requires specifying paths to the tokens, encoder, decoder, and joiner models, along with the audio files to process. The output includes the recognized text and performance metrics. Note the Windows executable path. ```bash cd /path/to/sherpa-onnx ./build/bin/sherpa-onnx-offline \ --tokens=./sherpa-onnx-conformer-en-2023-03-18/tokens.txt \ --encoder=./sherpa-onnx-conformer-en-2023-03-18/encoder-epoch-99-avg-1.int8.onnx \ --decoder=./sherpa-onnx-conformer-en-2023-03-18/decoder-epoch-99-avg-1.onnx \ --joiner=./sherpa-onnx-conformer-en-2023-03-18/joiner-epoch-99-avg-1.int8.onnx \ ./sherpa-onnx-conformer-en-2023-03-18/test_wavs/0.wav \ ./sherpa-onnx-conformer-en-2023-03-18/test_wavs/1.wav \ ./sherpa-onnx-conformer-en-2023-03-18/test_wavs/8k.wav # For Windows: # ./build/bin/Release/sherpa-onnx-offline.exe \ # --tokens=./sherpa-onnx-conformer-en-2023-03-18/tokens.txt \ # --encoder=./sherpa-onnx-conformer-en-2023-03-18/encoder-epoch-99-avg-1.int8.onnx \ # --decoder=./sherpa-onnx-conformer-en-2023-03-18/decoder-epoch-99-avg-1.onnx \ # --joiner=./sherpa-onnx-conformer-en-2023-03-18/joiner-epoch-99-avg-1.int8.onnx \ # ./sherpa-onnx-conformer-en-2023-03-18/test_wavs/0.wav \ # ./sherpa-onnx-conformer-en-2023-03-18/test_wavs/1.wav \ # ./sherpa-onnx-conformer-en-2023-03-18/test_wavs/8k.wav ``` -------------------------------- ### Start Triton Streaming Server with ONNX Models Source: https://k2-fsa.github.io/sherpa/triton/server/index This command starts the Triton server specifically configured for streaming ASR models exported to ONNX format. It assumes the ONNX models have been prepared in the preceding steps and are accessible within the sherpa/triton directory. This is typically run inside a Docker container. ```bash cd sherpa/triton/ bash scripts/start_streaming_server.sh ``` -------------------------------- ### Run Dart API Example (Shell) Source: https://k2-fsa.github.io/sherpa/onnx/index Shell commands to set up and run a Dart API example for Sherpa-onnx. ```shell # 1. Download the code git clone cd # 2. Download the sherpa-onnx package (add to pubspec.yaml) # flutter pub get # 3. Run it flutter run ``` -------------------------------- ### Install TensorRT using Docker Source: https://k2-fsa.github.io/sherpa/triton/trt/index Installs TensorRT by running a Docker container. This method is recommended for ease of setup and ensures compatibility. The container mounts the current directory to '/k2' and uses the host's network. Ensure your NVIDIA driver supports the specified CUDA version. ```bash docker run --gpus "device=0" -it --rm --net host -v $PWD/:/k2 nvcr.io/nvidia/tensorrt:22.12-py3 ``` -------------------------------- ### Dart API for SenseVoice: Run Example Source: https://k2-fsa.github.io/sherpa/index Provides instructions for running the Dart API example for SenseVoice. This involves downloading the code, obtaining the sherpa-onnx package, and executing the example. ```bash # 1. Download the Dart example code # git clone # cd dart_example # 2. Download the sherpa-onnx package (e.g., for Dart) # dart pub get # 3. Run the Dart example # dart run main.dart --model-dir /path/to/your/sense-voice-model --audio-file /path/to/your/audio.wav ``` -------------------------------- ### Sherpa ONNX Keyword Spotting Results Example Source: https://k2-fsa.github.io/sherpa/onnx/kws/pretrained_models/index This section shows example JSON output from the Sherpa ONNX keyword spotter for different audio files. Each entry indicates the detected keyword, its start time, and the corresponding tokens with their timestamps. This format is useful for programmatic analysis of the results. ```json {"start_time":0.00, "keyword": "LIGHT UP", "timestamps": [3.04, 3.08, 3.12, 3.20], "tokens":[" ", "L", "IGHT", " UP"]} ``` ```json {"start_time":0.00, "keyword": "LOVELY CHILD", "timestamps": [5.44, 5.56, 5.84, 6.00, 6.04], "tokens":[" LOVE", "LY", " CHI", "L", "D"]} ``` ```json {"start_time":0.00, "keyword": "FOREVER", "timestamps": [10.88, 11.04, 11.08], "tokens":[" FOR", "E", "VER"]} ``` -------------------------------- ### Build Sherpa-ONNX for Qualcomm NPU (C++) Source: https://k2-fsa.github.io/sherpa/onnx/index Instructions for building sherpa-onnx for Qualcomm NPU (QNN, HTP). This involves downloading the QNN SDK and compiling shared libraries and executable files. ```c++ # Example of building shared libraries # ... (code to be inserted) # Example of building executable files # ... (code to be inserted) ``` -------------------------------- ### Real-time Speech Recognition from Microphone (Python) Source: https://k2-fsa.github.io/sherpa/onnx/python/index Enables real-time speech recognition from a microphone using sherpa-onnx in Python. This example can be configured with or without endpoint detection. ```python from sherpa_onnx import SunriseRecognizer, SunriseRecognizerConfig config = SunriseRecognizerConfig() # Set model paths and other configurations here recognizer = SunriseRecognizer(config) # Start capturing audio from microphone and recognizing while True: audio_chunk = recognizer.get_audio_from_microphone() if audio_chunk: recognizer.accept_waveform(audio_chunk) result = recognizer.get_result() if result: print(result.text) ``` -------------------------------- ### Compile and Run C API Example for Sherpa-ONNX TTS Source: https://k2-fsa.github.io/sherpa/onnx/tts/all/French/vits-piper-fr_FR-siwis-medium These commands detail the process of compiling and running the C API example for Sherpa-ONNX TTS. It involves cloning the repository, building the shared library with the C API enabled, compiling the example C file, and then executing the compiled program. Ensure the model files are downloaded and extracted to the correct location. ```bash cd /tmp git clone https://github.com/k2-fsa/sherpa-onnx cd sherpa-onnx mkdir build-shared cd build-shared cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared .. make make install # Compile the example gcc -I /tmp/sherpa-onnx/shared/include -L /tmp/sherpa-onnx/shared/lib -lsherpa-onnx-c-api -lonnxruntime -o /tmp/test-piper /tmp/test-piper.c # Run the example cd /tmp # Assume you have downloaded the model and extracted it to /tmp ./test-piper # Set library path before running # For Linux export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH # For macOS export DYLD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$DYLD_LIBRARY_PATH ``` -------------------------------- ### Install Sherpa-NCNN from Source using setup.py Source: https://k2-fsa.github.io/sherpa/ncnn/python/index Installs the sherpa-ncnn Python package by cloning the repository and running the setup.py script. This method requires Python and may implicitly handle build dependencies. ```bash git clone https://github.com/k2-fsa/sherpa-ncnn cd sherpa-ncnn python3 setup.py install ``` -------------------------------- ### Start Non-streaming WebSocket Client (Python) Source: https://k2-fsa.github.io/sherpa/onnx/websocket/index Python scripts to run the non-streaming WebSocket client. These examples demonstrate decoding audio files sequentially or in parallel by connecting to the non-streaming server. ```shell python3 sherpa-onnx/k2-fsa_github_io_sherpa/examples/python/websocket/offline-websocket-client-decode-files-sequential.py --host localhost --port 5000 --files ``` ```shell python3 sherpa-onnx/k2-fsa_github_io_sherpa/examples/python/websocket/offline-websocket-client-decode-files-paralell.py --host localhost --port 5000 --files ``` -------------------------------- ### Run Sherpa-ONNX with QEMU (Initial Attempt) Source: https://k2-fsa.github.io/sherpa/onnx/install/riscv64-embedded-linux This command attempts to run the Sherpa-ONNX speech-to-text model using `qemu-riscv64`. It specifies the path to the Sherpa-ONNX executable and the model files (tokens, encoder, decoder, joiner), along with a test WAV file. This initial command may fail due to missing dynamic linker libraries. ```bash cd /path/to/sherpa-onnx export PATH=$HOME/qemu:$PATH qemu-riscv64 build-riscv64-linux-gnu/install/bin/sherpa-onnx \ --tokens=./sherpa-onnx-streaming-zipformer-en-20M-2023-02-17/tokens.txt \ --encoder=./sherpa-onnx-streaming-zipformer-en-20M-2023-02-17/encoder-epoch-99-avg-1.onnx \ --decoder=./sherpa-onnx-streaming-zipformer-en-20M-2023-02-17/decoder-epoch-99-avg-1.onnx \ --joiner=./sherpa-onnx-streaming-zipformer-en-20M-2023-02-17/joiner-epoch-99-avg-1.onnx \ ./sherpa-onnx-streaming-zipformer-en-20M-2023-02-17/test_wavs/0.wav ```