Lyte commited on
Commit
730a618
·
verified ·
1 Parent(s): 46e3c70

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +190 -197
README.md CHANGED
@@ -2,201 +2,194 @@
2
  library_name: transformers
3
  tags:
4
  - unsloth
5
- - trl
6
- - sft
 
 
 
 
 
 
 
 
7
  ---
8
-
9
- # Model Card for Model ID
10
-
11
- <!-- Provide a quick summary of what the model is/does. -->
12
-
13
-
14
-
15
- ## Model Details
16
-
17
- ### Model Description
18
-
19
- <!-- Provide a longer summary of what this model is. -->
20
-
21
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
22
-
23
- - **Developed by:** [More Information Needed]
24
- - **Funded by [optional]:** [More Information Needed]
25
- - **Shared by [optional]:** [More Information Needed]
26
- - **Model type:** [More Information Needed]
27
- - **Language(s) (NLP):** [More Information Needed]
28
- - **License:** [More Information Needed]
29
- - **Finetuned from model [optional]:** [More Information Needed]
30
-
31
- ### Model Sources [optional]
32
-
33
- <!-- Provide the basic links for the model. -->
34
-
35
- - **Repository:** [More Information Needed]
36
- - **Paper [optional]:** [More Information Needed]
37
- - **Demo [optional]:** [More Information Needed]
38
-
39
- ## Uses
40
-
41
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
42
-
43
- ### Direct Use
44
-
45
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
46
-
47
- [More Information Needed]
48
-
49
- ### Downstream Use [optional]
50
-
51
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
52
-
53
- [More Information Needed]
54
-
55
- ### Out-of-Scope Use
56
-
57
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
58
-
59
- [More Information Needed]
60
-
61
- ## Bias, Risks, and Limitations
62
-
63
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
64
-
65
- [More Information Needed]
66
-
67
- ### Recommendations
68
-
69
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
70
-
71
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
72
-
73
- ## How to Get Started with the Model
74
-
75
- Use the code below to get started with the model.
76
-
77
- [More Information Needed]
78
-
79
- ## Training Details
80
-
81
- ### Training Data
82
-
83
- <!-- 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. -->
84
-
85
- [More Information Needed]
86
-
87
- ### Training Procedure
88
-
89
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
90
-
91
- #### Preprocessing [optional]
92
-
93
- [More Information Needed]
94
-
95
-
96
- #### Training Hyperparameters
97
-
98
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
99
-
100
- #### Speeds, Sizes, Times [optional]
101
-
102
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
103
-
104
- [More Information Needed]
105
-
106
- ## Evaluation
107
-
108
- <!-- This section describes the evaluation protocols and provides the results. -->
109
-
110
- ### Testing Data, Factors & Metrics
111
-
112
- #### Testing Data
113
-
114
- <!-- This should link to a Dataset Card if possible. -->
115
-
116
- [More Information Needed]
117
-
118
- #### Factors
119
-
120
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
121
-
122
- [More Information Needed]
123
-
124
- #### Metrics
125
-
126
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
127
-
128
- [More Information Needed]
129
-
130
- ### Results
131
-
132
- [More Information Needed]
133
-
134
- #### Summary
135
-
136
-
137
-
138
- ## Model Examination [optional]
139
-
140
- <!-- Relevant interpretability work for the model goes here -->
141
-
142
- [More Information Needed]
143
-
144
- ## Environmental Impact
145
-
146
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
147
-
148
- 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).
149
-
150
- - **Hardware Type:** [More Information Needed]
151
- - **Hours used:** [More Information Needed]
152
- - **Cloud Provider:** [More Information Needed]
153
- - **Compute Region:** [More Information Needed]
154
- - **Carbon Emitted:** [More Information Needed]
155
-
156
- ## Technical Specifications [optional]
157
-
158
- ### Model Architecture and Objective
159
-
160
- [More Information Needed]
161
-
162
- ### Compute Infrastructure
163
-
164
- [More Information Needed]
165
-
166
- #### Hardware
167
-
168
- [More Information Needed]
169
-
170
- #### Software
171
-
172
- [More Information Needed]
173
-
174
- ## Citation [optional]
175
-
176
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
177
-
178
- **BibTeX:**
179
-
180
- [More Information Needed]
181
-
182
- **APA:**
183
-
184
- [More Information Needed]
185
-
186
- ## Glossary [optional]
187
-
188
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
189
-
190
- [More Information Needed]
191
-
192
- ## More Information [optional]
193
-
194
- [More Information Needed]
195
-
196
- ## Model Card Authors [optional]
197
-
198
- [More Information Needed]
199
-
200
- ## Model Card Contact
201
-
202
- [More Information Needed]
 
2
  library_name: transformers
3
  tags:
4
  - unsloth
