kadirnar commited on
Commit
c9738ad
·
verified ·
1 Parent(s): 5ce7396

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +157 -197
README.md CHANGED
@@ -1,200 +1,160 @@
1
  ---
 
 
 
 
 
 
 
 
2
  library_name: transformers
3
- tags:
4
- - unsloth
5
  ---
6
-
7
- # Model Card for Model ID
8
-
9
- <!-- Provide a quick summary of what the model is/does. -->
10
-
11
-
12
-
13
- ## Model Details
14
-
15
- ### Model Description
16
-
17
- <!-- Provide a longer summary of what this model is. -->
18
-
19
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
20
-
21
- - **Developed by:** [More Information Needed]
22
- - **Funded by [optional]:** [More Information Needed]
23
- - **Shared by [optional]:** [More Information Needed]
24
- - **Model type:** [More Information Needed]
25
- - **Language(s) (NLP):** [More Information Needed]
26
- - **License:** [More Information Needed]
27
- - **Finetuned from model [optional]:** [More Information Needed]
28
-
29
- ### Model Sources [optional]
30
-
31
- <!-- Provide the basic links for the model. -->
32
-
33
- - **Repository:** [More Information Needed]
34
- - **Paper [optional]:** [More Information Needed]
35
- - **Demo [optional]:** [More Information Needed]
36
-
37
- ## Uses
38
-
39
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
40
-
41
- ### Direct Use
42
-
43
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
44
-
45
- [More Information Needed]
46
-
47
- ### Downstream Use [optional]
48
-
49
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
50
-
51
- [More Information Needed]
52
-
53
- ### Out-of-Scope Use
54
-
55
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
56
-
57
- [More Information Needed]
58
-
59
- ## Bias, Risks, and Limitations
60
-
61
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
62
-
63
- [More Information Needed]
64
-
65
- ### Recommendations
66
-
67
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
68
-
69
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
70
-
71
- ## How to Get Started with the Model
72
-
73
- Use the code below to get started with the model.
74
-
75
- [More Information Needed]
76
-
77
- ## Training Details
78
-
79
- ### Training Data
80
-
81
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
82
-
83
- [More Information Needed]
84
-
85
- ### Training Procedure
86
-
87
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
88
-
89
- #### Preprocessing [optional]
90
-
91
- [More Information Needed]
92
-
93
-
94
- #### Training Hyperparameters
95
-
96
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
97
-
98
- #### Speeds, Sizes, Times [optional]
99
-
100
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
101
-
102
- [More Information Needed]
103
-
104
- ## Evaluation
105
-
106
- <!-- This section describes the evaluation protocols and provides the results. -->
107
-
108
- ### Testing Data, Factors & Metrics
109
-
110
- #### Testing Data
111
-
112
- <!-- This should link to a Dataset Card if possible. -->
113
-
114
- [More Information Needed]
115
-
116
- #### Factors
117
-
118
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
119
-
120
- [More Information Needed]
121
-
122
- #### Metrics
123
-
124
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
125
-
126
- [More Information Needed]
127
-
128
- ### Results
129
-
130
- [More Information Needed]
131
-
132
- #### Summary
133
-
134
-
135
-
136
- ## Model Examination [optional]
137
-
138
- <!-- Relevant interpretability work for the model goes here -->
139
-
140
- [More Information Needed]
141
-
142
- ## Environmental Impact
143
-
144
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
145
-
146
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
147
-
148
- - **Hardware Type:** [More Information Needed]
149
- - **Hours used:** [More Information Needed]
150
- - **Cloud Provider:** [More Information Needed]
151
- - **Compute Region:** [More Information Needed]
152
- - **Carbon Emitted:** [More Information Needed]
153
-
154
- ## Technical Specifications [optional]
155
-
156
- ### Model Architecture and Objective
157
-
158
- [More Information Needed]
159
-
160
- ### Compute Infrastructure
161
-
162
- [More Information Needed]
163
-
164
- #### Hardware
165
-
166
- [More Information Needed]
167
-
168
- #### Software
169
-
170
- [More Information Needed]
171
-
172
- ## Citation [optional]
173
-
174
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
175
-
176
- **BibTeX:**
177
-
178
- [More Information Needed]
179
-
180
- **APA:**
181
-
182
- [More Information Needed]
183
-
184
- ## Glossary [optional]
185
-
186
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
187
-
188
- [More Information Needed]
189
-
190
- ## More Information [optional]
191
-
192
- [More Information Needed]
193
-
194
- ## Model Card Authors [optional]
195
-
196
- [More Information Needed]
197
-
198
- ## Model Card Contact
199
-
200
- [More Information Needed]
 
