ArchiveStudio
/

ArchiveStudio ZHANGYUXUAN-zR commited on
Commit
1c9d03f
·
0 Parent(s):

Duplicate from zai-org/GLM-TTS

Browse files

Co-authored-by: zR <ZHANGYUXUAN-zR@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ - en
5
+ tags:
6
+ - llm
7
+ - tts
8
+ - zero-shot
9
+ - voice-cloning
10
+ - reinforcement-learning
11
+ - flow-matching
12
+ license: mit
13
+ pipeline_tag: text-to-speech
14
+ library_name: glm-tts
15
+ ---
16
+
17
+ # GLM-TTS: Controllable & Emotion-Expressive Zero-shot TTS
18
+
19
+ <div align="center">
20
+ <img src=https://raw.githubusercontent.com/zai-org/GLM-TTS/refs/heads/main/assets/images/logo.svg width="50%"/>
21
+ </div>
22
+
23
+ <p align="center">
24
+ <a href="https://arxiv.org/abs/2512.14291" target="_blank">📜 Paper</a>
25
+ &nbsp;&nbsp;|&nbsp;&nbsp;
26
+ <a href="https://github.com/zai-org/GLM-TTS" target="_blank">💻 GitHub Repository</a>
27
+ &nbsp;&nbsp;|&nbsp;&nbsp;
28
+ <a href="https://audio.z.ai/" target="_blank">🛠️ Audio.Z.AI</a>
29
+ </p>
30
+
31
+ ## 📖 Model Introduction
32
+
33
+ GLM-TTS is a high-quality text-to-speech (TTS) synthesis system based on large language models, supporting zero-shot voice cloning and streaming inference. The system adopts a two-stage architecture combining an LLM for speech token generation and a Flow Matching model for waveform synthesis.
34
+
35
+ By introducing a **Multi-Reward Reinforcement Learning** framework, GLM-TTS significantly improves the expressiveness of generated speech, achieving more natural emotional control compared to traditional TTS systems.
36
+
37
+ ### Key Features
38
+
39
+ * **Zero-shot Voice Cloning:** Clone any speaker's voice with just 3-10 seconds of prompt audio.
40
+ * **RL-enhanced Emotion Control:** Utilizes a multi-reward reinforcement learning framework (GRPO) to optimize prosody and emotion.
41
+ * **High-quality Synthesis:** Generates speech comparable to commercial systems with reduced Character Error Rate (CER).
42
+ * **Phoneme-level Control:** Supports "Hybrid Phoneme + Text" input for precise pronunciation control (e.g., polyphones).
43
+ * **Streaming Inference:** Supports real-time audio generation suitable for interactive applications.
44
+ * **Bilingual Support:** Optimized for Chinese and English mixed text.
45
+
46
+ ## System Architecture
47
+
48
+ GLM-TTS follows a two-stage design:
49
+
50
+ 1. **Stage 1 (LLM):** A Llama-based model converts input text into speech token sequences.
51
+ 2. **Stage 2 (Flow Matching):** A Flow model converts token sequences into high-quality mel-spectrograms, which are then turned into waveforms by a vocoder.
52
+
53
+ <div align="center">
54
+ <img src="https://raw.githubusercontent.com/zai-org/GLM-TTS/refs/heads/main/assets/images/architecture.png" width="60%" alt="GLM-TTS Architecture">
55
+ </div>
56
+
57
+ ### Reinforcement Learning Alignment
58
+ To tackle flat emotional expression, GLM-TTS uses a **Group Relative Policy Optimization (GRPO)** algorithm with multiple reward functions (Similarity, CER, Emotion, Laughter) to align the LLM's generation strategy.
59
+
60
+ ## Evaluation Results
61
+
62
+ Evaluated on `seed-tts-eval`. **GLM-TTS_RL** achieves the lowest Character Error Rate (CER) while maintaining high speaker similarity.
63
+
64
+ | Model | CER ↓ | SIM ↑ | Open-source |
65
+ | :--- | :---: | :---: | :---: |
66
+ | Seed-TTS | 1.12 | **79.6** | 🔒 No |
67
+ | CosyVoice2 | 1.38 | 75.7 | 👐 Yes |
68
+ | F5-TTS | 1.53 | 76.0 | 👐 Yes |
69
+ | **GLM-TTS (Base)** | 1.03 | 76.1 | 👐 Yes |
70
+ | **GLM-TTS_RL (Ours)** | **0.89** | 76.4 | 👐 Yes |
71
+
72
+ ## Quick Start
73
+
74
+ ### Installation
75
+
76
+ ```bash
77
+ git clone [https://github.com/zai-org/GLM-TTS.git](https://github.com/zai-org/GLM-TTS.git)
78
+ cd GLM-TTS
79
+ pip install -r requirements.txt
80
+ ```
81
+
82
+ #### Command Line Inference
83
+
84
+ ```bash
85
+ python glmtts_inference.py \
86
+ --data=example_zh \
87
+ --exp_name=_test \
88
+ --use_cache \
89
+ # --phoneme # Add this flag to enable phoneme capabilities.
90
+ ```
91
+
92
+ #### Shell Script Inference
93
+
94
+ ```bash
95
+ bash glmtts_inference.sh
96
+ ```
97
+
98
+ ## Acknowledgments & Citation
99
+
100
+ We thank the following open-source projects for their support:
101
+
102
+ - [CosyVoice](https://github.com/FunAudioLLM/CosyVoice) - Providing frontend processing framework and high-quality vocoder
103
+ - [Llama](https://github.com/meta-llama/llama) - Providing basic language model architecture
104
+ - [Vocos](https://github.com/charactr-platform/vocos) - Providing high-quality vocoder
105
+ - [GRPO-Zero](https://github.com/policy-gradient/GRPO-Zero) - Reinforcement learning algorithm implementation inspiration
106
+
107
+ If you find GLM-TTS useful for your research, please cite our technical report:
108
+
109
+ ```bibtex
110
+ @misc{cui2025glmttstechnicalreport,
111
+ title={GLM-TTS Technical Report},
112
+ author={Jiayan Cui and Zhihan Yang and Naihan Li and Jiankun Tian and Xingyu Ma and Yi Zhang and Guangyu Chen and Runxuan Yang and Yuqing Cheng and Yizhi Zhou and Guochen Yu and Xiaotao Gu and Jie Tang},
113
+ year={2025},
114
+ eprint={2512.14291},
115
+ archivePrefix={arXiv},
116
+ primaryClass={cs.SD},
117
+ url={https://arxiv.org/abs/2512.14291},
118
+ }
119
+ }
flow/config.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ flow: !new:flow.flow.Flow
2
+ spkr_emb_adaLN: True
3
+ speech_token_cfg: False
4
+ remove_spkr_concat_condition: True
5
+ mel_dim: 80
6
+ mel_framerate: 50
7
+ input_frame_rate: 25
flow/flow.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:532fb30348a9a8df727c8b4b142b3e7a272d5a4f2e2d7b70576c60662943b143
3
+ size 901331642
hift/hift.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3386cc880324d4e98e05987b99107f49e40ed925b8ecc87c1f4939432d429879
3
+ size 83390254
llm/config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "head_dim": 128,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 2048,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 6144,
14
+ "max_position_embeddings": 8192,
15
+ "mlp_bias": false,
16
+ "model_type": "llama",
17
+ "num_attention_heads": 16,
18
+ "num_hidden_layers": 28,
19
+ "num_key_value_heads": 4,
20
+ "pretraining_tp": 1,
21
+ "rms_norm_eps": 1e-05,
22
+ "rope_scaling": null,
23
+ "rope_theta": 10000.0,
24
+ "tie_word_embeddings": true,
25
+ "torch_dtype": "float32",
26
+ "transformers_version": "4.47.1",
27
+ "use_cache": true,
28
+ "vocab_size": 98304
29
+ }
llm/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.47.1"
6
+ }
llm/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12adf2b0ea8be7a39ea5d5aa2d3658556602b1d979a382d41e3cd79b546d7b30
3
+ size 4999976928
llm/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f07a39df2aff4b4f5b68494d98584e4cc319fc7561d9823d6408979f25f5e32
3
+ size 1208089016
llm/model.safetensors.index.json ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 6208036864
4
+ },
5
+ "weight_map": {
6
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
7
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
42
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
61
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
63
+ "model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
66
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
73
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
75
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
78
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
80
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
87
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
90
+ "model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
91
+ "model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
97
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
99
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
102
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
103
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
109
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
111
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
112
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
113
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
114
+ "model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
116
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
119
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
120
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
121
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
123
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
124
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
126
+ "model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
127
+ "model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
128
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
130
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
133
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
134
+ "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
135
+ "model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
137
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
138
+ "model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
139
+ "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
140
+ "model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
141
+ "model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
143
+ "model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
144
+ "model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
145
+ "model.layers.22.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
146
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
147
+ "model.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
148
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
149
+ "model.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
150
+ "model.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
151
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
152
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
153
+ "model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
154
+ "model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
155
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
156
+ "model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
157
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
158
+ "model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
159
+ "model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
160
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
161
+ "model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
162
+ "model.layers.24.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
163
+ "model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
164
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
165
+ "model.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
166
+ "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
167
+ "model.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
168
+ "model.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
169
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
170
+ "model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
171
+ "model.layers.25.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
172
+ "model.layers.25.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
173
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
174
+ "model.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
175
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
176
+ "model.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
177
+ "model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
178
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
179
+ "model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
180
+ "model.layers.26.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
181
+ "model.layers.26.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
182
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
183
+ "model.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
184
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
185
+ "model.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
186
+ "model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
187
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
188
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
189
+ "model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
190
+ "model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
191
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
192
+ "model.layers.27.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
193
+ "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
194
+ "model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
195
+ "model.layers.27.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
196
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
197
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
198
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
199
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
200
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
201
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
202
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
203
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
204
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
205
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
206
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
207
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
208
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
209
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
210
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
211
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
212
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
213
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
214
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
215
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
216
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
217
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
218
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
219
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
220
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
221
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
222
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
223
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
224
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
225
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
226
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
227
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
228
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
229
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
230
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
231
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
232
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
233
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
234
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
235
+ "model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
236
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
237
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
238
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
239
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
240
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
241
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
242
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
243
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
244
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
245
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
246
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
247
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
248
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
249
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
250
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
251
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
252
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
253
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
254
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
255
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
256
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
257
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
258
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
259
+ "model.norm.weight": "model-00002-of-00002.safetensors"
260
+ }
261
+ }
speech_tokenizer/config.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/workspace/audio_team/usr/jiayan/jiayan--TTS3--1.5B/pretrained_models/whisper-large-v3",
3
+ "activation_dropout": 0.0,
4
+ "activation_function": "gelu",
5
+ "apply_spec_augment": false,
6
+ "architectures": [
7
+ "WhisperVQForConditionalGeneration"
8
+ ],
9
+ "attention_dropout": 0.0,
10
+ "begin_suppress_tokens": [
11
+ 220,
12
+ 50257
13
+ ],
14
+ "bos_token_id": 50257,
15
+ "classifier_proj_size": 256,
16
+ "d_model": 1280,
17
+ "decoder_attention_heads": 20,
18
+ "decoder_ffn_dim": 5120,
19
+ "decoder_layerdrop": 0.0,
20
+ "decoder_layers": 32,
21
+ "decoder_start_token_id": 50258,
22
+ "dropout": 0.0,
23
+ "encoder_attention_heads": 20,
24
+ "encoder_causal_attention": false,
25
+ "encoder_causal_convolution": false,
26
+ "encoder_ffn_dim": 5120,
27
+ "encoder_layerdrop": 0.0,
28
+ "encoder_layers": 32,
29
+ "eos_token_id": 50257,
30
+ "init_std": 0.02,
31
+ "is_encoder_decoder": true,
32
+ "mask_feature_length": 10,
33
+ "mask_feature_min_masks": 0,
34
+ "mask_feature_prob": 0.0,
35
+ "mask_time_length": 10,
36
+ "mask_time_min_masks": 2,
37
+ "mask_time_prob": 0.05,
38
+ "max_length": 448,
39
+ "max_source_positions": 1500,
40
+ "max_target_positions": 448,
41
+ "median_filter_width": 7,
42
+ "model_type": "whisper",
43
+ "num_hidden_layers": 32,
44
+ "num_mel_bins": 128,
45
+ "pad_token_id": 50256,
46
+ "pitch_control": "fcpe_f0",
47
+ "pitch_loss_scale": 2.0,
48
+ "pitch_upsample_scale": 2,
49
+ "pooling_kernel_size": 2,
50
+ "pooling_position": 16,
51
+ "pooling_type": "avg",
52
+ "quantize_causal_block_size": 200,
53
+ "quantize_causal_encoder": false,
54
+ "quantize_commit_coefficient": 0.25,
55
+ "quantize_ema_decay": 0.99,
56
+ "quantize_encoder_only": false,
57
+ "quantize_hidden_dim": null,
58
+ "quantize_loss_scale": 10.0,
59
+ "quantize_position": 16,
60
+ "quantize_restart_interval": 100,
61
+ "quantize_vocab_size": 32768,
62
+ "scale_embedding": false,
63
+ "skip_language_detection": true,
64
+ "torch_dtype": "float32",
65
+ "transformers_version": "4.44.1",
66
+ "use_cache": true,
67
+ "use_weighted_layer_sum": false,
68
+ "vocab_size": 51866
69
+ }
speech_tokenizer/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78e3a3542b8e111a2ecb363056c643dafdef3624eacce3af587693421a55e38e
3
+ size 1628135704
speech_tokenizer/preprocessor_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "chunk_length": 30,
3
+ "feature_extractor_type": "WhisperFeatureExtractor",
4
+ "feature_size": 128,
5
+ "hop_length": 160,
6
+ "n_fft": 400,
7
+ "n_samples": 480000,
8
+ "nb_max_frames": 3000,
9
+ "padding_side": "right",
10
+ "padding_value": 0.0,
11
+ "processor_class": "WhisperProcessor",
12
+ "return_attention_mask": false,
13
+ "sampling_rate": 16000
14
+ }
vocos2d/generator_jit.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:acfccc69db407008db8388eea1b8229151bdb822083211f757f5c1c73847913a
3
+ size 60429952
vq32k-phoneme-tokenizer/tokenization_chatglm.py ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import regex as re
2
+ import base64
3
+ import os
4
+ import tiktoken
5
+ from typing import List, Optional, Union, Dict
6
+ from transformers import PreTrainedTokenizer
7
+ from transformers.utils import PaddingStrategy
8
+ from transformers.tokenization_utils_base import EncodedInput, BatchEncoding
9
+
10
+
11
+ class ChatGLM4Tokenizer(PreTrainedTokenizer):
12
+ vocab_files_names = {"vocab_file": "tokenizer.model"}
13
+ model_input_names = ["input_ids", "attention_mask", "position_ids"]
14
+
15
+ def __init__(
16
+ self,
17
+ vocab_file,
18
+ clean_up_tokenization_spaces=False,
19
+ **kwargs
20
+ ):
21
+ self.name = "GLM4Tokenizer"
22
+ self.vocab_file = vocab_file
23
+ pat_str = "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+"
24
+ self.pat_str = re.compile(pat_str)
25
+
26
+ mergeable_ranks = {}
27
+ with open(vocab_file) as f:
28
+ for line in f:
29
+ token, rank = line.strip().split()
30
+ rank = int(rank)
31
+ token = base64.b64decode(token)
32
+ mergeable_ranks[token] = rank
33
+
34
+ self.mergeable_ranks = mergeable_ranks
35
+
36
+ self.tokenizer = tiktoken.Encoding(
37
+ name="my_tokenizer",
38
+ pat_str=pat_str,
39
+ mergeable_ranks=mergeable_ranks,
40
+ special_tokens={}
41
+ )
42
+ self.decoder = {rank: token for token, rank in mergeable_ranks.items()}
43
+ self.n_words = len(self.decoder)
44
+
45
+ super().__init__(
46
+ clean_up_tokenization_spaces=clean_up_tokenization_spaces,
47
+ **kwargs
48
+ )
49
+
50
+ @property
51
+ def vocab_size(self):
52
+ return self.n_words
53
+
54
+ def get_vocab(self):
55
+ """ Returns vocab as a dict """
56
+ vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
57
+ vocab.update(self.added_tokens_encoder)
58
+ return vocab
59
+
60
+ def convert_tokens_to_string(self, tokens: List[Union[bytes, str, int]]) -> str:
61
+ """
62
+ Converts a sequence of tokens in a single string.
63
+ """
64
+ text = ""
65
+ temp = b""
66
+ for t in tokens:
67
+ if isinstance(t, int):
68
+ t = chr(t)
69
+ if isinstance(t, str):
70
+ if temp:
71
+ text += temp.decode("utf-8", errors="replace")
72
+ elif isinstance(t, bytes):
73
+ temp += t
74
+ else:
75
+ raise TypeError("token should only be of type int, bytes or str")
76
+ if temp:
77
+ text += temp.decode("utf-8", errors="replace")
78
+ return text
79
+
80
+ def _tokenize(self, text, **kwargs):
81
+ tokens = []
82
+ ids = self.tokenizer.encode(text)
83
+ for t in ids:
84
+ tokens.append(self.decoder[t])
85
+ return tokens
86
+
87
+ def _convert_token_to_id(self, token):
88
+ """ Converts a token (str) in an id using the vocab. """
89
+ return self.mergeable_ranks[token]
90
+
91
+ def _convert_id_to_token(self, index):
92
+ """Converts an index (integer) in a token (str) using the vocab."""
93
+ return self.decoder.get(index, "")
94
+
95
+ def save_vocabulary(self, save_directory, filename_prefix=None):
96
+ """
97
+ Save the vocabulary and special tokens file to a directory.
98
+
99
+ Args:
100
+ save_directory (`str`):
101
+ The directory in which to save the vocabulary.
102
+ filename_prefix (`str`, *optional*):
103
+ An optional prefix to add to the named of the saved files.
104
+
105
+ Returns:
106
+ `Tuple(str)`: Paths to the files saved.
107
+ """
108
+ if os.path.isdir(save_directory):
109
+ vocab_file = os.path.join(
110
+ save_directory, self.vocab_files_names["vocab_file"]
111
+ )
112
+ else:
113
+ vocab_file = save_directory
114
+
115
+ with open(self.vocab_file, 'rb') as fin:
116
+ proto_str = fin.read()
117
+
118
+ with open(vocab_file, "wb") as writer:
119
+ writer.write(proto_str)
120
+
121
+ return (vocab_file,)
122
+
123
+ def get_prefix_tokens(self):
124
+ prefix_tokens = [self.convert_tokens_to_ids("[gMASK]"), self.convert_tokens_to_ids("<sop>")]
125
+ return prefix_tokens
126
+
127
+ def build_single_message(self, role, metadata, message, tokenize=True):
128
+ assert role in ["system", "user", "assistant", "observation"], role
129
+ if tokenize:
130
+ role_tokens = [self.convert_tokens_to_ids(f"<|{role}|>")] + self.tokenizer.encode(f"{metadata}\n",
131
+ disallowed_special=())
132
+ message_tokens = self.tokenizer.encode(message, disallowed_special=())
133
+ tokens = role_tokens + message_tokens
134
+ return tokens
135
+ else:
136
+ return str(f"<|{role}|>{metadata}\n{message}")
137
+
138
+ def build_inputs_with_special_tokens(
139
+ self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
140
+ ) -> List[int]:
141
+ """
142
+ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
143
+ adding special tokens. A BERT sequence has the following format:
144
+
145
+ - single sequence: `[CLS] X [SEP]`
146
+ - pair of sequences: `[CLS] A [SEP] B [SEP]`
147
+
148
+ Args:
149
+ token_ids_0 (`List[int]`):
150
+ List of IDs to which the special tokens will be added.
151
+ token_ids_1 (`List[int]`, *optional*):
152
+ Optional second list of IDs for sequence pairs.
153
+
154
+ Returns:
155
+ `List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
156
+ """
157
+ # prefix_tokens = self.get_prefix_tokens()
158
+ # token_ids_0 = prefix_tokens + token_ids_0
159
+ if token_ids_1 is not None:
160
+ token_ids_0 = token_ids_0 + token_ids_1 + [self.convert_tokens_to_ids("<eos>")]
161
+ return token_ids_0
162
+
163
+ def _pad(
164
+ self,
165
+ encoded_inputs: Union[Dict[str, EncodedInput], BatchEncoding],
166
+ max_length: Optional[int] = None,
167
+ padding_side: str = "left",
168
+ padding_strategy: PaddingStrategy = PaddingStrategy.DO_NOT_PAD,
169
+ pad_to_multiple_of: Optional[int] = None,
170
+ return_attention_mask: Optional[bool] = None,
171
+ ) -> dict:
172
+ """
173
+ Pad encoded inputs (on left/right and up to predefined length or max length in the batch)
174
+
175
+ Args:
176
+ encoded_inputs:
177
+ Dictionary of tokenized inputs (`List[int]`) or batch of tokenized inputs (`List[List[int]]`).
178
+ max_length: maximum length of the returned list and optionally padding length (see below).
179
+ Will truncate by taking into account the special tokens.
180
+ padding_strategy: PaddingStrategy to use for padding.
181
+
182
+ - PaddingStrategy.LONGEST Pad to the longest sequence in the batch
183
+ - PaddingStrategy.MAX_LENGTH: Pad to the max length (default)
184
+ - PaddingStrategy.DO_NOT_PAD: Do not pad
185
+ The tokenizer padding sides are defined in self.padding_side:
186
+
187
+ - 'left': pads on the left of the sequences
188
+ - 'right': pads on the right of the sequences
189
+ pad_to_multiple_of: (optional) Integer if set will pad the sequence to a multiple of the provided value.
190
+ This is especially useful to enable the use of Tensor Core on NVIDIA hardware with compute capability
191
+ `>= 7.5` (Volta).
192
+ return_attention_mask:
193
+ (optional) Set to False to avoid returning attention mask (default: set to model specifics)
194
+ """
195
+ # Load from model defaults
196
+
197
+ required_input = encoded_inputs[self.model_input_names[0]]
198
+ seq_length = len(required_input)
199
+
200
+ if padding_strategy == PaddingStrategy.LONGEST:
201
+ max_length = len(required_input)
202
+
203
+ if max_length is not None and pad_to_multiple_of is not None and (max_length % pad_to_multiple_of != 0):
204
+ max_length = ((max_length // pad_to_multiple_of) + 1) * pad_to_multiple_of
205
+
206
+ needs_to_be_padded = padding_strategy != PaddingStrategy.DO_NOT_PAD and len(required_input) != max_length
207
+
208
+ # Initialize attention mask if not present.
209
+ if "attention_mask" not in encoded_inputs:
210
+ encoded_inputs["attention_mask"] = [1] * seq_length
211
+
212
+ if "position_ids" not in encoded_inputs:
213
+ encoded_inputs["position_ids"] = list(range(seq_length))
214
+
215
+ if needs_to_be_padded:
216
+ difference = max_length - len(required_input)
217
+
218
+ if "attention_mask" in encoded_inputs:
219
+ encoded_inputs["attention_mask"] = [0] * difference + encoded_inputs["attention_mask"]
220
+ if "position_ids" in encoded_inputs:
221
+ encoded_inputs["position_ids"] = [0] * difference + encoded_inputs["position_ids"]
222
+ encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input
223
+
224
+ return encoded_inputs
vq32k-phoneme-tokenizer/tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c16309bf80bf496e823cad3a9e77967746d5f0ac55afd1755717ec9f9cc1ce0
3
+ size 1044856
vq32k-phoneme-tokenizer/tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff