Deploy and Run the TTS NIM Microservice#

Deploy a TTS model as a NIM container and run speech synthesis through gRPC, HTTP, or WebSocket.

For model details, GPU requirements, and supported voices, refer to the TTS support matrix.

Prerequisites#

Deploy the NIM Container#

Magpie TTS Multilingual and Magpie TTS Zeroshot ship as profiles of a single container image; Chatterbox TTS Multilingual has its own. Set CONTAINER_ID and NIM_TAGS_SELECTOR to the values for the model you want to deploy.

12 languages, streaming + offline, multi-voice with emotional styles.

For the container image, refer to the NGC catalog.

export CONTAINER_ID=magpie-tts-multilingual
export NIM_TAGS_SELECTOR=name=magpie-tts-multilingual

docker run -it --rm --name=$CONTAINER_ID \
  --runtime=nvidia \
  --gpus '"device=0"' \
  --shm-size=8GB \
  -e NGC_API_KEY \
  -e NIM_HTTP_API_PORT=9000 \
  -e NIM_GRPC_API_PORT=50051 \
  -p 9000:9000 \
  -p 50051:50051 \
  -e NIM_TAGS_SELECTOR \
  nvcr.io/nim/nvidia/$CONTAINER_ID:latest

The default model profile is batch_size=8. To select a different batch size, append it to NIM_TAGS_SELECTOR:

export NIM_TAGS_SELECTOR="name=magpie-tts-multilingual,batch_size=32"

Refer to the support matrix for available batch sizes and their GPU memory requirements.

12 languages, streaming + offline, built-in voices with zero-shot voice cloning from an audio prompt.

This model ships as a set of model profiles inside the Magpie TTS Multilingual container. For the container image, refer to the NGC catalog.

export CONTAINER_ID=magpie-tts-multilingual
export NIM_TAGS_SELECTOR=name=magpie-tts-zeroshot

docker run -it --rm --name=$CONTAINER_ID \
  --runtime=nvidia \
  --gpus '"device=0"' \
  --shm-size=8GB \
  -e NGC_API_KEY \
  -e NIM_HTTP_API_PORT=9000 \
  -e NIM_GRPC_API_PORT=50051 \
  -p 9000:9000 \
  -p 50051:50051 \
  -e NIM_TAGS_SELECTOR \
  nvcr.io/nim/nvidia/$CONTAINER_ID:latest

To select a different batch size, append batch_size to NIM_TAGS_SELECTOR:

export NIM_TAGS_SELECTOR="name=magpie-tts-zeroshot,batch_size=32"

Important

Always set name for this model. The container carries profiles for both models, and if you leave NIM_TAGS_SELECTOR unset the microservice loads Magpie TTS Multilingual. batch_size is optional: when you omit it, the microservice prefers the batch_size=8 prebuilt profile for the detected GPU.

Refer to the support matrix for available batch sizes and their GPU memory requirements.

Note

Access to Magpie TTS Zeroshot is restricted. Apply for access.

23 languages, streaming + offline.

export CONTAINER_ID=chatterbox-tts-multilingual
export NIM_TAGS_SELECTOR="name=chatterbox-tts-multilingual"

docker run -it --rm --name=$CONTAINER_ID \
  --runtime=nvidia \
  --gpus '"device=0"' \
  --shm-size=8GB \
  -e NGC_API_KEY \
  -e NIM_HTTP_API_PORT=9000 \
  -e NIM_GRPC_API_PORT=50051 \
  -p 9000:9000 \
  -p 50051:50051 \
  -e NIM_TAGS_SELECTOR \
  nvcr.io/nim/nvidia/$CONTAINER_ID:latest

On first startup, the container downloads the model from NGC, which can take up to 30 minutes depending on network speed. A pre-built TensorRT engine is downloaded when available for the target GPU. Otherwise, the container generates an optimized engine from the RMIR model on-the-fly, which adds additional startup time.

Tip

Mount a local cache directory to avoid repeated downloads. See Model Caching.

Verify Readiness#

Wait for the container to finish model setup, then check the health endpoint.

curl -X 'GET' 'http://localhost:9000/v1/health/ready'

Expected response:

{"status":"ready"}

Run Speech Synthesis#

List Available Voices#

Before synthesizing, discover which voices the deployed model serves.

python3 python-clients/scripts/tts/talk.py \
  --server 0.0.0.0:50051 \
  --list-voices
curl -sS http://localhost:9000/v1/audio/list_voices | jq

The output lists voice names grouped by language. Use these names in the --voice parameter. For voice naming details, refer to Voices and Emotional Styles.

Offline Synthesis#

Offline synthesis generates the complete audio and returns it in a single response. The output is saved to output.wav.

python3 python-clients/scripts/tts/talk.py --server 0.0.0.0:50051 \
  --language-code en-US \
  --text "Deploy and run speech synthesis with NVIDIA TTS NIM." \
  --voice Magpie-Multilingual.EN-US.Aria \
  --output output.wav
curl -sS http://localhost:9000/v1/audio/synthesize --fail-with-body \
  -F language=en-US \
  -F text="Deploy and run speech synthesis with NVIDIA TTS NIM." \
  -F voice=Magpie-Multilingual.EN-US.Aria \
  --output output.wav

Note

gRPC limits message size to 4 MB by default. If the synthesized audio exceeds this limit, use streaming synthesis instead.

Streaming Synthesis#

Streaming synthesis returns audio in chunks as they are generated, providing lower time-to-first-audio.

python3 python-clients/scripts/tts/talk.py --server 0.0.0.0:50051 \
  --language-code en-US \
  --text "Deploy and run speech synthesis with NVIDIA TTS NIM." \
  --voice Magpie-Multilingual.EN-US.Aria \
  --stream \
  --output output.wav

The streaming HTTP API returns raw LPCM audio without a WAV header. Use sox to convert the output.

curl -sS http://localhost:9000/v1/audio/synthesize_online --fail-with-body \
  -F language=en-US \
  -F text="Deploy and run speech synthesis with NVIDIA TTS NIM." \
  -F voice=Magpie-Multilingual.EN-US.Aria \
  -F sample_rate_hz=22050 \
  --output output.raw
sox -b 16 -e signed -c 1 -r 22050 output.raw output.wav

The WebSocket realtime API provides the lowest latency for interactive applications.

python3 python-clients/scripts/tts/realtime_tts_client.py \
  --server localhost:9000 \
  --language-code en-US \
  --text "Deploy and run speech synthesis with NVIDIA TTS NIM." \
  --voice Magpie-Multilingual.EN-US.Aria \
  --output output.wav

Handling Long Inputs#

The TTS NIM enforces a per-request limit of 2,000 characters on the normalized text. Requests that exceed it are rejected with Input text is larger than the maximum input length: <size> > 2000. The limit applies to both offline and streaming synthesis. Streaming returns audio in chunks, but the input text itself is still passed in a single request and is validated up front. The check runs after text normalization (numbers, abbreviations, and SSML tags are expanded), so heavily marked-up input can exceed the cap with fewer raw characters than expected.

Note

Chatterbox TTS Multilingual enforces a lower limit of 500 characters and reports it with a different message: Input text length (<size>) exceeds maximum allowed length (500). Please reduce the input text size. This limit is also applied after normalization.

For longer content, split the source text into sentences or paragraphs and send one request per chunk. The client below reads a file, splits on blank lines, and synthesizes each block sequentially:

cat > long_input.txt <<'EOF'
Deploy and run speech synthesis with NVIDIA TTS NIM.
Streaming synthesis returns audio in chunks for low-latency playback.

The same NIM can also be invoked offline.
Offline synthesis is simpler but caps out at the gRPC message size limit.
EOF

while IFS= read -r chunk; do
  [ -z "$chunk" ] && continue
  python3 python-clients/scripts/tts/talk.py --server 0.0.0.0:50051 \
    --language-code en-US \
    --text "$chunk" \
    --voice Magpie-Multilingual.EN-US.Aria \
    --stream \
    --output "chunk_$(date +%s%N).wav"
done < long_input.txt

Concatenate the per-chunk WAV files (for example with sox in_*.wav out.wav) to produce a single audio track. Keep individual chunks well below 2,000 characters, or below 500 for Chatterbox TTS Multilingual, to leave headroom for normalization expansion.

Request Limits#

Three separate limits apply to a synthesis request. They are measured in different units and produce different failures, so a rejected request is not always a text-length problem.

Limit

Applies to

Value

How it appears

Input text length

Input text, after normalization

2,000 characters; 500 for Chatterbox TTS Multilingual

Input text is larger than the maximum input length: <size> > 2000

Model token budget

Tokens derived from the text, and the audio tokens generated from them

Not exposed as a request parameter

Audio can end before the text does, returned without an error

Offline response size

The single response returned by offline synthesis

4 MB, the default gRPC message size

Received message larger than max (<size> vs. 4194304)

Characters and tokens are different units, so the character cap is not a token budget and cannot be converted into one.

Which limit a request meets first depends on the encoding. Measured on magpie-tts-zeroshot at 22050 Hz LINEAR_PCM, English prose produces roughly 0.05 seconds of audio per character: a 1,600-character request returns 79.5 seconds of audio in 3.5 MB, and near 1,900 characters the response exceeds 4 MB and the request fails. OGG_OPUS is compressed, so the same text returns well under 1 MB and the response-size limit stays out of reach. Size offline requests against the response-size limit, not only against the character cap. Streaming synthesis removes the response-size limit entirely, because the audio is returned in chunks rather than in one message.

Audio Encodings by Protocol#