1
  ---
2
+ license: cc-by-nc-4.0
3
+ datasets:
4
+ - amphion/Emilia-Dataset
5
+ language:
6
+ - en
7
+ base_model:
8
+ - LiquidAI/LFM2-350M
9
+ pipeline_tag: text-to-speech
10
  library_name: transformers
 
 
11
  ---
12
+ ## Overview
13
+ VyvoTTS-LFM2-350M is a Text-to-Speech model based on LFM2-350M, trained to produce natural-sounding English speech.
14
+
15
+ - **Type:** Text-to-Speech
16
+ - **Language:** English
17
+ - **License:** CC BY-NC 4.0
18
+ - **Params:** ~383M
19
+
20
+ ## Usage
21
+ Below is an example of using the model with `unsloth` and `SNAC` for speech generation:
22
+
23
+ ```python
24
+ from unsloth import FastLanguageModel
25
+ import torch
26
+ from snac import SNAC
27
+
28
+ model, tokenizer = FastLanguageModel.from_pretrained(
29
+ model_name = "Vyvo/VyvoTTS-LFM2-Itto",
30
+ max_seq_length= 8192,
31
+ dtype = None,
32
+ load_in_4bit = False,
33
+ )
34
+ snac_model = SNAC.from_pretrained("hubertsiuzdak/snac_24khz")
35
+ tokeniser_length = 64400
36
+ start_of_text = 1
37
+ end_of_text = 7
38
+
39
+ start_of_speech = tokeniser_length + 1
40
+ end_of_speech = tokeniser_length + 2
41
+ start_of_human = tokeniser_length + 3
42
+ end_of_human = tokeniser_length + 4
43
+ pad_token = tokeniser_length + 7
44
+
45
+ audio_tokens_start = tokeniser_length + 10
46
+ prompts = ["Hey there my name is Elise, and I'm a speech generation model that can sound like a person."]
47
+ chosen_voice = None
48
+
49
+ FastLanguageModel.for_inference(model)
50
+ snac_model.to("cpu")
51
+ prompts_ = [(f"{chosen_voice}: " + p) if chosen_voice else p for p in prompts]
52
+
53
+ all_input_ids = []
54
+ for prompt in prompts_:
55
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids
56
+ all_input_ids.append(input_ids)
57
+
58
+ start_token = torch.tensor([[start_of_human]], dtype=torch.int64)
59
+ end_tokens = torch.tensor([[end_of_text, end_of_human]], dtype=torch.int64)
60
+
61
+ all_modified_input_ids = []
62
+ for input_ids in all_input_ids:
63
+ modified_input_ids = torch.cat([start_token, input_ids, end_tokens], dim=1)
64
+ all_modified_input_ids.append(modified_input_ids)
65
+
66
+ all_padded_tensors, all_attention_masks = [], []
67
+ max_length = max([m.shape[1] for m in all_modified_input_ids])
68
+ for m in all_modified_input_ids:
69
+ padding = max_length - m.shape[1]
70
+ padded_tensor = torch.cat([torch.full((1, padding), pad_token, dtype=torch.int64), m], dim=1)
71
+ attention_mask = torch.cat([torch.zeros((1, padding), dtype=torch.int64), torch.ones((1, m.shape[1]), dtype=torch.int64)], dim=1)
72
+ all_padded_tensors.append(padded_tensor)
73
+ all_attention_masks.append(attention_mask)
74
+
75
+ input_ids = torch.cat(all_padded_tensors, dim=0).to("cuda")
76
+ attention_mask = torch.cat(all_attention_masks, dim=0).to("cuda")
77
+
78
+ generated_ids = model.generate(
79
+ input_ids=input_ids,
80
+ attention_mask=attention_mask,
81
+ max_new_tokens=1200,
82
+ do_sample=True,
83
+ temperature=0.6,
84
+ top_p=0.95,
85
+ repetition_penalty=1.1,
86
+ num_return_sequences=1,
87
+ eos_token_id=end_of_speech,
88
+ use_cache=True
89
+ )
90
+
91
+ token_to_find = start_of_speech
92
+ token_to_remove = end_of_speech
93
+ token_indices = (generated_ids == token_to_find).nonzero(as_tuple=True)
94
+
95
+ if len(token_indices[1]) > 0:
96
+ last_occurrence_idx = token_indices[1][-1].item()
97
+ cropped_tensor = generated_ids[:, last_occurrence_idx+1:]
98
+ else:
99
+ cropped_tensor = generated_ids
100
+
101
+ processed_rows = []
102
+ for row in cropped_tensor:
103
+ masked_row = row[row != token_to_remove]
104
+ processed_rows.append(masked_row)
105
+
106
+ code_lists = []
107
+ for row in processed_rows:
108
+ row_length = row.size(0)
109
+ new_length = (row_length // 7) * 7
110
+ trimmed_row = row[:new_length]
111
+ trimmed_row = [t - audio_tokens_start for t in trimmed_row]
112
+ code_lists.append(trimmed_row)
113
+
114
+ def redistribute_codes(code_list):
115
+ layer_1, layer_2, layer_3 = [], [], []
116
+ for i in range((len(code_list)+1)//7):
117
+ layer_1.append(code_list[7*i])
118
+ layer_2.append(code_list[7*i+1]-4096)
119
+ layer_3.append(code_list[7*i+2]-(2*4096))
120
+ layer_3.append(code_list[7*i+3]-(3*4096))
121
+ layer_2.append(code_list[7*i+4]-(4*4096))
122
+ layer_3.append(code_list[7*i+5]-(5*4096))
123
+ layer_3.append(code_list[7*i+6]-(6*4096))
124
+ codes = [
125
+ torch.tensor(layer_1).unsqueeze(0),
126
+ torch.tensor(layer_2).unsqueeze(0),
127
+ torch.tensor(layer_3).unsqueeze(0)
128
+ ]
129
+ audio_hat = snac_model.decode(codes)
130
+ return audio_hat
131
+
132
+ my_samples = []
133
+ for code_list in code_lists:
134
+ samples = redistribute_codes(code_list)
135
+ my_samples.append(samples)
136
+
137
+ from IPython.display import display, Audio
138
+ if len(prompts) != len(my_samples):
139
+ raise Exception("Number of prompts and samples do not match")
140
+ else:
141
+ for i in range(len(my_samples)):
142
+ print(prompts[i])
143
+ samples = my_samples[i]
144
+ display(Audio(samples.detach().squeeze().to("cpu").numpy(), rate=24000))
145
+
146
+ del my_samples, samples
147
+ ```
148
+
149
+ ## Citation
150
+
151
+ If you use this model, please cite:
152
+
153
+ ```bibtex
154
+ @misc{VyvoTTS-LFM2-350M,
155
+ title={VyvoTTS-LFM2-350M},
156
+ author={Vyvo},
157
+ year={2025},
158
+ howpublished={\url{https://huggingface.co/Vyvo/VyvoTTS-LFM2-350M}}
159
+ }
160
+ ```