Skip to content

Nemotron VoiceChat STT + TTS joint class - #15456

Merged
Edresson merged 57 commits into
NVIDIA-NeMo:mainfrom
Edresson:nemotron_voice_chat_release
Mar 6, 2026
Merged

Edresson merged 57 commits into
NVIDIA-NeMo:mainfrom
Edresson:nemotron_voice_chat_release

Conversation

@Edresson

@Edresson Edresson commented Mar 2, 2026 •

Copy link
Copy Markdown
Member

What does this PR do ?

Implement Nemotron VoiceChat STT + TTS joint class to allows inference and also update Duplex EARTTS.

Collection: SpeechLM2

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

@Edresson
Edresson marked this pull request as draft March 2, 2026 16:50

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@Edresson
Edresson force-pushed the nemotron_voice_chat_release branch 6 times, most recently from 272c3a0 to b415a32 Compare March 2, 2026 17:57
@Edresson
Edresson requested a review from kevinhu-nv March 2, 2026 18:05
@Edresson
Edresson force-pushed the nemotron_voice_chat_release branch 2 times, most recently from bfb6da8 to f632cb5 Compare March 2, 2026 19:29
@Edresson
Edresson force-pushed the nemotron_voice_chat_release branch 4 times, most recently from 0df6e7c to 8940647 Compare March 4, 2026 12:36
@Edresson
Edresson force-pushed the nemotron_voice_chat_release branch 2 times, most recently from 32a1266 to 6c11f0b Compare March 4, 2026 13:24
@Edresson
Edresson requested a review from pzelasko March 4, 2026 13:26
@Edresson
Edresson marked this pull request as ready for review March 4, 2026 13:26
Comment thread examples/speechlm2/duplex_eartts_inf.py Resolved
Comment thread examples/speechlm2/duplex_eartts_inf.py Resolved
Comment thread examples/speechlm2/duplex_eartts_inf.py Outdated
yield batch


