Text to Speech with NVIDIA Riva TTS NIM

Text to Speech with NVIDIA Riva TTS NIM

Riva TTS NIM APIs provide easy access to state-of-the-art text to speech (TTS) models, capable of synthesizing English speech from text with exceptional accuracy. Riva TTS NIM models are built on the NVIDIA software platform, incorporating CUDA, TensorRT, and Triton to offer out-of-the-box GPU acceleration. This tutorial is based on:

Step 1 - NGC Authentication

Since Riva TTS 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 TTS NIM.

#!/bin/bash #SBATCH --job-name=fastpitch #SBATCH --output=%j.out #SBATCH --time=8:00:00 #SBATCH --gpus=1 #SBATCH --container-image='docker://nvcr.io/nim/nvidia/riva-tts: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 Params SLURM_NODE_NAME="$SLURMD_NODENAME" SLURM_JOB_ID="$SLURM_JOB_ID" # NIM Params NIM_HTTP_API_PORT=9000 NIM_GRPC_API_PORT=50051 # Build 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}" # Setup Demo Folder DEMO_DIR="/mnt/dgx_lab/fastpitch_demo" mkdir -p ${DEMO_DIR}/python-clients # Download Riva sample client git clone https://github.com/nvidia-riva/python-clients.git ${DEMO_DIR}/python-clients # Print URLs echo -e "\n================================================================================\n" echo -e "SLURM Job ID ${SLURM_JOB_ID} is 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" # NGC API Key export NGC_API_KEY="YOUR_API_KEY" # Model Profile export NIM_TAGS_SELECTOR=name="fastpitch-hifigan-en-us" # Container Entrypoint sh /opt/nim/start_server.sh

You can copy the contents from this snippet and save it as fastpitch 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 fastpitch.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 23473 is 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 Fastpitch HifiGAN en-US model, which supports text to speech in English (en-US) language. Within the demo directory (e.g., /mnt/dgx_lab/fastpitch_demo), the python-clients folder contains Python scripts to ease interaction with the service.

  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 and voices (replace dgx04.its.albany.edu:50051 with your GRPC URL):

python3 ./scripts/tts/talk.py \ --server dgx04.its.albany.edu:50051 \ --list-voices

Expected output example:

{ "en-US": { "voices": [ "English-US.Female-1", "English-US.Male-1", "English-US.Female-Neutral", "English-US.Male-Neutral", "English-US.Female-Angry", "English-US.Male-Angry", "English-US.Female-Calm", "English-US.Male-Calm", "English-US.Female-Fearful", "English-US.Female-Happy", "English-US.Male-Happy", "English-US.Female-Sad" ] } }
  1. Run a speech synthesizing example:

python3 ./scripts/tts/talk.py \ --server dgx04.its.albany.edu:50051 \ --language-code en-US \ --text "The Research Technology folks at UAlbany are amazing! This tutorial will surely help me hit the ground running." \ --voice English-US.Female-1 \ --output output.wav

Synthesized speech will be saved in output.wav. You should expect to see something like the following.


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