Skip to content

Add MOSS-TTSD with XY-Tokenizer#40286

Open
gaoyang07 wants to merge 15 commits into
huggingface:mainfrom
gaoyang07:moss-ttsd
Open

Add MOSS-TTSD with XY-Tokenizer#40286
gaoyang07 wants to merge 15 commits into
huggingface:mainfrom
gaoyang07:moss-ttsd

Conversation

@gaoyang07

@gaoyang07 gaoyang07 commented Aug 19, 2025

Copy link
Copy Markdown

What does this PR do?

MOSS-TTSD 🪐

[Files and versions] [Community]

Overview

MOSS-TTSD (text to spoken dialogue) is an open-source bilingual spoken dialogue synthesis model that supports both Chinese and English. It can transform dialogue scripts between two speakers into natural, expressive conversational speech. MOSS-TTSD supports voice cloning and single-session speech generation of up to 960 seconds, making it ideal for AI podcast production.

Highlights

  • Highly Expressive Dialogue Speech: Built on unified semantic-acoustic neural audio codec, a pre-trained large language model, millions of hours of TTS data, and 400k hours synthetic and real conversational speech, MOSS-TTSD generates highly expressive, human-like dialogue speech with natural conversational prosody.
  • Two-Speaker Voice Cloning: MOSS-TTSD supports zero-shot two speakers voice cloning and can generate conversational speech with accurate speaker swithcing based on dialogue scripts.
  • Chinese-English Bilingual Support: MOSS-TTSD enables highly expressive speech generation in both Chinese and English.
  • Long-Form Speech Generation (up to 960 seconds): Thanks to low-bitrate codec and training framework optimization, MOSS-TTSD has been trained for long speech generation, enabling single-session speech generation of up to 960 seconds.
  • Fully Open Source & Commercial-Ready: MOSS-TTSD and its future updates will be fully open-source and support free commercial use.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@gaoyang07 gaoyang07 changed the title [Feature] Support MOSS-TTSD with XY-Tokenizer [WIP] [Feature] Support MOSS-TTSD with XY-Tokenizer Aug 19, 2025
@gaoyang07 gaoyang07 changed the title [WIP] [Feature] Support MOSS-TTSD with XY-Tokenizer [WIP] [models] Add MOSS-TTSD with XY-Tokenizer Aug 19, 2025
@Rocketknight1

Copy link
Copy Markdown
Member

cc @eustlb

@ebezzam ebezzam added the Audio label Aug 20, 2025
@gaoyang07
gaoyang07 force-pushed the moss-ttsd branch 4 times, most recently from 2eedcef to 0d23e64 Compare August 25, 2025 05:59
@gaoyang07 gaoyang07 changed the title [WIP] [models] Add MOSS-TTSD with XY-Tokenizer Add MOSS-TTSD with XY-Tokenizer Aug 25, 2025
@gaoyang07
gaoyang07 force-pushed the moss-ttsd branch 2 times, most recently from 1687d1a to a2d4c6e Compare August 26, 2025 11:11
@gaoyang07

gaoyang07 commented Aug 27, 2025

Copy link
Copy Markdown
Author

@ebezzam @eustlb Hey there, I think now the failed CI cases are not related to our PR changes, so maybe you can start reviewing on this? Thanks~

@ebezzam

ebezzam commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

hey @gaoyang07 thanks a bunch for the PR! We'll try to get in an initial review by next week, we should have more bandwidth then! Thanks for your patience 🙏

@gaoyang07

Copy link
Copy Markdown
Author

hey @gaoyang07 thanks a bunch for the PR! We'll try to get in an initial review by next week, we should have more bandwidth then! Thanks for your patience 🙏

Hey @ebezzam , hope all is well~ Just checking in on this PR — no rush if you’re tied up, but I’d appreciate your review whenever you get a chance. Thanks~

@ebezzam

ebezzam commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Hi @gaoyang07 thanks for your message. I started the review and hope to give you some initial comments by the end of the week!

@ebezzam ebezzam 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.

Thanks for the PR, a lot of things here that are great to add to Transformers and a very nice model to add to the collection. Thanks for open-sourcing and making the effort to contribute 🙏

I've done a first review to focus on the Tokenizer since MOSS-TTSD will depend on it + iterating on the tokenizer will help you get used to some Transformer conventions for us to then iterate on MOSS-TTSD itself more efficiently!

