Upload folder using huggingface_hub
Browse files- .gitattributes +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/__init__.py +0 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/added_tokens.json +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/config.json +39 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/generation_config.json +11 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/hf_rwkv_tokenizer.py +278 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/modeling_rwkv7.py +4 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/rwkv_vocab_v20230424.txt +0 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/special_tokens_map.json +5 -0
- CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/tokenizer_config.json +27 -0
- CosyVoice2-0.5B_RWKV_1.5B/README.md +227 -0
- CosyVoice2-0.5B_RWKV_1.5B/asset/dingding.png +0 -0
- CosyVoice2-0.5B_RWKV_1.5B/campplus.onnx +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/configuration.json +1 -0
- CosyVoice2-0.5B_RWKV_1.5B/cosyvoice.yaml +138 -0
- CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.a10.plan +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.l20.plan +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.v100.plan +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp32.onnx +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/flow.encoder.fp16.zip +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/flow.encoder.fp32.zip +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/flow.pt +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/hift.pt +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/llm.pt +3 -0
- CosyVoice2-0.5B_RWKV_1.5B/speech_tokenizer_v2.onnx +3 -0
.gitattributes
CHANGED
@@ -39,3 +39,6 @@ CosyVoice2-0.5B_RWKV_0.19B/flow.decoder.estimator.fp16.v100.plan filter=lfs diff
|
|
39 |
CosyVoice2-0.5B_RWKV_0.4B/flow.decoder.estimator.fp16.a10.plan filter=lfs diff=lfs merge=lfs -text
|
40 |
CosyVoice2-0.5B_RWKV_0.4B/flow.decoder.estimator.fp16.l20.plan filter=lfs diff=lfs merge=lfs -text
|
41 |
CosyVoice2-0.5B_RWKV_0.4B/flow.decoder.estimator.fp16.v100.plan filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
39 |
CosyVoice2-0.5B_RWKV_0.4B/flow.decoder.estimator.fp16.a10.plan filter=lfs diff=lfs merge=lfs -text
|
40 |
CosyVoice2-0.5B_RWKV_0.4B/flow.decoder.estimator.fp16.l20.plan filter=lfs diff=lfs merge=lfs -text
|
41 |
CosyVoice2-0.5B_RWKV_0.4B/flow.decoder.estimator.fp16.v100.plan filter=lfs diff=lfs merge=lfs -text
|
42 |
+
CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.a10.plan filter=lfs diff=lfs merge=lfs -text
|
43 |
+
CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.l20.plan filter=lfs diff=lfs merge=lfs -text
|
44 |
+
CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.v100.plan filter=lfs diff=lfs merge=lfs -text
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/__init__.py
ADDED
File without changes
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/added_tokens.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"<|rwkv_tokenizer_end_of_text|>": 0
|
3 |
+
}
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/config.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_attn_implementation_autoset": true,
|
3 |
+
"a_low_rank_dim": 96,
|
4 |
+
"architectures": [
|
5 |
+
"RWKV7ForCausalLM"
|
6 |
+
],
|
7 |
+
"attn": null,
|
8 |
+
"attn_mode": "chunk",
|
9 |
+
"auto_map": {
|
10 |
+
"AutoConfig": "modeling_rwkv7.RWKV7Config",
|
11 |
+
"AutoModel": "modeling_rwkv7.RWKV7Model",
|
12 |
+
"AutoModelForCausalLM": "modeling_rwkv7.RWKV7ForCausalLM"
|
13 |
+
},
|
14 |
+
"bos_token_id": 1,
|
15 |
+
"decay_low_rank_dim": 96,
|
16 |
+
"eos_token_id": 2,
|
17 |
+
"fuse_cross_entropy": true,
|
18 |
+
"fuse_norm": true,
|
19 |
+
"gate_low_rank_dim": 256,
|
20 |
+
"head_dim": 64,
|
21 |
+
"hidden_act": "sqrelu",
|
22 |
+
"hidden_ratio": 4.0,
|
23 |
+
"hidden_size": 2048,
|
24 |
+
"initializer_range": 0.02,
|
25 |
+
"intermediate_size": 8192,
|
26 |
+
"max_position_embeddings": 2048,
|
27 |
+
"model_type": "rwkv7",
|
28 |
+
"norm_bias": true,
|
29 |
+
"norm_eps": 1e-05,
|
30 |
+
"norm_first": true,
|
31 |
+
"num_heads": null,
|
32 |
+
"num_hidden_layers": 24,
|
33 |
+
"tie_word_embeddings": false,
|
34 |
+
"torch_dtype": "float32",
|
35 |
+
"transformers_version": "4.48.1",
|
36 |
+
"use_cache": true,
|
37 |
+
"v_low_rank_dim": 64,
|
38 |
+
"vocab_size": 65536
|
39 |
+
}
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/generation_config.json
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token_id": 0,
|
3 |
+
"eos_token_id": 0,
|
4 |
+
"pad_token_id": 0,
|
5 |
+
"max_window_size": 2147483647,
|
6 |
+
"do_sample": true,
|
7 |
+
"top_k": 65536,
|
8 |
+
"top_p": 1.0,
|
9 |
+
"temperature": 1.0,
|
10 |
+
"transformers_version": "4.48.0"
|
11 |
+
}
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/hf_rwkv_tokenizer.py
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2024 The HuggingFace Inc. team.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Tokenization classes for RWKV."""
|
16 |
+
|
17 |
+
import os
|
18 |
+
import re
|
19 |
+
from typing import TYPE_CHECKING, List, Optional, Tuple
|
20 |
+
|
21 |
+
from transformers.tokenization_utils import AddedToken, PreTrainedTokenizer
|
22 |
+
from transformers.utils import logging
|
23 |
+
|
24 |
+
|
25 |
+
if TYPE_CHECKING:
|
26 |
+
pass
|
27 |
+
|
28 |
+
logger = logging.get_logger(__name__)
|
29 |
+
|
30 |
+
|
31 |
+
VOCAB_FILES_NAMES = {
|
32 |
+
"vocab_file": "rwkv_vocab_v20230424.txt",
|
33 |
+
}
|
34 |
+
|
35 |
+
class TRIE:
|
36 |
+
__slots__ = tuple("ch,to,values,front".split(","))
|
37 |
+
to: list
|
38 |
+
values: set
|
39 |
+
|
40 |
+
def __init__(self, front=None, ch=None):
|
41 |
+
self.ch = ch
|
42 |
+
self.to = [None for ch in range(256)]
|
43 |
+
self.values = set()
|
44 |
+
self.front = front
|
45 |
+
|
46 |
+
def __repr__(self):
|
47 |
+
fr = self
|
48 |
+
ret = []
|
49 |
+
while fr != None:
|
50 |
+
if fr.ch != None:
|
51 |
+
ret.append(fr.ch)
|
52 |
+
fr = fr.front
|
53 |
+
return "<TRIE %s %s>" % (ret[::-1], self.values)
|
54 |
+
|
55 |
+
def add(self, key: bytes, idx: int = 0, val=None):
|
56 |
+
if idx == len(key):
|
57 |
+
if val is None:
|
58 |
+
val = key
|
59 |
+
self.values.add(val)
|
60 |
+
return self
|
61 |
+
ch = key[idx]
|
62 |
+
if self.to[ch] is None:
|
63 |
+
self.to[ch] = TRIE(front=self, ch=ch)
|
64 |
+
return self.to[ch].add(key, idx=idx + 1, val=val)
|
65 |
+
|
66 |
+
def find_longest(self, key: bytes, idx: int = 0):
|
67 |
+
u: TRIE = self
|
68 |
+
ch: int = key[idx]
|
69 |
+
|
70 |
+
while u.to[ch] is not None:
|
71 |
+
u = u.to[ch]
|
72 |
+
idx += 1
|
73 |
+
if u.values:
|
74 |
+
ret = idx, u, u.values
|
75 |
+
if idx == len(key):
|
76 |
+
break
|
77 |
+
ch = key[idx]
|
78 |
+
return ret
|
79 |
+
|
80 |
+
|
81 |
+
class RWKV_TOKENIZER:
|
82 |
+
def __init__(self, file_name):
|
83 |
+
self.idx2token = {}
|
84 |
+
sorted = [] # must be already sorted
|
85 |
+
with open(file_name, "r", encoding="utf-8") as f:
|
86 |
+
lines = f.readlines()
|
87 |
+
for l in lines:
|
88 |
+
idx = int(l[: l.index(" ")])
|
89 |
+
x = eval(l[l.index(" ") : l.rindex(" ")])
|
90 |
+
x = x.encode("utf-8") if isinstance(x, str) else x
|
91 |
+
assert isinstance(x, bytes)
|
92 |
+
|
93 |
+
assert len(x) == int(l[l.rindex(" ") :])
|
94 |
+
sorted += [x]
|
95 |
+
self.idx2token[idx] = x
|
96 |
+
|
97 |
+
self.token2idx = {}
|
98 |
+
for k, v in self.idx2token.items():
|
99 |
+
self.token2idx[v] = int(k)
|
100 |
+
|
101 |
+
self.root = TRIE()
|
102 |
+
for t, i in self.token2idx.items():
|
103 |
+
_ = self.root.add(t, val=(t, i))
|
104 |
+
|
105 |
+
def encodeBytes(self, src: bytes):
|
106 |
+
idx: int = 0
|
107 |
+
tokens = []
|
108 |
+
while idx < len(src):
|
109 |
+
_idx: int = idx
|
110 |
+
idx, _, values = self.root.find_longest(src, idx)
|
111 |
+
assert idx != _idx
|
112 |
+
_, token = next(iter(values))
|
113 |
+
tokens.append(token)
|
114 |
+
return tokens
|
115 |
+
|
116 |
+
def decodeBytes(self, tokens):
|
117 |
+
return b"".join(map(lambda i: self.idx2token[i], tokens))
|
118 |
+
|
119 |
+
def encode(self, src):
|
120 |
+
if isinstance(src, str):
|
121 |
+
return [self.encodeBytes(src.encode("utf-8"))]
|
122 |
+
elif isinstance(src, list):
|
123 |
+
return [self.encodeBytes(s.encode("utf-8")) for s in src]
|
124 |
+
|
125 |
+
def decode(self, tokens):
|
126 |
+
return [self.decodeBytes(batch).decode("utf-8") for batch in tokens]
|
127 |
+
# try:
|
128 |
+
# return self.decodeBytes(tokens).decode('utf-8')
|
129 |
+
# except:
|
130 |
+
# return '\ufffd' # bad utf-8
|
131 |
+
|
132 |
+
def printTokens(self, tokens):
|
133 |
+
for i in tokens:
|
134 |
+
s = self.idx2token[i]
|
135 |
+
try:
|
136 |
+
s = s.decode("utf-8")
|
137 |
+
except:
|
138 |
+
pass
|
139 |
+
print(f"{repr(s)}{i}", end=" ")
|
140 |
+
print()
|
141 |
+
|
142 |
+
|
143 |
+
class RwkvTokenizer(PreTrainedTokenizer):
|
144 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
145 |
+
model_input_names = ["input_ids", "attention_mask"]
|
146 |
+
|
147 |
+
def __init__(
|
148 |
+
self, vocab_file, bos_token="<|rwkv_tokenizer_end_of_text|>", eos_token="<|rwkv_tokenizer_end_of_text|>", unk_token="<|rwkv_tokenizer_end_of_text|>", **kwargs
|
149 |
+
):
|
150 |
+
if not os.path.isfile(vocab_file):
|
151 |
+
raise ValueError(
|
152 |
+
f"Can't find a vocabulary file at path '{vocab_file}'."
|
153 |
+
)
|
154 |
+
|
155 |
+
with open(vocab_file, "r", encoding="utf-8") as reader:
|
156 |
+
tokens = reader.readlines()
|
157 |
+
|
158 |
+
if "add_bos_token" in kwargs:
|
159 |
+
self.add_bos_token = kwargs["add_bos_token"]
|
160 |
+
else:
|
161 |
+
self.add_bos_token = False
|
162 |
+
self.trie_tokenizer = RWKV_TOKENIZER(vocab_file)
|
163 |
+
vocab = self.trie_tokenizer.token2idx
|
164 |
+
self.encoder = vocab
|
165 |
+
self.decoder = {v: k for k, v in vocab.items()}
|
166 |
+
self._added_tokens_decoder = {0: AddedToken(str(bos_token))}
|
167 |
+
super().__init__(
|
168 |
+
bos_token=bos_token, eos_token=eos_token, unk_token=unk_token, **kwargs
|
169 |
+
)
|
170 |
+
|
171 |
+
@property
|
172 |
+
def vocab_size(self):
|
173 |
+
return len(self.encoder)
|
174 |
+
|
175 |
+
def get_vocab(self):
|
176 |
+
vocab = {str(self.convert_ids_to_tokens(i)): i for i in range(self.vocab_size)}
|
177 |
+
vocab.update(self.added_tokens_encoder)
|
178 |
+
return vocab
|
179 |
+
|
180 |
+
def _tokenize(self, text, split_special_tokens=False):
|
181 |
+
# return self.wordpiece_tokenizer.tokenize(text.encode("utf-8"))
|
182 |
+
return self.trie_tokenizer.encode(text)[0]
|
183 |
+
|
184 |
+
def _convert_token_to_id(self, token):
|
185 |
+
return token
|
186 |
+
|
187 |
+
def _convert_id_to_token(self, index):
|
188 |
+
"""Converts an index (integer) in a token (byte) using the vocab."""
|
189 |
+
token = self.decoder.get(index, self.unk_token)
|
190 |
+
if isinstance(token, (bytes)):
|
191 |
+
token = token.decode("utf-8", errors="replace")
|
192 |
+
return token
|
193 |
+
|
194 |
+
def convert_tokens_to_string(self, tokens):
|
195 |
+
"""Converts a sequence of tokens (bytes) in a single string. Additional tokens are encoded to bytes"""
|
196 |
+
out_string = b"".join(
|
197 |
+
[k.encode(errors="replace") if isinstance(k, str) else k for k in tokens]
|
198 |
+
).decode("utf-8")
|
199 |
+
return out_string
|
200 |
+
|
201 |
+
def save_vocabulary(
|
202 |
+
self, save_directory: str, filename_prefix: Optional[str] = None
|
203 |
+
) -> Tuple[str]:
|
204 |
+
index = 0
|
205 |
+
if os.path.isdir(save_directory):
|
206 |
+
vocab_file = os.path.join(
|
207 |
+
save_directory,
|
208 |
+
(filename_prefix + "-" if filename_prefix else "") + "vocab.txt",
|
209 |
+
)
|
210 |
+
else:
|
211 |
+
vocab_file = (
|
212 |
+
filename_prefix + "-" if filename_prefix else ""
|
213 |
+
) + save_directory
|
214 |
+
with open(vocab_file, "w", encoding="utf-8") as writer:
|
215 |
+
for token, token_index in sorted(
|
216 |
+
self.encoder.items(), key=lambda kv: kv[1]
|
217 |
+
):
|
218 |
+
if index != token_index:
|
219 |
+
logger.warning(
|
220 |
+
f"Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive."
|
221 |
+
" Please check that the vocabulary is not corrupted!"
|
222 |
+
)
|
223 |
+
index = token_index
|
224 |
+
writer.write(str(token) + "\n")
|
225 |
+
index += 1
|
226 |
+
return (vocab_file,)
|
227 |
+
|
228 |
+
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
|
229 |
+
if self.add_bos_token:
|
230 |
+
bos_token_ids = [self.bos_token_id]
|
231 |
+
else:
|
232 |
+
bos_token_ids = []
|
233 |
+
|
234 |
+
output = bos_token_ids + token_ids_0
|
235 |
+
|
236 |
+
if token_ids_1 is None:
|
237 |
+
return output
|
238 |
+
|
239 |
+
return output + bos_token_ids + token_ids_1
|
240 |
+
|
241 |
+
def get_special_tokens_mask(
|
242 |
+
self,
|
243 |
+
token_ids_0: List[int],
|
244 |
+
token_ids_1: Optional[List[int]] = None,
|
245 |
+
already_has_special_tokens: bool = False,
|
246 |
+
) -> List[int]:
|
247 |
+
"""
|
248 |
+
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
|
249 |
+
special tokens using the tokenizer `prepare_for_model` or `encode_plus` methods.
|
250 |
+
|
251 |
+
Args:
|
252 |
+
token_ids_0 (`List[int]`):
|
253 |
+
List of IDs.
|
254 |
+
token_ids_1 (`List[int]`, *optional*):
|
255 |
+
Optional second list of IDs for sequence pairs.
|
256 |
+
already_has_special_tokens (`bool`, *optional*, defaults to `False`):
|
257 |
+
Whether or not the token list is already formatted with special tokens for the model.
|
258 |
+
|
259 |
+
Returns:
|
260 |
+
`List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
|
261 |
+
"""
|
262 |
+
if already_has_special_tokens:
|
263 |
+
return super().get_special_tokens_mask(
|
264 |
+
token_ids_0=token_ids_0,
|
265 |
+
token_ids_1=token_ids_1,
|
266 |
+
already_has_special_tokens=True,
|
267 |
+
)
|
268 |
+
|
269 |
+
if not self.add_bos_token:
|
270 |
+
return super().get_special_tokens_mask(
|
271 |
+
token_ids_0=token_ids_0,
|
272 |
+
token_ids_1=token_ids_1,
|
273 |
+
already_has_special_tokens=False,
|
274 |
+
)
|
275 |
+
|
276 |
+
if token_ids_1 is None:
|
277 |
+
return [1] + ([0] * len(token_ids_0))
|
278 |
+
return [1] + ([0] * len(token_ids_0)) + [1] + ([0] * len(token_ids_1))
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/modeling_rwkv7.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fla.models.rwkv7 import RWKV7ForCausalLM, RWKV7Model, RWKV7Config
|
2 |
+
RWKV7ForCausalLM = RWKV7ForCausalLM
|
3 |
+
RWKV7Model = RWKV7Model
|
4 |
+
RWKV7Config = RWKV7Config
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/rwkv_vocab_v20230424.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/special_tokens_map.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<|rwkv_tokenizer_end_of_text|>",
|
3 |
+
"eos_token": "<|rwkv_tokenizer_end_of_text|>",
|
4 |
+
"unk_token": "<|rwkv_tokenizer_end_of_text|>"
|
5 |
+
}
|
CosyVoice2-0.5B_RWKV_1.5B/CosyVoice-BlankEN/tokenizer_config.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": false,
|
3 |
+
"added_tokens_decoder": {
|
4 |
+
"0": {
|
5 |
+
"content": "<|rwkv_tokenizer_end_of_text|>",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": false,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false,
|
10 |
+
"special": true
|
11 |
+
}
|
12 |
+
},
|
13 |
+
"auto_map": {
|
14 |
+
"AutoTokenizer": [
|
15 |
+
"hf_rwkv_tokenizer.RwkvTokenizer",
|
16 |
+
null
|
17 |
+
]
|
18 |
+
},
|
19 |
+
"bos_token": "<|rwkv_tokenizer_end_of_text|>",
|
20 |
+
"clean_up_tokenization_spaces": false,
|
21 |
+
"eos_token": "<|rwkv_tokenizer_end_of_text|>",
|
22 |
+
"model_max_length": 1000000000000000019884624838656,
|
23 |
+
"tokenizer_class": "RwkvTokenizer",
|
24 |
+
"unk_token": "<|rwkv_tokenizer_end_of_text|>",
|
25 |
+
"use_fast": false,
|
26 |
+
"chat_template": "{{ '<|rwkv_tokenizer_end_of_text|>' }}{% for message in messages %}{% if message['role'] == 'user' %}{{'User: ' + message['content'] + '\n\n'}}{% elif message['role'] == 'system' %}{{'System: ' + message['content'] + '\n\n'}}{% elif message['role'] == 'assistant' %}{{'Assistant: ' + message['content'] + '\n\n'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}"
|
27 |
+
}
|
CosyVoice2-0.5B_RWKV_1.5B/README.md
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[](https://github.com/Akshay090/svg-banners)
|
2 |
+
|
3 |
+
## 👉🏻 CosyVoice 👈🏻
|
4 |
+
**CosyVoice 2.0**: [Demos](https://funaudiollm.github.io/cosyvoice2/); [Paper](https://arxiv.org/abs/2412.10117); [Modelscope](https://www.modelscope.cn/studios/iic/CosyVoice2-0.5B); [HuggingFace](https://huggingface.co/spaces/FunAudioLLM/CosyVoice2-0.5B)
|
5 |
+
|
6 |
+
**CosyVoice 1.0**: [Demos](https://fun-audio-llm.github.io); [Paper](https://funaudiollm.github.io/pdf/CosyVoice_v1.pdf); [Modelscope](https://www.modelscope.cn/studios/iic/CosyVoice-300M)
|
7 |
+
|
8 |
+
## Highlight🔥
|
9 |
+
|
10 |
+
**CosyVoice 2.0** has been released! Compared to version 1.0, the new version offers more accurate, more stable, faster, and better speech generation capabilities.
|
11 |
+
### Multilingual
|
12 |
+
- **Supported Language**: Chinese, English, Japanese, Korean, Chinese dialects (Cantonese, Sichuanese, Shanghainese, Tianjinese, Wuhanese, etc.)
|
13 |
+
- **Crosslingual & Mixlingual**:Support zero-shot voice cloning for cross-lingual and code-switching scenarios.
|
14 |
+
### Ultra-Low Latency
|
15 |
+
- **Bidirectional Streaming Support**: CosyVoice 2.0 integrates offline and streaming modeling technologies.
|
16 |
+
- **Rapid First Packet Synthesis**: Achieves latency as low as 150ms while maintaining high-quality audio output.
|
17 |
+
### High Accuracy
|
18 |
+
- **Improved Pronunciation**: Reduces pronunciation errors by 30% to 50% compared to CosyVoice 1.0.
|
19 |
+
- **Benchmark Achievements**: Attains the lowest character error rate on the hard test set of the Seed-TTS evaluation set.
|
20 |
+
### Strong Stability
|
21 |
+
- **Consistency in Timbre**: Ensures reliable voice consistency for zero-shot and cross-language speech synthesis.
|
22 |
+
- **Cross-language Synthesis**: Marked improvements compared to version 1.0.
|
23 |
+
### Natural Experience
|
24 |
+
- **Enhanced Prosody and Sound Quality**: Improved alignment of synthesized audio, raising MOS evaluation scores from 5.4 to 5.53.
|
25 |
+
- **Emotional and Dialectal Flexibility**: Now supports more granular emotional controls and accent adjustments.
|
26 |
+
|
27 |
+
## Roadmap
|
28 |
+
|
29 |
+
- [x] 2024/12
|
30 |
+
|
31 |
+
- [x] 25hz cosyvoice 2.0 released
|
32 |
+
|
33 |
+
- [x] 2024/09
|
34 |
+
|
35 |
+
- [x] 25hz cosyvoice base model
|
36 |
+
- [x] 25hz cosyvoice voice conversion model
|
37 |
+
|
38 |
+
- [x] 2024/08
|
39 |
+
|
40 |
+
- [x] Repetition Aware Sampling(RAS) inference for llm stability
|
41 |
+
- [x] Streaming inference mode support, including kv cache and sdpa for rtf optimization
|
42 |
+
|
43 |
+
- [x] 2024/07
|
44 |
+
|
45 |
+
- [x] Flow matching training support
|
46 |
+
- [x] WeTextProcessing support when ttsfrd is not available
|
47 |
+
- [x] Fastapi server and client
|
48 |
+
|
49 |
+
|
50 |
+
## Install
|
51 |
+
|
52 |
+
**Clone and install**
|
53 |
+
|
54 |
+
- Clone the repo
|
55 |
+
``` sh
|
56 |
+
git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
|
57 |
+
# If you failed to clone submodule due to network failures, please run following command until success
|
58 |
+
cd CosyVoice
|
59 |
+
git submodule update --init --recursive
|
60 |
+
```
|
61 |
+
|
62 |
+
- Install Conda: please see https://docs.conda.io/en/latest/miniconda.html
|
63 |
+
- Create Conda env:
|
64 |
+
|
65 |
+
``` sh
|
66 |
+
conda create -n cosyvoice python=3.10
|
67 |
+
conda activate cosyvoice
|
68 |
+
# pynini is required by WeTextProcessing, use conda to install it as it can be executed on all platform.
|
69 |
+
conda install -y -c conda-forge pynini==2.1.5
|
70 |
+
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
|
71 |
+
|
72 |
+
# If you encounter sox compatibility issues
|
73 |
+
# ubuntu
|
74 |
+
sudo apt-get install sox libsox-dev
|
75 |
+
# centos
|
76 |
+
sudo yum install sox sox-devel
|
77 |
+
```
|
78 |
+
|
79 |
+
**Model download**
|
80 |
+
|
81 |
+
We strongly recommend that you download our pretrained `CosyVoice2-0.5B` `CosyVoice-300M` `CosyVoice-300M-SFT` `CosyVoice-300M-Instruct` model and `CosyVoice-ttsfrd` resource.
|
82 |
+
|
83 |
+
``` python
|
84 |
+
# SDK模型下载
|
85 |
+
from modelscope import snapshot_download
|
86 |
+
snapshot_download('iic/CosyVoice2-0.5B', local_dir='pretrained_models/CosyVoice2-0.5B')
|
87 |
+
snapshot_download('iic/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')
|
88 |
+
snapshot_download('iic/CosyVoice-300M-25Hz', local_dir='pretrained_models/CosyVoice-300M-25Hz')
|
89 |
+
snapshot_download('iic/CosyVoice-300M-SFT', local_dir='pretrained_models/CosyVoice-300M-SFT')
|
90 |
+
snapshot_download('iic/CosyVoice-300M-Instruct', local_dir='pretrained_models/CosyVoice-300M-Instruct')
|
91 |
+
snapshot_download('iic/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')
|
92 |
+
```
|
93 |
+
|
94 |
+
``` sh
|
95 |
+
# git模型下载,请确保已安装git lfs
|
96 |
+
mkdir -p pretrained_models
|
97 |
+
git clone https://www.modelscope.cn/iic/CosyVoice2-0.5B.git pretrained_models/CosyVoice2-0.5B
|
98 |
+
git clone https://www.modelscope.cn/iic/CosyVoice-300M.git pretrained_models/CosyVoice-300M
|
99 |
+
git clone https://www.modelscope.cn/iic/CosyVoice-300M-25Hz.git pretrained_models/CosyVoice-300M-25Hz
|
100 |
+
git clone https://www.modelscope.cn/iic/CosyVoice-300M-SFT.git pretrained_models/CosyVoice-300M-SFT
|
101 |
+
git clone https://www.modelscope.cn/iic/CosyVoice-300M-Instruct.git pretrained_models/CosyVoice-300M-Instruct
|
102 |
+
git clone https://www.modelscope.cn/iic/CosyVoice-ttsfrd.git pretrained_models/CosyVoice-ttsfrd
|
103 |
+
```
|
104 |
+
|
105 |
+
Optionally, you can unzip `ttsfrd` resouce and install `ttsfrd` package for better text normalization performance.
|
106 |
+
|
107 |
+
Notice that this step is not necessary. If you do not install `ttsfrd` package, we will use WeTextProcessing by default.
|
108 |
+
|
109 |
+
``` sh
|
110 |
+
cd pretrained_models/CosyVoice-ttsfrd/
|
111 |
+
unzip resource.zip -d .
|
112 |
+
pip install ttsfrd_dependency-0.1-py3-none-any.whl
|
113 |
+
pip install ttsfrd-0.4.2-cp310-cp310-linux_x86_64.whl
|
114 |
+
```
|
115 |
+
|
116 |
+
**Basic Usage**
|
117 |
+
|
118 |
+
We strongly recommend using `CosyVoice2-0.5B` for better performance.
|
119 |
+
Follow code below for detailed usage of each model.
|
120 |
+
|
121 |
+
``` python
|
122 |
+
import sys
|
123 |
+
sys.path.append('third_party/Matcha-TTS')
|
124 |
+
from cosyvoice.cli.cosyvoice import CosyVoice, CosyVoice2
|
125 |
+
from cosyvoice.utils.file_utils import load_wav
|
126 |
+
import torchaudio
|
127 |
+
```
|
128 |
+
|
129 |
+
**CosyVoice2 Usage**
|
130 |
+
```python
|
131 |
+
cosyvoice = CosyVoice2('pretrained_models/CosyVoice2-0.5B', load_jit=False, load_trt=False, fp16=False)
|
132 |
+
|
133 |
+
# NOTE if you want to reproduce the results on https://funaudiollm.github.io/cosyvoice2, please add text_frontend=False during inference
|
134 |
+
# zero_shot usage
|
135 |
+
prompt_speech_16k = load_wav('zero_shot_prompt.wav', 16000)
|
136 |
+
for i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', prompt_speech_16k, stream=False)):
|
137 |
+
torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
138 |
+
|
139 |
+
# fine grained control, for supported control, check cosyvoice/tokenizer/tokenizer.py#L248
|
140 |
+
for i, j in enumerate(cosyvoice.inference_cross_lingual('在他讲述那个荒诞故事的过程中,他突然[laughter]停下来,因为他自己也被逗笑了[laughter]。', prompt_speech_16k, stream=False)):
|
141 |
+
torchaudio.save('fine_grained_control_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
142 |
+
|
143 |
+
# instruct usage
|
144 |
+
for i, j in enumerate(cosyvoice.inference_instruct2('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '用四川话说这句话', prompt_speech_16k, stream=False)):
|
145 |
+
torchaudio.save('instruct_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
146 |
+
```
|
147 |
+
|
148 |
+
**CosyVoice Usage**
|
149 |
+
```python
|
150 |
+
cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-SFT', load_jit=False, load_trt=False, fp16=False)
|
151 |
+
# sft usage
|
152 |
+
print(cosyvoice.list_available_spks())
|
153 |
+
# change stream=True for chunk stream inference
|
154 |
+
for i, j in enumerate(cosyvoice.inference_sft('你好,我是通义生成式语音大模型,请问有什么可以帮您的吗?', '中文女', stream=False)):
|
155 |
+
torchaudio.save('sft_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
156 |
+
|
157 |
+
cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M') # or change to pretrained_models/CosyVoice-300M-25Hz for 25Hz inference
|
158 |
+
# zero_shot usage, <|zh|><|en|><|jp|><|yue|><|ko|> for Chinese/English/Japanese/Cantonese/Korean
|
159 |
+
prompt_speech_16k = load_wav('zero_shot_prompt.wav', 16000)
|
160 |
+
for i, j in enumerate(cosyvoice.inference_zero_shot('收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。', '希望你以后能够做的比我还好呦。', prompt_speech_16k, stream=False)):
|
161 |
+
torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
162 |
+
# cross_lingual usage
|
163 |
+
prompt_speech_16k = load_wav('cross_lingual_prompt.wav', 16000)
|
164 |
+
for i, j in enumerate(cosyvoice.inference_cross_lingual('<|en|>And then later on, fully acquiring that company. So keeping management in line, interest in line with the asset that\'s coming into the family is a reason why sometimes we don\'t buy the whole thing.', prompt_speech_16k, stream=False)):
|
165 |
+
torchaudio.save('cross_lingual_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
166 |
+
# vc usage
|
167 |
+
prompt_speech_16k = load_wav('zero_shot_prompt.wav', 16000)
|
168 |
+
source_speech_16k = load_wav('cross_lingual_prompt.wav', 16000)
|
169 |
+
for i, j in enumerate(cosyvoice.inference_vc(source_speech_16k, prompt_speech_16k, stream=False)):
|
170 |
+
torchaudio.save('vc_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
171 |
+
|
172 |
+
cosyvoice = CosyVoice('pretrained_models/CosyVoice-300M-Instruct')
|
173 |
+
# instruct usage, support <laughter></laughter><strong></strong>[laughter][breath]
|
174 |
+
for i, j in enumerate(cosyvoice.inference_instruct('在面对挑战时,他展现了非凡的<strong>勇气</strong>与<strong>智慧</strong>。', '中文男', 'Theo \'Crimson\', is a fiery, passionate rebel leader. Fights with fervor for justice, but struggles with impulsiveness.', stream=False)):
|
175 |
+
torchaudio.save('instruct_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
|
176 |
+
```
|
177 |
+
|
178 |
+
**Start web demo**
|
179 |
+
|
180 |
+
You can use our web demo page to get familiar with CosyVoice quickly.
|
181 |
+
|
182 |
+
Please see the demo website for details.
|
183 |
+
|
184 |
+
``` python
|
185 |
+
# change iic/CosyVoice-300M-SFT for sft inference, or iic/CosyVoice-300M-Instruct for instruct inference
|
186 |
+
python3 webui.py --port 50000 --model_dir pretrained_models/CosyVoice-300M
|
187 |
+
```
|
188 |
+
|
189 |
+
**Advanced Usage**
|
190 |
+
|
191 |
+
For advanced user, we have provided train and inference scripts in `examples/libritts/cosyvoice/run.sh`.
|
192 |
+
|
193 |
+
**Build for deployment**
|
194 |
+
|
195 |
+
Optionally, if you want service deployment,
|
196 |
+
you can run following steps.
|
197 |
+
|
198 |
+
``` sh
|
199 |
+
cd runtime/python
|
200 |
+
docker build -t cosyvoice:v1.0 .
|
201 |
+
# change iic/CosyVoice-300M to iic/CosyVoice-300M-Instruct if you want to use instruct inference
|
202 |
+
# for grpc usage
|
203 |
+
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/grpc && python3 server.py --port 50000 --max_conc 4 --model_dir iic/CosyVoice-300M && sleep infinity"
|
204 |
+
cd grpc && python3 client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
|
205 |
+
# for fastapi usage
|
206 |
+
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/fastapi && python3 server.py --port 50000 --model_dir iic/CosyVoice-300M && sleep infinity"
|
207 |
+
cd fastapi && python3 client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
|
208 |
+
```
|
209 |
+
|
210 |
+
## Discussion & Communication
|
211 |
+
|
212 |
+
You can directly discuss on [Github Issues](https://github.com/FunAudioLLM/CosyVoice/issues).
|
213 |
+
|
214 |
+
You can also scan the QR code to join our official Dingding chat group.
|
215 |
+
|
216 |
+
<img src="./asset/dingding.png" width="250px">
|
217 |
+
|
218 |
+
## Acknowledge
|
219 |
+
|
220 |
+
1. We borrowed a lot of code from [FunASR](https://github.com/modelscope/FunASR).
|
221 |
+
2. We borrowed a lot of code from [FunCodec](https://github.com/modelscope/FunCodec).
|
222 |
+
3. We borrowed a lot of code from [Matcha-TTS](https://github.com/shivammehta25/Matcha-TTS).
|
223 |
+
4. We borrowed a lot of code from [AcademiCodec](https://github.com/yangdongchao/AcademiCodec).
|
224 |
+
5. We borrowed a lot of code from [WeNet](https://github.com/wenet-e2e/wenet).
|
225 |
+
|
226 |
+
## Disclaimer
|
227 |
+
The content provided above is for academic purposes only and is intended to demonstrate technical capabilities. Some examples are sourced from the internet. If any content infringes on your rights, please contact us to request its removal.
|
CosyVoice2-0.5B_RWKV_1.5B/asset/dingding.png
ADDED
![]() |
CosyVoice2-0.5B_RWKV_1.5B/campplus.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a6ac6a63997761ae2997373e2ee1c47040854b4b759ea41ec48e4e42df0f4d73
|
3 |
+
size 28303423
|
CosyVoice2-0.5B_RWKV_1.5B/configuration.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"framework":"Pytorch","task":"text-to-speech"}
|
CosyVoice2-0.5B_RWKV_1.5B/cosyvoice.yaml
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# set random seed, so that you may reproduce your result.
|
2 |
+
#__set_seed1: !apply:random.seed [1986]
|
3 |
+
#__set_seed2: !apply:numpy.random.seed [1986]
|
4 |
+
#__set_seed3: !apply:torch.manual_seed [1986]
|
5 |
+
#__set_seed4: !apply:torch.cuda.manual_seed_all [1986]
|
6 |
+
|
7 |
+
# fixed params
|
8 |
+
sample_rate: 24000
|
9 |
+
llm_input_size: 2048
|
10 |
+
llm_output_size: 2048
|
11 |
+
spk_embed_dim: 192
|
12 |
+
qwen_pretrain_path: ''
|
13 |
+
|
14 |
+
# model params
|
15 |
+
# for all class/function included in this repo, we use !<name> or !<new> for intialization, so that user may find all corresponding class/function according to one single yaml.
|
16 |
+
# for system/third_party class/function, we do not require this.
|
17 |
+
llm: !new:model.llm.llm.RWKV7LM
|
18 |
+
llm_input_size: !ref <llm_input_size>
|
19 |
+
llm_output_size: !ref <llm_output_size>
|
20 |
+
speech_token_size: 6561
|
21 |
+
length_normalized_loss: True
|
22 |
+
lsm_weight: 0
|
23 |
+
llm: !ref <qwen_pretrain_path>
|
24 |
+
sampling: !name:cosyvoice.utils.common.ras_sampling
|
25 |
+
top_p: 0.8
|
26 |
+
top_k: 25
|
27 |
+
win_size: 10
|
28 |
+
tau_r: 0.1
|
29 |
+
|
30 |
+
flow: !new:cosyvoice.flow.flow.CausalMaskedDiffWithXvec
|
31 |
+
input_size: 512
|
32 |
+
output_size: 80
|
33 |
+
spk_embed_dim: !ref <spk_embed_dim>
|
34 |
+
output_type: 'mel'
|
35 |
+
vocab_size: 6561
|
36 |
+
input_frame_rate: 25
|
37 |
+
only_mask_loss: True
|
38 |
+
token_mel_ratio: 2
|
39 |
+
pre_lookahead_len: 3
|
40 |
+
encoder: !new:cosyvoice.transformer.upsample_encoder.UpsampleConformerEncoder
|
41 |
+
output_size: 512
|
42 |
+
attention_heads: 8
|
43 |
+
linear_units: 2048
|
44 |
+
num_blocks: 6
|
45 |
+
dropout_rate: 0.1
|
46 |
+
positional_dropout_rate: 0.1
|
47 |
+
attention_dropout_rate: 0.1
|
48 |
+
normalize_before: True
|
49 |
+
input_layer: 'linear'
|
50 |
+
pos_enc_layer_type: 'rel_pos_espnet'
|
51 |
+
selfattention_layer_type: 'rel_selfattn'
|
52 |
+
input_size: 512
|
53 |
+
use_cnn_module: False
|
54 |
+
macaron_style: False
|
55 |
+
decoder: !new:cosyvoice.flow.flow_matching.CausalConditionalCFM
|
56 |
+
in_channels: 240
|
57 |
+
n_spks: 1
|
58 |
+
spk_emb_dim: 80
|
59 |
+
cfm_params: !new:omegaconf.DictConfig
|
60 |
+
content:
|
61 |
+
sigma_min: 1e-06
|
62 |
+
solver: 'euler'
|
63 |
+
t_scheduler: 'cosine'
|
64 |
+
training_cfg_rate: 0.2
|
65 |
+
inference_cfg_rate: 0.7
|
66 |
+
reg_loss_type: 'l1'
|
67 |
+
estimator: !new:cosyvoice.flow.decoder.ConditionalDecoder
|
68 |
+
in_channels: 320
|
69 |
+
out_channels: 80
|
70 |
+
causal: True
|
71 |
+
channels: [256]
|
72 |
+
dropout: 0.0
|
73 |
+
attention_head_dim: 64
|
74 |
+
n_blocks: 4
|
75 |
+
num_mid_blocks: 12
|
76 |
+
num_heads: 8
|
77 |
+
act_fn: 'gelu'
|
78 |
+
|
79 |
+
hift: !new:cosyvoice.hifigan.generator.HiFTGenerator
|
80 |
+
in_channels: 80
|
81 |
+
base_channels: 512
|
82 |
+
nb_harmonics: 8
|
83 |
+
sampling_rate: !ref <sample_rate>
|
84 |
+
nsf_alpha: 0.1
|
85 |
+
nsf_sigma: 0.003
|
86 |
+
nsf_voiced_threshold: 10
|
87 |
+
upsample_rates: [8, 5, 3]
|
88 |
+
upsample_kernel_sizes: [16, 11, 7]
|
89 |
+
istft_params:
|
90 |
+
n_fft: 16
|
91 |
+
hop_len: 4
|
92 |
+
resblock_kernel_sizes: [3, 7, 11]
|
93 |
+
resblock_dilation_sizes: [[1, 3, 5], [1, 3, 5], [1, 3, 5]]
|
94 |
+
source_resblock_kernel_sizes: [7, 7, 11]
|
95 |
+
source_resblock_dilation_sizes: [[1, 3, 5], [1, 3, 5], [1, 3, 5]]
|
96 |
+
lrelu_slope: 0.1
|
97 |
+
audio_limit: 0.99
|
98 |
+
f0_predictor: !new:cosyvoice.hifigan.f0_predictor.ConvRNNF0Predictor
|
99 |
+
num_class: 1
|
100 |
+
in_channels: 80
|
101 |
+
cond_channels: 512
|
102 |
+
|
103 |
+
# processor functions
|
104 |
+
parquet_opener: !name:cosyvoice.dataset.processor.parquet_opener
|
105 |
+
get_tokenizer: !name:utils.utilities.get_tokenizer
|
106 |
+
model_dir: !ref <qwen_pretrain_path>
|
107 |
+
allowed_special: 'all'
|
108 |
+
tokenize: !name:cosyvoice.dataset.processor.tokenize
|
109 |
+
get_tokenizer: !ref <get_tokenizer>
|
110 |
+
allowed_special: !ref <allowed_special>
|
111 |
+
filter: !name:cosyvoice.dataset.processor.filter
|
112 |
+
max_length: 40960
|
113 |
+
min_length: 0
|
114 |
+
token_max_length: 200
|
115 |
+
token_min_length: 1
|
116 |
+
resample: !name:cosyvoice.dataset.processor.resample
|
117 |
+
resample_rate: !ref <sample_rate>
|
118 |
+
feat_extractor: !name:matcha.utils.audio.mel_spectrogram
|
119 |
+
n_fft: 1920
|
120 |
+
num_mels: 80
|
121 |
+
sampling_rate: !ref <sample_rate>
|
122 |
+
hop_size: 480
|
123 |
+
win_size: 1920
|
124 |
+
fmin: 0
|
125 |
+
fmax: 8000
|
126 |
+
center: False
|
127 |
+
compute_fbank: !name:cosyvoice.dataset.processor.compute_fbank
|
128 |
+
feat_extractor: !ref <feat_extractor>
|
129 |
+
parse_embedding: !name:cosyvoice.dataset.processor.parse_embedding
|
130 |
+
normalize: True
|
131 |
+
shuffle: !name:cosyvoice.dataset.processor.shuffle
|
132 |
+
shuffle_size: 1000
|
133 |
+
sort: !name:cosyvoice.dataset.processor.sort
|
134 |
+
sort_size: 500 # sort_size should be less than shuffle_size
|
135 |
+
batch: !name:cosyvoice.dataset.processor.batch
|
136 |
+
batch_type: 'dynamic'
|
137 |
+
max_frames_in_batch: 2000
|
138 |
+
padding: !name:cosyvoice.dataset.processor.padding
|
CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.a10.plan
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6f6b9073bd9e7b8ac5bef0a21431391cbc32376b9265ec73935d6f28a0d32d01
|
3 |
+
size 168597292
|
CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.l20.plan
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:012df9e730e36e1cb61bf2780378c15ae92c536ae87518b7a54a90026cb99385
|
3 |
+
size 166520788
|
CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp16.v100.plan
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f231edf01451fafbc3dc0498a51feb3a264afad43275536c8151fff954ef3c56
|
3 |
+
size 161799540
|
CosyVoice2-0.5B_RWKV_1.5B/flow.decoder.estimator.fp32.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:51aed3efa2c153898ea53a780893c920e968dab1d7aec25402bd6c9815d94702
|
3 |
+
size 286521895
|
CosyVoice2-0.5B_RWKV_1.5B/flow.encoder.fp16.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:46d2539ad8bdb90026cd50cb42e45bd389f10108111d742b912feddca105aeb6
|
3 |
+
size 116703414
|
CosyVoice2-0.5B_RWKV_1.5B/flow.encoder.fp32.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:32ac668741e1358123d3c066cfd1f68a81bd386028755be9831509e304bfd98c
|
3 |
+
size 192365750
|
CosyVoice2-0.5B_RWKV_1.5B/flow.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff4c2f867674411e0a08cee702996df13fa67c1cd864c06108da88d16d088541
|
3 |
+
size 450575567
|
CosyVoice2-0.5B_RWKV_1.5B/hift.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d4af0d661a416c69544eec83ff9c070dc80c37ee53ef44af3a37d910c95bc21
|
3 |
+
size 83364158
|
CosyVoice2-0.5B_RWKV_1.5B/llm.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:86afba86da5bfce84dec57722f8ebe70cef334b66c3a16e1bcd2a0628bb6a35d
|
3 |
+
size 6217253422
|
CosyVoice2-0.5B_RWKV_1.5B/speech_tokenizer_v2.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d43342aa12163a80bf07bffb94c9de2e120a8df2f9917cd2f642e7f4219c6f71
|
3 |
+
size 496082973
|