The TTS NIM supports linear PCM and Ogg Opus output across all three protocols. The field that selects them and the spelling of the Opus value differ by protocol.

Protocol

Field or flag

Linear PCM

Opus

gRPC

encoding (AudioEncoding enum)

LINEAR_PCM

OGGOPUS

HTTP

encoding form field

LINEAR_PCM

OGG_OPUS

WebSocket

output_audio_params.audio_format

LINEAR_PCM

OGG_OPUS

Other AudioEncoding members are defined by riva_audio.proto but are not supported for TTS. HTTP rejects an unsupported value with 400 Bad Request and {"detail": "Bad Request, invalid encoding"}. The WebSocket API matches its two values exactly and fails session validation on anything else — including the gRPC spelling OGGOPUS, a lowercase ogg_opus, and a hyphenated OGG-OPUS — with Input should be 'LINEAR_PCM' or 'OGG_OPUS'.

Each encoding allows a different set of sample rates:

Encoding

Valid sample_rate_hz

Response media type (HTTP)

Linear PCM

8000, 16000, 22050, 44100, 48000

audio/wav

Ogg Opus

8000, 12000, 16000, 24000, 48000

audio/opus

Warning

The default sample_rate_hz is 22050, which is not a valid Opus rate. Requesting Opus without also setting sample_rate_hz therefore always fails with 400 Bad Request. Set 48000, or another Opus-valid rate, whenever you request Opus.

The audio prompt for zero-shot cloning is a separate setting. Over the WebSocket API, zero_shot_config.prompt_encoding is a free-form string that defaults to LINEAR_PCM; an unrecognized value is silently treated as LINEAR_PCM rather than rejected, so a mis-spelled value shows up as distorted cloned audio instead of an error. Send the prompt as raw 16-bit PCM, or as a WAV file.

Client Parameters Reference#

talk.py (gRPC)#

--text and --list-voices are mutually exclusive.

Parameter

Description

Default

--server

gRPC server address and port.

0.0.0.0:50051

--text

Text to synthesize.

–

--list-voices

List available voices, then exit.

–

--voice

Voice name to use. If omitted, the server selects the first available voice.

–

--language-code

Language code (for example, en-US).

en-US

--output / -o

Output WAV file path.

output.wav

--stream

Enable streaming synthesis.

false

--sample-rate-hz

Output audio sample rate.

44100

--encoding

Output encoding (LINEAR_PCM or OGGOPUS).

LINEAR_PCM

--custom-dictionary

Path to a custom pronunciation dictionary file.

–

--custom-configuration

Comma-separated key:value pairs for model-specific request parameters.

–

--zero_shot_audio_prompt_file

Path to audio prompt for voice cloning (3–10 s).

–

--zero_shot_quality

Voice cloning quality (1–40).

20

--zero_shot_transcript

Transcript of the audio prompt. Accepted by the API, but no currently supported model uses it.

–

--play-audio

Play synthesized audio through speakers.

false

realtime_tts_client.py (WebSocket)#

Parameter

Description

Default

--server

WebSocket server address and port.

localhost:9000

--text

Direct text input to synthesize.

–

--input-file

Path to a text file for batch synthesis.

–

--list-voices

List available voices, then exit.

–

--voice

Voice name to use.

–

--language-code

Language code.

en-US

--output / -o

Output WAV file path.

–

--num-parallel-requests

Number of concurrent synthesis connections.

1

--zero-shot-audio-prompt-file

Path to audio prompt for voice cloning.

–

--zero-shot-prompt-quality

Voice cloning quality (1–40).

20

--zero-shot-audio-prompt-transcript

Transcript of the audio prompt. Accepted by the API, but no currently supported model uses it.

–

--custom-dictionary

Path to custom pronunciation dictionary.

–

--custom-configuration

Comma-separated key:value pairs for model-specific request parameters.

–

Helm Deployment#

For Kubernetes deployment, create a custom-values.yaml file:

image:
  repository: nvcr.io/nim/nvidia/magpie-tts-multilingual
  pullPolicy: IfNotPresent
  tag: latest
nim:
  ngcAPISecret: ngc-api
imagePullSecrets:
  - name: ngc-secret
envVars:
  NIM_TAGS_SELECTOR: name=magpie-tts-multilingual

Replace the repository and NIM_TAGS_SELECTOR values for other models:

Model

Repository

NIM_TAGS_SELECTOR

Magpie TTS Multilingual

nvcr.io/nim/nvidia/magpie-tts-multilingual

name=magpie-tts-multilingual

Magpie TTS Zeroshot

nvcr.io/nim/nvidia/magpie-tts-multilingual

name=magpie-tts-zeroshot

Chatterbox TTS Multilingual

nvcr.io/nim/nvidia/chatterbox-tts-multilingual

name=chatterbox-tts-multilingual

For complete Helm instructions, refer to Deploying with Helm.

Next Steps#