Some general comments:

  • We want to explicitly expose parameters in the configuration. So we want to avoid something like self.params = kwargs in the configuration. I've tried to point some examples to other codecs that may be useful for you.
  • We have this tool known as modular to reuse code from other models. As I see from your paper that you make use of Whisper's encoder and various attention modules, we will want to use modular to import/inherit from replicated components (e.g. Whisper, Llama, DAC), and optionally add more parameters to the init or overwrite methods like forward if a slight variation is needed (see this example). The modular script will be used to generate modeling_xy_tokenizer.py. For the review process, modular also help us to clearly see the new features/architectures that your model is adding to Transformers.
  • Could you also add a conversion script? Essentially it's the script that will map weights from the original model to the Transformers-compatible one, and upload the model and its configuration to the hub. You can see an example here.
  • I was a bit confused by your feature extractor. If your encoders follow the same architecture as Whisper, why can't you directly use Whisper's feature extractor?
  • Removing unused features / options / code branch / etc

Hope that helps and let me know if you have any questions!

Comment thread docs/source/en/model_doc/moss_ttsd.md Outdated
Comment thread docs/source/en/model_doc/xy_tokenizer.md Outdated
Comment thread src/transformers/models/xy_tokenizer/configuration_xy_tokenizer.py Outdated
Comment thread src/transformers/models/xy_tokenizer/configuration_xy_tokenizer.py Outdated
return output_lengths


class XYTokenizerFeatureExtractor(WhisperFeatureExtractor):

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.

I haven't dug deep into how your feature extractors differs from WhisperFeatureExtractor, but is there a reason why the WhisperFeatureExtractor can't be used as is?

From what I understand in your paper (Sec 3.1 - Encoder), the semantic and acoustic encoder are initialized to Whisper's encoder, so I would expect the same feature extractor could be used?

And a new model can used an existing feature extractor, by configuring like so.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We implemented XYTokenizerFeatureExtractor mainly for two reasons:

  • In WhisperFeatureExtractor
    , the maximum frequency is fixed at 8000, which works for 16 kHz inputs but may not generalize. Since we plan to support 24 kHz inputs in XY-Tokenizer, we needed more flexibility.

  • WhisperFeatureExtractor simply truncates inputs longer than 30s. In contrast, XYTokenizerFeatureExtractor splits them into consecutive 30s chunks and adds configurable overlap (right-sided or two-sided), so we can handle inference on audio longer than 30s.

So while they are very similar, we needed these extensions for XY-Tokenizer.

Comment on lines +979 to +987
input_dim: int = 1280,
rvq_dim: Optional[int] = None,
output_dim: Optional[int] = None,
num_quantizers: int = 32,
codebook_size: int = 1024,
codebook_dim: int = 8,
quantizer_dropout: float = 0.5,
skip_rvq_ratio: float = 0.0,
vq_config: VectorQuantizerConfig = None,

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.

Similar to other modules, let's explicitly store the relevant parameters in XYTokenizerConfig. You can how other codecs also specify codebook parameters in the configuration (DAC, EnCodec, Xcodec).

Comment on lines +1002 to +1003
self.input_proj = WNConv1d(input_dim, rvq_dim, 1) if input_dim != rvq_dim else nn.Identity()
self.output_proj = WNConv1d(rvq_dim, self.output_dim, 1) if rvq_dim != self.output_dim else nn.Identity()

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.

Let's remove weight norm as mentioned above.

Comment thread src/transformers/models/xy_tokenizer/modeling_xy_tokenizer.py Outdated
return self.out_project(embeddings)


class ResidualVQ(nn.Module):

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.

Are there similarities with DAC's RVQ? If so, we can simularly use modular to inherit/import from it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for pointing this out! 🙏
There are some similarities, but our quantization method is different from DAC’s. Specifically, as shown in DACVectorQuantize
, DAC normalizes both the input vectors and the codebook before the nearest-neighbor search, while in our implementation we do not apply this normalization step.

Comment thread src/transformers/models/xy_tokenizer/modeling_xy_tokenizer.py Outdated
@kaysonyu
kaysonyu force-pushed the moss-ttsd branch 6 times, most recently from a95029f to 2cd6dc0 Compare December 10, 2025 08:39
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, moss_ttsd, xy_tokenizer

@github-actions

Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=40286&sha=8d9481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants