|
| 1 | +# GLM-TTS |
| 2 | + |
| 3 | +GLM-TTS is a zero-shot Chinese and English speech-synthesis model. The native |
| 4 | +audio.cpp path executes its Llama speech-token generator, Whisper-VQ reference |
| 5 | +encoder, Flow/DiT mel generator, CAMPPlus speaker encoder, and HiFT vocoder. |
| 6 | +Both advertised routes are reference-conditioned: provide a clean WAV and the |
| 7 | +exact words spoken in it. |
| 8 | + |
| 9 | +| Field | Value | |
| 10 | +|---|---| |
| 11 | +| Family | `glm_tts` | |
| 12 | +| Model directory | `models/GLM-TTS` | |
| 13 | +| Task | `tts`, `clon` | |
| 14 | +| Modes | `offline` | |
| 15 | +| Languages | Chinese, English | |
| 16 | +| Voice input | Required reference WAV plus its exact transcript | |
| 17 | +| Output | mono 24 kHz WAV | |
| 18 | + |
| 19 | +Install and prepare the official checkpoint: |
| 20 | + |
| 21 | +```bash |
| 22 | +python tools/model_manager.py install glm_tts --models-dir models |
| 23 | +``` |
| 24 | + |
| 25 | +The installer downloads `zai-org/GLM-TTS`, converts the official Flow and HiFT |
| 26 | +PyTorch checkpoints to safetensors, prepares the ChatGLM tokenizer resources, |
| 27 | +and installs the matching CAMPPlus safetensors weights. The latter are sourced |
| 28 | +from `mlx-community/index-tts2-mlx` because the GLM-TTS repository publishes |
| 29 | +CAMPPlus as ONNX only; the native output was checked directly against that |
| 30 | +official ONNX graph. |
| 31 | + |
| 32 | +Run the prepared safetensors package: |
| 33 | + |
| 34 | +```bash |
| 35 | +audiocpp_cli --task clon --family glm_tts \ |
| 36 | + --model models/GLM-TTS --backend cuda \ |
| 37 | + --voice-ref reference.wav \ |
| 38 | + --reference-text "The exact words spoken in reference.wav." \ |
| 39 | + --text "Hello from GLM-TTS." \ |
| 40 | + --top-k 25 --top-p 0.8 --temperature 1.0 \ |
| 41 | + --seed 0 --max-tokens 256 --out glm_tts.wav |
| 42 | +``` |
| 43 | + |
| 44 | +The `tts` task accepts the same reference arguments. It is an alias for the |
| 45 | +same zero-shot synthesis path rather than an unconditioned preset voice. |
| 46 | + |
| 47 | +## Standalone GGUF |
| 48 | + |
| 49 | +After installing the package, create a standalone mixed GGUF. The |
| 50 | +autoregressive Llama group remains F16 for speech-token quality; the speech |
| 51 | +tokenizer, Flow, HiFT, and CAMPPlus groups use Q8_0: |
| 52 | + |
| 53 | +```bash |
| 54 | +audiocpp_gguf \ |
| 55 | + --input llama_weights=models/GLM-TTS/llm/model.safetensors.index.json \ |
| 56 | + --input speech_tokenizer_weights=models/GLM-TTS/speech_tokenizer/model.safetensors \ |
| 57 | + --input flow_weights=models/GLM-TTS/flow/model.safetensors \ |
| 58 | + --input hift_weights=models/GLM-TTS/hift/model.safetensors \ |
| 59 | + --input campplus_weights=models/GLM-TTS/frontend/campplus.safetensors \ |
| 60 | + --root models/GLM-TTS \ |
| 61 | + --family glm_tts \ |
| 62 | + --model-spec model_specs/glm_tts.json \ |
| 63 | + --type q8_0 \ |
| 64 | + --keep-type "llama_weights/*=f16" \ |
| 65 | + --overwrite \ |
| 66 | + --output models/GLM-TTS-Q8/GLM-TTS_Q8.gguf |
| 67 | +``` |
| 68 | + |
| 69 | +The resulting file embeds all five tensor groups, the package specification, |
| 70 | +configs, and tokenizer sidecars. It runs from a directory containing only the |
| 71 | +GGUF: |
| 72 | + |
| 73 | +```bash |
| 74 | +audiocpp_cli --task clon --family glm_tts \ |
| 75 | + --model models/GLM-TTS-Q8/GLM-TTS_Q8.gguf --backend cuda \ |
| 76 | + --voice-ref reference.wav \ |
| 77 | + --reference-text "The exact words spoken in reference.wav." \ |
| 78 | + --text "Hello from GLM-TTS." \ |
| 79 | + --seed 0 --max-tokens 256 --out glm_tts_q8.wav |
| 80 | +``` |
| 81 | + |
| 82 | +## Controls |
| 83 | + |
| 84 | +| Option | Values | Default | Meaning | |
| 85 | +|---|---|---:|---| |
| 86 | +| `--reference-text` | text | required | Exact transcript of `--voice-ref`. | |
| 87 | +| `--max-tokens` | integer | automatic | Maximum generated speech-token count. | |
| 88 | +| `--temperature` | float | `1.0` | Speech-token sampling temperature. | |
| 89 | +| `--top-k` | integer | `25` | Speech-token top-k limit. | |
| 90 | +| `--top-p` | float | `0.8` | Speech-token nucleus threshold. | |
| 91 | +| `--seed` | integer | `0` | Seed used by token sampling, Flow noise, and HiFT. | |
| 92 | +| `--request-option flow_steps=<n>` | integer | `10` | Flow Euler integration steps. | |
| 93 | +| `--request-option cfg_rate=<float>` | float | `0.7` | Flow classifier-free guidance rate. | |
| 94 | +| `--request-option flow_noise_file=<path>` | raw F32 path | none | Optional exact initial Flow noise for parity tests. | |
| 95 | +| `--request-option hift_source_random_file=<path>` | raw F32 path | none | Optional exact HiFT phase-uniform and Gaussian values for parity tests. | |
| 96 | +| `--request-option hift_prior_noise_values=<n>` | integer | `0` | Torch RNG offset before normal HiFT source generation. | |
| 97 | +| `--session-option glm_tts.weight_type=native|f32|f16|bf16|q8_0` | enum | `native` | Requested component weight storage type. | |
| 98 | +| `--session-option glm_tts.mem_saver=true|false` | bool | `false` | Release the reference-only Whisper-VQ and CAMPPlus runtimes after caching the voice, while keeping Llama, Flow, and HiFT warm. | |
| 99 | +| `--session-option glm_tts.aggressive_mem_saver=true|false` | bool | `false` | Also release Llama, Flow, and HiFT after each stage. This minimizes VRAM but reloads the generation path on every request. | |
| 100 | +| `--session-option glm_tts.reference_cache_slots=<n>` | integer | `1` | Prepared reference-audio cache slots. Reusing a reference skips Whisper-VQ, mel, fbank, and CAMPPlus preparation; `0` disables it. | |
| 101 | + |
| 102 | +Balanced mem-saver is intended for a server repeatedly using a cached |
| 103 | +reference voice. On a reference-cache miss it first releases the warm |
| 104 | +generation path, prepares and caches the new voice, then reconstructs the |
| 105 | +generation path. This prevents the reference and generation weight groups |
| 106 | +from overlapping in VRAM. Set `glm_tts.aggressive_mem_saver=true` only when |
| 107 | +the lowest possible peak VRAM is more important than request latency; it |
| 108 | +implies balanced mem-saver even when `glm_tts.mem_saver` is omitted. |
| 109 | + |
| 110 | +The reference transcript must match the audio. A mismatched transcript changes |
| 111 | +both semantic and speaker conditioning and can substantially reduce quality. |
| 112 | +Q8 generation can select a slightly different speech-token sequence from the |
| 113 | +native checkpoint, so waveform identity is not expected. |
| 114 | + |
| 115 | +See [GLM-TTS validation](../reports/glm_tts_validation.md) for exact component |
| 116 | +parity, path-test, timing, and output details. |
0 commit comments