Speech to Text with NVIDIA Riva ASR NIM

Speech to Text with NVIDIA Riva ASR NIM

NVIDIA Riva ASR NIM APIs provide seamless access to state-of-the-art Automatic Speech Recognition (ASR) models supporting multiple languages. Built on NVIDIA's software platform, these models leverage CUDA, TensorRT, and Triton to offer out-of-the-box GPU acceleration for high-performance speech transcription. This tutorial is based on:

Step 1 - NGC Authentication

Since Riva ASR NIM is a self-hosted NVIDIA Inference Micro-service (NIM) available under the NVIDIA AI Enterprise (NVAIE) License, an NGC API key is required.

Note: This requires a Personal Key, different from the Legacy Key used in Enroot configurations.

For Enroot setup, refer to: DGX On-Prem How-To

To generate your NGC API Personal Key, visit: Generate Personal Key. When creating your key, make sure to select “NGC Catalog” under the “Services Included” dropdown. Additional services can be included if the key will be reused for other purposes. For detailed information on API key types: https://docs.nvidia.com/ngc/gpu-cloud/ngc-user-guide/index.html#ngc-api-keys. The key will have a prefix nvapi-. Keep it securely, as it will be used in the next step.

Step 2 - Launching the NIM

The official NVIDIA documentation provides Docker-based instructions, but since DGX environments use Enroot as the container runtime, a SLURM script is needed to translate Docker parameters to the appropriate Pyxis/Enroot flags. Below is a template SLURM script to launch the Riva ASR NIM.

#!/bin/bash #SBATCH --job-name=parakeet #SBATCH --output=%j.out #SBATCH --time=8:00:00 #SBATCH --gpus=1 #SBATCH --container-image='docker://nvcr.io/nim/nvidia/parakeet-1-1b-ctc-en-us:1.3.0' #SBATCH --container-mounts=/network/rit/dgx/dgx_YOUR_LAB_NAME:/mnt/dgx_lab,/network/rit/lab/YOUR_LAB_NAME:/mnt/lab #SBATCH --container-writable # SLURM Parameters SLURM_NODE_NAME="$SLURMD_NODENAME" SLURM_JOB_ID="$SLURM_JOB_ID" # NIM API Ports NIM_HTTP_API_PORT=9000 NIM_GRPC_API_PORT=50051 # Construct URLs NIM_HTTP_API_URL="http://${SLURM_NODE_NAME}.its.albany.edu:${NIM_HTTP_API_PORT}" NIM_GRPC_API_URL="${SLURM_NODE_NAME}.its.albany.edu:${NIM_GRPC_API_PORT}" # Prepare Demo Folder DEMO_DIR="/mnt/dgx_lab/parakeet_demo" mkdir -p ${DEMO_DIR}/python-clients # Clone Riva Python client repository git clone https://github.com/nvidia-riva/python-clients.git ${DEMO_DIR}/python-clients # Copy example audio file from container cp /opt/riva/wav/en-US_sample.wav ${DEMO_DIR}/ # Display URLs and job info echo -e "\n================================================================================\n" echo -e "SLURM Job ID ${SLURM_JOB_ID} running on ${SLURM_NODE_NAME}\n" echo -e "HTTP URL: ${NIM_HTTP_API_URL}\n" echo -e "GRPC URL: ${NIM_GRPC_API_URL}" echo -e "\n================================================================================\n" # Set NGC API Key (replace YOUR_API_KEY with your actual API key) export NGC_API_KEY="YOUR_API_KEY" # Model Profile export NIM_TAGS_SELECTOR="name=parakeet-1-1b-ctc-en-us,mode=all" # Start the NIM server sh /opt/nim/start_server.sh

You can copy the contents from this snippet and save it as parakeet.slurm or you can simply download it from here: .

  1. Connect to the DGX On-Prem cluster over SSH (ssh your_netid@dgx-head01.its.albany.edu). If off-campus, ensure VPN is connected before logging in.

  2. Download and edit the above SLURM script for your use:

    • Replace YOUR_LAB_NAME with your lab's actual name.

    • Replace YOUR_API_KEY with the NGC API key (including nvapi- prefix).

  3. Submit the job to SLURM (sbatch parakeet.slurm). SLURM will assign and queue your job according to resource availability.

  4. Monitor job status (squeue -u YOUR_NETID).

  5. Watch job progress by checking the output file (tail -f YOUR_JOB_ID.out). Look for an entry similar to the following, as you will use the URLs on the next step.

================================================================================ SLURM Job ID 22941 running on dgx04 HTTP URL: http://dgx04.its.albany.edu:9000 GRPC URL: dgx04.its.albany.edu:50051 ================================================================================

Step 3 - Running Inference

This NIM runs the Parakeet 1.1b ASR model, which transcribes spoken English into lowercase text. Within the demo directory (e.g., /mnt/dgx_lab/parakeet_demo), the python-clients folder contains Python scripts to ease interaction with the service. On this demo, we will be using the following sample file.

Using The gRPC API

  1. On your local machine, navigate or copy the python-clients directory and install required Python dependencies (pip install -U nvidia-riva-client)

  2. Test connectivity and list available models (replace dgx04.its.albany.edu:50051 with your GRPC URL):

python3 ./scripts/asr/transcribe_file.py \ --server dgx04.its.albany.edu:50051 \ --list-models

Expected output example:

Available ASR models {'en-US': [{'model': ['parakeet-1.1b-en-US-asr-streaming']}]}
  1. Run a transcription example on the included sample audio:

python3 ./scripts/asr/transcribe_file.py \ --server dgx04.its.albany.edu:50051 \ --language-code en-US --automatic-punctuation \ --input-file en-US_sample.wav

Expected transcription output:

What is natural language processing?

Using The HTTP API

  1. On your local machine, navigate or copy the en-US_sample.wav file from the python-clients directory

  2. Run a transcription example (replace http://dgx04.its.albany.edu:9000 with your HTTP URL) on the included sample audio (make sure you’re in the same directory of the .wav file):

curl http://dgx04.its.albany.edu:9000/v1/audio/transcriptions -F language="en-US" -F file="@en-US_sample.wav”

Expected transcription output:

{"text":"What is natural language processing?"}

Explore the official documentation for more details and parameters: https://docs.nvidia.com/nim/riva/asr/latest/getting-started.html#running-inference. This tutorial provides a solid foundation to get started with NVIDIA Riva ASR using NIM on DGX systems. Feel free to experiment with client parameters and models to tailor the ASR experience to your needs.