def collate_and_tokenize_custom(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we re-use DuplexEarTTSDataset and simply run it on a batch? It looks to me like this data setup code could be sth like this instead:

from ... import DuplexEarTTSDataset

dataloader = torch.utils.data.DataLoader(
  DuplexEarTTSDataset(...), 
  sampler=lhotse.dataset.DynamicCutSampler(load_jsonl(path), max_cuts=batch_size),
  batch_size=None,
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we cant do that, because on this script we are creating the target audio as a dummy silence audio and making the speech channel x times longer than text channel len. We are also emulating the silence between turns and so on. DuplexEarTTSDataset is a dataset ready for training and does not support it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, how about DuplexEarTTSInferenceDataset (it can be defined locally in the script) so that you're able to hide all this overhead behind a dataloader's worker process (num_workers=1)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can handle this, but I’d prefer to do it in a separate PR. Since this inference recipe won’t be used directly in the release, I’d rather not spend extra time on it now. I can submit a follow-up PR later if that works for you.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Comment thread examples/speechlm2/duplex_eartts_inf.py Resolved
OmegaConf.resolve(cfg)
torch.distributed.init_process_group(backend="nccl")
torch.distributed.init_process_group(
backend="nccl", timeout=datetime.timedelta(seconds=int(cfg.trainer.strategy.get("timeout", 3600)))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it needed?

@Edresson Edresson Mar 4, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove it, It was for debug purpose, I had some crashes on cluster so I wanted to set timeout to a small value to crash earlier, but just set on nemo config was not working, the only way to make it work was passing the argument directly to init_process_group.

Should I remove it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK keep but please follow up later with a PR to make this change universal to speechlm2 scripts.

@Edresson
Edresson force-pushed the nemotron_voice_chat_release branch from 28b2a68 to 7c2f35b Compare March 4, 2026 18:06
Edresson added 6 commits March 4, 2026 10:10
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Edresson and others added 2 commits March 5, 2026 11:10
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Co-authored-by: Piotr Żelasko <petezor@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>

@pzelasko pzelasko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments, only the comment under from_pretrained may require a bit more involved work.

.. code-block:: python

import torch
import torchaudio

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove torchaudio here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All others models are using it. I think we need to do a full refresh on the docs removing it for all models.


# Resample to the source_sample_rate (usually 16kHz for STT perception)
if sample_rate != 16000:
audio_signal = torchaudio.functional.resample(audio_signal, sample_rate, 16000)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use nemo.collections.audio.parts.utils.transforms.resample instead (same API)


# Load user audio prompt
audio_path = "path/to/user_audio.wav"
audio_signal, sample_rate = torchaudio.load(audio_path)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soundfile.read or re-write to leverage`lhotse.Recording.from_file(audio_path).resample(16000).load_audio()

Comment thread docs/source/speechlm2/intro.rst Resolved

# Note: If an explicit audio reference is not passed into `offline_inference`,
# the model relies on the internal config parameters:
# 1. model.cfg.inference_speaker_name (Highest priority preset, e.g., 'Megan')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show how to select a specific speaker?

Edresson and others added 3 commits March 5, 2026 12:40
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson <Edresson@users.noreply.github.com>
pzelasko
pzelasko previously approved these changes Mar 5, 2026
Edresson added 2 commits March 5, 2026 12:45
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
@Edresson
Edresson requested review from pzelasko and zhehuaichen March 5, 2026 20:56
pzelasko
pzelasko previously approved these changes Mar 5, 2026
Signed-off-by: Edresson Casanova <edresson1@gmail.com>
@Edresson
Edresson merged commit e36b992 into NVIDIA-NeMo:main Mar 6, 2026
161 of 163 checks passed
nune-tadevosyan pushed a commit to nune-tadevosyan/NeMo that referenced this pull request Mar 13, 2026
* Add Nemotron VoiceChat inference Class

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Fix EARTTS loading

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Update EARTTS with system prompt

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Add smooth support for audio_prompt_latent

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Undo undesired changes

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Clean up inference script

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Undo undesired changes

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply black

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Rename eval recipe

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Remove unused functions

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Fix lint

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Fix Lint checks

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Fix import

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Remove unused imports

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Add Nemotron VoiceChat unit test

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Fix evaluation

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Add latent cache restore on checkpoint load

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Fix lint

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Add docs to NemotronVoiceChat class

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Overide from_pretrained to avoid OOM

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Remove Duplex EARTTS old eval script

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Update EARTTS inference docs

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Remove unused configs from NemotronVoiceChat test set

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Remove unused pretrained_s2s_model

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Update nemo/collections/speechlm2/models/nemotron_voicechat.py

Co-authored-by: Piotr Żelasko <petezor@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Remove workaround to support older models

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Update EARTTS inference script

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Update EARTTS dataloader

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Use cuts.truncate(keep_excessive_supervisions=False)

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Add Nemotron VoiceChat hugging face export

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Update export script

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Update evaluation script and config

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Update docs for Nemotron VoiceChat and Duplex EARTTS

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply black

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Fix Duplex EARTTS tests

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Fix lint

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply suggestion from @pzelasko

Co-authored-by: Piotr Żelasko <petezor@gmail.com>
Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Override _from_pretrained instead of from_pretrained

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Apply isort and black reformatting

Signed-off-by: Edresson <Edresson@users.noreply.github.com>

* Fix lint

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Add data format on docs

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

* Fix unit test

Signed-off-by: Edresson Casanova <edresson1@gmail.com>

---------

Signed-off-by: Edresson Casanova <edresson1@gmail.com>
Signed-off-by: Edresson <Edresson@users.noreply.github.com>
Co-authored-by: Edresson <Edresson@users.noreply.github.com>
Co-authored-by: Piotr Żelasko <petezor@gmail.com>

This branch was previously deployed

1 inactive deployment
test — 6071d479 Deployed Mar 6, 2026 by chtruong814 via cicd-wait-in-queue #19069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants