Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,116 @@
|
|
1 |
-
|
2 |
-
library_name: transformers
|
3 |
-
tags: []
|
4 |
-
---
|
5 |
-
|
6 |
-
# Model Card for Model ID
|
7 |
-
|
8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
## Model Details
|
13 |
-
|
14 |
-
### Model Description
|
15 |
-
|
16 |
-
<!-- Provide a longer summary of what this model is. -->
|
17 |
-
|
18 |
-
This is the model card of a π€ transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
-
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
-
|
36 |
-
## Uses
|
37 |
-
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
-
### Direct Use
|
41 |
-
|
42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
-
|
52 |
-
### Out-of-Scope Use
|
53 |
-
|
54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
-
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
-
|
60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
-
|
62 |
-
[More Information Needed]
|
63 |
-
|
64 |
-
### Recommendations
|
65 |
-
|
66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
|
|
|
133 |
|
|
|
134 |
|
135 |
-
##
|
136 |
|
137 |
-
|
138 |
|
139 |
-
|
140 |
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
144 |
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
|
153 |
-
|
154 |
|
155 |
-
###
|
156 |
|
157 |
-
|
|
|
|
|
|
|
158 |
|
159 |
-
|
|
|
|
|
|
|
160 |
|
161 |
-
|
|
|
162 |
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
|
166 |
|
167 |
-
|
168 |
|
169 |
-
|
|
|
|
|
170 |
|
171 |
-
|
|
|
|
|
172 |
|
173 |
-
|
|
|
|
|
174 |
|
175 |
-
|
176 |
|
177 |
-
|
178 |
|
179 |
-
|
180 |
|
181 |
-
|
|
|
182 |
|
183 |
-
|
184 |
|
185 |
-
|
186 |
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
-
|
190 |
|
191 |
-
|
192 |
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
-
|
196 |
|
197 |
-
##
|
198 |
|
199 |
-
[
|
|
|
|
|
|
1 |
+
# TinyWave Base Speech 2B
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
**TinyWave Base Speech 2B** is a compact speech-to-speech generation model distilled from the 7B SPIRIT-LM-Base teacher. It uses HuBERT-based phonetic tokens for efficient, high-quality speech generation and is optimized for **fast inference** on **commodity hardware**.
|
4 |
|
5 |
+
This model focuses on generating semantically coherent speech continuations without expressive modulation (e.g., pitch/style tokens). It is ideal for **low-resource speech agents**, **instruction-following speech bots**, and **embedded systems**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
> π See the [TinyWave paper (arXiv:2506.23670)](https://arxiv.org/abs/2506.23670) and [demo site](https://mohammadmahdinoori.github.io/tinywave-landing/) for more details.
|
8 |
|
9 |
+
---
|
10 |
|
11 |
+
## π§ Usage
|
12 |
|
13 |
+
This model requires **SPIRIT-LM's base speech tokenizer**, which uses HuBERT units without pitch/style tokens.
|
14 |
|
15 |
+
### 1. Clone SPIRIT-LM and Install Requirements
|
16 |
|
17 |
+
```bash
|
18 |
+
git clone https://github.com/facebookresearch/spiritlm
|
19 |
+
cd spiritlm
|
20 |
+
pip install -e '.[eval]'
|
21 |
+
````
|
22 |
|
23 |
+
---
|
24 |
|
25 |
+
### 2. Load Tokenizer
|
26 |
|
27 |
+
```python
|
28 |
+
from spiritlm.speech_tokenizer import spiritlm_base
|
29 |
+
speech_tokenizer = spiritlm_base()
|
30 |
+
```
|
|
|
31 |
|
32 |
+
---
|
33 |
|
34 |
+
### 3. Inference Code (Speech-to-Speech)
|
35 |
|
36 |
+
```python
|
37 |
+
from transformers import LlamaForCausalLM, AutoTokenizer
|
38 |
+
import torchaudio
|
39 |
+
import torch
|
40 |
|
41 |
+
# Load model and tokenizer
|
42 |
+
MODEL_PATH = "tinywave/speech-base-2b"
|
43 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
44 |
+
model = LlamaForCausalLM.from_pretrained(MODEL_PATH, device_map="auto", torch_dtype=torch.bfloat16)
|
45 |
|
46 |
+
# Load base speech tokenizer
|
47 |
+
speech_tokenizer = spiritlm_base()
|
48 |
|
49 |
+
def get_inference(audio_path):
|
50 |
+
audio, _ = torchaudio.load(audio_path)
|
51 |
+
input_values = audio.view(1, 1, -1).to(speech_tokenizer.hubert_model.device).float()
|
52 |
+
tokens = speech_tokenizer.encode_string(input_values)
|
53 |
+
input_ids = tokenizer(tokens, return_tensors="pt").input_ids.to(model.device)
|
54 |
+
output = model.generate(input_ids, max_new_tokens=256, top_p=0.9, temperature=0.9, do_sample=True)
|
55 |
+
return tokenizer.decode(output[0])
|
56 |
+
```
|
57 |
|
58 |
+
---
|
59 |
|
60 |
+
### 4. Decode to WAV
|
61 |
|
62 |
+
```python
|
63 |
+
import numpy as np
|
64 |
+
from scipy.io.wavfile import write
|
65 |
|
66 |
+
def save_array_to_wav_int16(audio_array: np.ndarray, sampling_rate=16000, filename="output.wav"):
|
67 |
+
scaled = np.int16(audio_array / np.max(np.abs(audio_array)) * 32767)
|
68 |
+
write(filename, sampling_rate, scaled)
|
69 |
|
70 |
+
decoded_audio = speech_tokenizer.decode(generated_output.replace(" ", "").replace("<s>", "").replace("</s>", ""), speaker_id=2)
|
71 |
+
save_array_to_wav_int16(decoded_audio, filename="generated.wav")
|
72 |
+
```
|
73 |
|
74 |
+
---
|
75 |
|
76 |
+
## π£οΈ Inference Example
|
77 |
|
78 |
+
### π§ Basic Speech Continuation
|
79 |
|
80 |
+
Input: `simple_prompt.wav`
|
81 |
+
Output: Semantically consistent speech continuation without expressive variation.
|
82 |
|
83 |
+
---
|
84 |
|
85 |
+
## π§ Model Details
|
86 |
|
87 |
+
| Feature | Description |
|
88 |
+
| ------------------- | ------------------------------------------------ |
|
89 |
+
| Architecture | 2B parameter distilled transformer |
|
90 |
+
| Tokenizer | SPIRIT-LM Base (HuBERT phonetic tokens) |
|
91 |
+
| Input Type | Discrete HuBERT tokens only (speech-only) |
|
92 |
+
| Output Type | Discrete audio tokens |
|
93 |
+
| Teacher Model | SPIRIT-LM-Base 7B |
|
94 |
+
| Tasks | Speech continuation |
|
95 |
+
| Distillation Method | Layer-aligned (hidden states, attention, logits) |
|
96 |
|
97 |
+
---
|
98 |
|
99 |
+
## π Citation
|
100 |
|
101 |
+
```bibtex
|
102 |
+
@article{nouriborji2025tinywave,
|
103 |
+
title={Efficient Interleaved Speech Modeling through Knowledge Distillation},
|
104 |
+
author={Nouriborji, Mohammadmahdi and Rohanian, Morteza},
|
105 |
+
journal={arXiv preprint arXiv:2506.23670},
|
106 |
+
year={2025}
|
107 |
+
}
|
108 |
+
```
|
109 |
|
110 |
+
---
|
111 |
|
112 |
+
## π Resources
|
113 |
|
114 |
+
* π [Project Page](https://mohammadmahdinoori.github.io/tinywave-landing/)
|
115 |
+
* π¬ [Demo Samples](https://mohammadmahdinoori.github.io/tinywave-landing/#samples)
|
116 |
+
* π§ [Training & Codebase](https://github.com/mohammadmahdinoori/TinyWave)
|