Update README.md
Browse files
README.md
CHANGED
@@ -2,201 +2,194 @@
|
|
2 |
library_name: transformers
|
3 |
tags:
|
4 |
- unsloth
|
5 |
-
-
|
6 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
---
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
##
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
This
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
- **
|
27 |
-
- **
|
28 |
-
- **
|
29 |
-
- **
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
-
|
37 |
-
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
[
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
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 |
-
<!-- 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 |
+
[](https://ko-fi.com/lyte)
|
19 |
+
[](https://huggingface.co/datasets/KandirResearch/Speech2Speech)
|
20 |
+
[](https://huggingface.co/KandirResearch/CiSiMi)
|
21 |
+
[](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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|