This is a
GPTQ 4-bit quantized version of
MOSS-TTS (MossTTSDelay 8B) by the OpenMOSS Team, quantized using
GPTQModel. The quantization targets the LLM backbone only; the non-backbone weights (
emb_ext,
lm_heads,
language_model.norm) are preserved in their original precision and merged back into a single self-contained repo.
This repo is intended to be used together with the float16 audio tokenizer: 🤗
blazingbhavneek/MOSS-Audio-Tokenizer-FP16.
The quantization scripts and a working environment
requirements.txt are available in the
fork used to produce this model.
Install
GPTQModel in addition to the standard MOSS-TTS dependencies — it is required to load the quantized backbone at inference time:
1git clone -b feature/gptq-quant-model-support https://github.com/blazingbhavneek/MOSS-TTS.git
2cd MOSS-TTS
3pip install --extra-index-url https://download.pytorch.org/whl/cu128 -e .
1from pathlib import Path
2import torch
3import torchaudio
4from moss_tts_delay.modeling_moss_tts import MossTTSDelayModel
5from moss_tts_delay.processing_moss_tts import MossTTSDelayProcessor
6
7# Disable problematic SDP backends
8torch.backends.cuda.enable_cudnn_sdp(False)
9torch.backends.cuda.enable_flash_sdp(False)
10torch.backends.cuda.enable_mem_efficient_sdp(False)
11torch.backends.cuda.enable_math_sdp(True)
12
13MERGED_PATH = "blazingbhavneek/MOSS-TTS-GPTQ"
14AUDIO_TOK_PATH = "blazingbhavneek/MOSS-Audio-Tokenizer-FP16"
15
16device = "cuda" if torch.cuda.is_available() else "cpu"
17
18model = MossTTSDelayModel.from_pretrained(
19 MERGED_PATH,
20 gptq_device=device,
21 trust_remote_code=True,
22).eval()
23
24processor = MossTTSDelayProcessor.from_pretrained(
25 MERGED_PATH,
26 codec_path=AUDIO_TOK_PATH,
27 trust_remote_code=True,
28)
29
30# --- Example texts ---
31text_en = "We stand on the threshold of the AI era. Artificial intelligence is no longer just a concept in laboratories, but is entering every industry, every creative endeavor, and every decision."
32text_zh = "亲爱的你,你好呀。今天,我想用最认真、最温柔的声音,对你说一些重要的话。"
33text_pinyin = "nin2 hao3,qing3 wen4 nin2 lai2 zi4 na3 zuo4 cheng2 shi4?"
34text_ipa = "/həloʊ, meɪ aɪ æsk wɪtʃ sɪti juː ɑːr frʌm?/"
35
36# Reference audio for voice cloning (URLs or local paths)
37ref_audio_zh = "https://speech-demo.oss-cn-shanghai.aliyuncs.com/moss_tts_demo/tts_readme_demo/reference_zh.wav"
38ref_audio_en = "https://speech-demo.oss-cn-shanghai.aliyuncs.com/moss_tts_demo/tts_readme_demo/reference_en.m4a"
39
40conversations = [
41 # Direct TTS (no reference)
42 [processor.build_user_message(text=text_zh)],
43 [processor.build_user_message(text=text_en)],
44 # Pronunciation control
45 [processor.build_user_message(text=text_pinyin)],
46 [processor.build_user_message(text=text_ipa)],
47 # Voice cloning
48 [processor.build_user_message(text=text_zh, reference=[ref_audio_zh])],
49 [processor.build_user_message(text=text_en, reference=[ref_audio_en])],
50 # Duration control (1s ≈ 12.5 tokens)
51 [processor.build_user_message(text=text_en, tokens=325)],
52 [processor.build_user_message(text=text_en, tokens=600)],
53]
54
55save_dir = Path("inference_root")
56save_dir.mkdir(exist_ok=True, parents=True)
57
58with torch.no_grad():
59 for idx, conversation in enumerate(conversations):
60 batch = processor([conversation], mode="generation")
61 outputs = model.generate(
62 input_ids=batch["input_ids"].to(device),
63 attention_mask=batch["attention_mask"].to(device),
64 max_new_tokens=4096,
65 )
66 for message in processor.decode([(sl, ids.long()) for sl, ids in outputs]):
67 audio = message.audio_codes_list[0]
68 out_path = save_dir / f"sample{idx}.wav"
69 torchaudio.save(out_path, audio.unsqueeze(0), processor.model_config.sampling_rate)
70 print(f"Saved {out_path}")
Apache 2.0, consistent with the original
MOSS-TTS release.