5
+ - text-to-audio
6
+ - s2s
7
+ license: cc-by-sa-4.0
8
+ datasets:
9
+ - KandirResearch/Speech2Speech
10
+ language:
11
+ - en
12
+ base_model:
13
+ - OuteAI/OuteTTS-0.3-500M
14
+ pipeline_tag: text-to-audio
15
  ---
16
+ # CiSiMi: A Text-to-Speech TTS Model
17
+
18
+ [![Buy Me A Coffee](https://img.shields.io/badge/Ko--fi-Support%20My%20Work-FF5E5B?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/lyte)
19
+ [![Dataset](https://img.shields.io/badge/Dataset-KandirResearch/Speech2Speech-blue)](https://huggingface.co/datasets/KandirResearch/Speech2Speech)
20
+ [![Model](https://img.shields.io/badge/Model-KandirResearch/CiSiMi-green)](https://huggingface.co/KandirResearch/CiSiMi)
21
+ [![Demo](https://img.shields.io/badge/Demo-KandirResearch/CiSiMi--At--Home-orange)](https://huggingface.co/spaces/KandirResearch/CiSiMi-At-Home)
22
+
23
+ ## Overview
24
+
25
+ CiSiMi is an early prototype of a text-to-audio model that can process text inputs and respond with both text and audio. Built for resource-constrained environments, it's designed to run efficiently on CPU using llama.cpp, making advanced speech synthesis accessible even without powerful GPUs.
26
+
27
+ *"Being GPU poor and slightly disappointed with the csm release and my inability to run it, having to wait for time it takes me to run an ASR+LLM+TTS combo, I decided to ask Mom and Mom gave me CiSiMi At Home!"*
28
+
29
+ This project demonstrates the power of open-source tools to create accessible speech technology. While still in its early stages, it represents a step toward democratizing advanced text-to-audio capabilities.
30
+
31
+ ## Technical Details
32
+
33
+ ### Model Specifications
34
+ - **Architecture**: Based on OuteTTS-0.3-500M
35
+ - **Languages**: English
36
+ - **Pipeline**: Text-to-audio
37
+ - **Parameters**: 500M
38
+ - **Training Dataset Size**: ~15k samples
39
+ - **Future Goals**: Scale to 200k-500k dataset with multi-turn conversation using a 1B parameter model
40
+
41
+ ### Training Methodology
42
+
43
+ 1. **Dataset Preparation**:
44
+ - Started with [gruhit-patel/alpaca_speech_instruct](https://huggingface.co/datasets/gruhit-patel/alpaca_speech_instruct)
45
+ - Cleaned by removing code, mathematical expressions, and non-English content
46
+ - Filtered to keep only entries with input+output texts of 256 tokens or less
47
+
48
+ 2. **Audio Generation**:
49
+ - Converted text outputs to speech using [hexgrad/Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M)
50
+ - Verified each audio generation using [OpenAI Whisper](https://github.com/openai/whisper)
51
+ - Published the resulting dataset as [KandirResearch/Speech2Speech](https://huggingface.co/datasets/KandirResearch/Speech2Speech)
52
+
53
+ 3. **Model Training**:
54
+ - Preprocessed dataset using modified OuteTTS methodology ([training details](https://github.com/edwko/OuteTTS/blob/8eb0fa369df6f3c062f7084ddc33d10bc28992be/examples/training/OuteTTS-0.3/train.md))
55
+ - Fine-tuned [OuteAI/OuteTTS-0.3-500M](https://huggingface.co/OuteAI/OuteTTS-0.3-500M) using Unsloth SFT
56
+ - Trained for 3 epochs as a proof of concept
57
+
58
+ ## Usage Guide
59
+
60
+ ### Installation
61
+
62
+ ```bash
63
+ pip install outetts llama-cpp-python --upgrade
64
+ pip install huggingface_hub sounddevice
65
+ ```
66
+
67
+ ### Implementation
68
+
69
+ ```python
70
+ import torch
71
+ import outetts
72
+ import numpy as np
73
+ from huggingface_hub import hf_hub_download
74
+ from outetts.wav_tokenizer.audio_codec import AudioCodec
75
+ from outetts.version.v2.prompt_processor import PromptProcessor
76
+ from outetts.version.playback import ModelOutput
77
+
78
+ # Download the model
79
+ model_path = hf_hub_download(
80
+ repo_id="Lyte/CiSiMi",
81
+ filename="unsloth.Q8_0.gguf",
82
+ )
83
+
84
+ # Configure the model
85
+ model_config = outetts.GGUFModelConfig_v2(
86
+ model_path=model_path,
87
+ tokenizer_path="Lyte/CiSiMi",
88
+ )
89
+
90
+ # Initialize components
91
+ interface = outetts.InterfaceGGUF(model_version="0.3", cfg=model_config)
92
+ audio_codec = AudioCodec()
93
+ prompt_processor = PromptProcessor("Lyte/CiSiMi")
94
+
95
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
96
+ gguf_model = interface.get_model()
97
+
98
+ # Helper function to extract audio from tokens
99
+ def get_audio(tokens):
100
+ outputs = prompt_processor.extract_audio_from_tokens(tokens)
101
+ if not outputs:
102
+ return None
103
+ audio_tensor = audio_codec.decode(torch.tensor([[outputs]], dtype=torch.int64).to(device))
104
+ return ModelOutput(audio_tensor, audio_codec.sr)
105
+
106
+ # Helper function to clean text output
107
+ def extract_text_from_tts_output(tts_output):
108
+ text = ""
109
+ for line in tts_output.strip().split('\n'):
110
+ if '<|audio_end|>' in line or '<|im_end|>' in line:
111
+ continue
112
+ if '<|' in line:
113
+ word = line.split('<|')[0].strip()
114
+ if word:
115
+ text += word + " "
116
+ else:
117
+ text += line.strip() + " "
118
+ return text.strip()
119
+
120
+ # Generate response function
121
+ def generate_response(instruction):
122
+ prompt = f"<|im_start|>\nInstructions:\n{instruction}\n<|im_end|>\nAnswer:\n"
123
+ gen_cfg = outetts.GenerationConfig(
124
+ text=prompt,
125
+ temperature=0.6,
126
+ repetition_penalty=1.1,
127
+ max_length=4096,
128
+ speaker=None
129
+ )
130
+
131
+ input_ids = prompt_processor.tokenizer.encode(prompt)
132
+ tokens = gguf_model.generate(input_ids, gen_cfg)
133
+
134
+ output_text = prompt_processor.tokenizer.decode(tokens, skip_special_tokens=False)
135
+
136
+ if "<|audio_end|>" in output_text:
137
+ first_part, _, _ = output_text.partition("<|audio_end|>")
138
+
139
+ if "<|audio_end|>\n<|im_end|>\n" not in first_part:
140
+ first_part += "<|audio_end|>\n<|im_end|>\n"
141
+
142
+ extracted_text = extract_text_from_tts_output(first_part)
143
+
144
+ audio_start_pos = first_part.find("<|audio_start|>\n") + len("<|audio_start|>\n")
145
+ audio_end_pos = first_part.find("<|audio_end|>\n<|im_end|>\n") + len("<|audio_end|>\n<|im_end|>\n")
146
+
147
+ if audio_start_pos >= len("<|audio_start|>\n") and audio_end_pos > audio_start_pos:
148
+ audio_tokens_text = first_part[audio_start_pos:audio_end_pos]
149
+ audio_tokens = prompt_processor.tokenizer.encode(audio_tokens_text)
150
+ audio_output = get_audio(audio_tokens)
151
+
152
+ if audio_output is not None and hasattr(audio_output, 'audio') and audio_output.audio is not None:
153
+ audio_numpy = audio_output.audio.cpu().numpy()
154
+ if audio_numpy.ndim > 1:
155
+ audio_numpy = audio_numpy.squeeze()
156
+
157
+ return extracted_text, (audio_output.sr, audio_numpy)
158
+
159
+ return output_text, None
160
+
161
+ # Example usage
162
+ question = "What is the meaning of life?"
163
+ response_text, response_audio = generate_response(question)
164
+ print(response_text)
165
+
166
+ # Play audio if available
167
+ if response_audio is not None:
168
+ if "ipykernel" in sys.modules:
169
+ from IPython.display import display, Audio
170
+ display(Audio(response_audio[1], rate=response_audio[0], autoplay=True))
171
+ else:
172
+ import sounddevice as sd
173
+ sd.play(response_audio[1], samplerate=response_audio[0])
174
+ sd.wait()
175
+ ```
176
+
177
+ ## Limitations & Future Work
178
+
179
+ This early prototype has several areas for improvement:
180
+ - Limited training data (~15k samples)
181
+ - Basic prompt/chat template structure
182
+ - Opportunity to optimize training hyperparameters
183
+ - Potential for multi-turn conversation capabilities
184
+
185
+ **Potential Limitation**: This type of model quickly fills up context window, making smaller models generally more practical for implementation.
186
+
187
+ ## Acknowledgments & Citations
188
+
189
+ This model builds on the following open-source projects:
190
+
191
+ 1. [OuteAI/OuteTTS-0.3-500M](https://huggingface.co/OuteAI/OuteTTS-0.3-500M) - Base model
192
+ 2. [gruhit-patel/alpaca_speech_instruct](https://huggingface.co/datasets/gruhit-patel/alpaca_speech_instruct) - Initial dataset
193
+ 3. [hexgrad/Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) - TTS generation
194
+ 4. [OpenAI Whisper](https://github.com/openai/whisper) - Speech verification
195
+ 5. [Unsloth](https://github.com/unslothai/unsloth) - Training optimization