nemo_voice_agent.pipecat.services.nemo.tts
nemo_voice_agent.pipecat.services.nemo.tts
Module Contents
Classes
Functions
API
Bases: TTSService, ToolCallingMixin
Text-to-Speech service using Nemo TTS models.
This service works with any TTS model that exposes a generate(text) method that returns audio data. The TTS generation runs in a dedicated background thread to avoid blocking the main asyncio event loop, following the same pattern as NemoDiarService.
Parameters:
TTS model instance with a generate(text) method
Audio sample rate in Hz (defaults to 22050)
Additional arguments passed to TTSService
Convert various audio data formats to bytes.
Drop the special tokens from the text.
Get the response queue for a specific request.
Handle the thinking tokens for TTS. If the thinking tokens are not provided, return the text as it is. Otherwise: If both thinking tokens appear in the text, return the text after the end of thinking tokens. If the LLM is thinking, return None. If the LLM is done thinking, return the text after the end of thinking tokens. If the LLM starts thinking, return the text before the start of thinking tokens. If the LLM is not thinking, return the text as is.
Initialize the tool calling mixin by registering all available tools.
Handler for background processing task.
Stop background processing tasks.
Background processor that handles TTS generation calls.
If the TTS service can generate metrics.
Handle service cancellation.
Reset the TTS service.
Generate speech from text using the Nemo TTS model.
Setup the tool calling mixin by registering all available tools.
Handle service start.
Handle service stop.
Bases: BaseNemoTTSService
Text-to-Speech service using Kokoro-82M model.
Kokoro is an open-weight TTS model with 82 million parameters. More info: https://huggingface.co/hexgrad/Kokoro-82M
Parameters:
Language code for the model (default: ‘a’ for American English)
Voice to use (default: ‘af_heart’)
Device to run on (default: ‘cuda’)
Audio sample rate in Hz (default: 24000 for Kokoro)
Download all models for different languages (default: True)
Cache models on GPU for faster switching between languages (default: True)
Additional arguments passed to BaseNemoTTSService
Attach the Apache-2.0 OOV fallback (see _g2p_fallback.py) to an English pipeline.
Without this, misaki’s dictionary-based G2P silently drops any word outside its lexicon (phonemes=None) since the GPL-licensed espeak fallback is excluded.
Download all models for Kokoro TTS service.
Generate audio using the Kokoro pipeline.
Parameters:
Text to convert to speech
Initialize the Kokoro pipeline.
Reset the voice and speed to the original ones.
Setup the tool calling mixin by registering all available tools.
Reset the speaking speed to the original speed.
Inform user of the result of this tool call. After calling this tool, continue the previous response if it was unfinished and was interrupted by the user, otherwise start a new response and ask if the user needs help on anything else. Avoid repeating previous responses.
Reset the accent and voice to the original ones.
Inform user of the result of this tool call. After calling this tool, continue the previous response if it was unfinished and was interrupted by the user, otherwise start a new response and ask if the user needs help on anything else. Avoid repeating previous responses.
Set a specific speaking speed of the assistant’s voice. This tool should be called only when the user specifies the speed explicitly, such as “speak twice as fast” or “speak half as slow” or “speak 1.5 times as fast”.
Inform user of the result of this tool call. After calling this tool, continue the previous response if it was unfinished and was interrupted by the user, otherwise start a new response and ask if the user needs help on anything else. Avoid repeating previous responses.
Parameters:
positive float, the relative change of the speaking speed to the original speed. E.g., 1.0 for original speed, 1.25 for 25% faster than original speed, 0.8 for 20% slower than original speed.
Set the accent and gender of the assistant’s voice. This tool should be called only when the user specifies the accent and/or gender explicitly.
Inform user of the result of this tool call. After calling this tool, continue the previous response if it was unfinished and was interrupted by the user, otherwise start a new response and ask if the user needs help on anything else. Avoid repeating previous responses.
Parameters:
Accent for the TTS model. Must be one of ‘American English’, ‘British English’ or ‘current’ for keeping the current accent.
gender of the assistant’s voice. Must be one of ‘male’, ‘female’, or ‘current’ for keeping the current gender.
Speak faster by increasing the speaking speed 15% faster each time this function is called.
Inform user of the result of this tool call. After calling this tool, continue the previous response if it was unfinished and was interrupted by the user, otherwise start a new response and ask if the user needs help on anything else. Avoid repeating previous responses.
Speak slower by decreasing the speaking speed 15% slower each time this function is called.
Inform user of the result of this tool call. After calling this tool, continue the previous response if it was unfinished and was interrupted by the user, otherwise start a new response and ask if the user needs help on anything else. Avoid repeating previous responses.
Bases: BaseNemoTTSService
Text-to-Speech service using Magpie TTS model.
Magpie is a multilingual TTS model with 357 million parameters. More info: https://huggingface.co/nvidia/magpie_tts_multilingual_357m
Parameters:
Model name or path to the Magpie TTS model.
Language code for the model (default: ‘en’ for English)
Speaker to use for the model (default: ‘Sofia’)
Whether to apply text normalization (default: False)
Device to run on (default: ‘cuda’)
Additional arguments passed to BaseNemoTTSService
No tools for now for Magpie TTS service.
Bases: BaseNemoTTSService
Text-to-Speech service using NeMo FastPitch-Hifigan model.
More info: https://huggingface.co/nvidia/tts_en_fastpitch
Parameters:
FastPitch model name
Hifigan model name
Device to run on (default: ‘cuda’)
Additional arguments passed to BaseNemoTTSService
Build the sentence aggregator for TTS, or None if disabled by config.
Since pipecat 1.0, TTSService no longer accepts a text_aggregator
argument — text aggregation belongs to an LLMTextProcessor placed
upstream of the TTS service. Note that pipecat silently ignores unknown
constructor kwargs, so passing it to the service would drop our
segmentation with no error at all.
Get the TTS service from the configuration.
Returns: The TTS service.
Parameters:
The DictConfig object containing the TTS configuration.
The audio logger to use for audio logging.