NVIDIA Riva
Text-to-speech service implementation using NVIDIA Riva
Overview
RivaTTSService
converts text to speech using NVIDIA’s Riva. It provides high-quality text-to-speech synthesis with configurable voice options, including multilingual voices.
Installation
To use RivaTTSService
, install the required dependencies:
You’ll also need to set up your NVIDIA API key as an environment variable: NVIDIA_API_KEY
Configuration
Constructor Parameters
Your NVIDIA API key
NVIDIA Riva server address
Voice identifier to use for synthesis
Output audio sample rate in Hz
A mapping of the NVIDIA function identifier for the TTS service with the model name.
Additional configuration parameters (language and quality)
InputParams
The language for TTS generation
Quality level for the generated audio
Input
The service accepts text input through its TTS pipeline.
Output Frames
TTSStartedFrame
Signals the start of audio generation.
TTSAudioRawFrame
Contains generated audio data:
Raw audio data chunk
Audio sample rate
Number of audio channels (1 for mono)
TTSStoppedFrame
Signals the completion of audio generation.
Methods
See the TTS base class methods for additional functionality.
Models
Model | Model Card Link |
---|---|
magpie-tts-multilingual | NVIDIA Model Card |
fastpitch-hifigan-tts | NVIDIA Model Card |
Language Support
Riva model magpie-tts-multilingual
(default) supports English, Spanish, and French:
Language Code | Description | Service Codes |
---|---|---|
Language.EN_US | English (US) | en-US |
Language.ES-US | Spanish (US) | es-US |
Language.FR-FR | French (France) | fr-FR |
Usage Examples
TTS Language and Voice Configuration
Model, function ID, and Voice configuration
Frame Flow
Metrics Support
The service supports metrics collection:
- Time to First Byte (TTFB)
- TTS usage metrics
- Processing duration
Audio Processing
- Processes audio through the Riva API
- Generates mono audio output
- Handles asynchronous audio streaming
- Configurable sampling rate
Notes
- Uses NVIDIA’s Riva AI Services platform
- Streams audio in chunks
- Requires valid NVIDIA API key
- Thread-safe processing with asyncio