Views
No views yet
unsloth/csm-1b repository. This model is trained using dataset which mentioned below.speaker_id values:| Speaker | Text | Synthesized Audio |
|---|---|---|
| 0 | They decided to take a short break from work and travel to the mountains. | |
| 0 | I think that movie had a very unexpected and thrilling ending. | |
| 0 | It's always a good idea to double-check your work before submitting it. | |
| 1 | They decided to take a short break from work and travel to the mountains. | |
| 1 | I think that movie had a very unexpected and thrilling ending. | |
| 1 | It's always a good idea to double-check your work before submitting it. | |
| 2 | They decided to take a short break from work and travel to the mountains. | |
| 2 | I think that movie had a very unexpected and thrilling ending. | |
| 2 | It's always a good idea to double-check your work before submitting it. | |
| 3 | They decided to take a short break from work and travel to the mountains. | |
| 3 | I think that movie had a very unexpected and thrilling ending. | |
| 3 | It's always a good idea to double-check your work before submitting it. |
!pip install unsloth
!pip install transformers==4.52.31from unsloth import FastModel
2from transformers import CsmForConditionalGeneration
3import torch
4from IPython.display import Audio
5
6model, processor = FastModel.from_pretrained(
7 model_name = "onecxi/csm-english-multi-speaker-v1",
8 max_seq_length= 2048, # Choose any for long context!
9 dtype = None, # Leave as None for auto-detection
10 auto_model = CsmForConditionalGeneration,
11 load_in_4bit = False, # Select True for 4bit - reduces memory usage
12)
13
14text = "We just finished fine-tuning a text to speech model."
15speaker_id = 0
16
17inputs = processor(f"[{speaker_id}]{text}", add_special_tokens=True, return_tensors="pt").to("cuda")
18audio_values = model.generate(
19 **inputs,
20 max_new_tokens=125, # 125 tokens is 10 seconds of audio, for longer speech increase this
21 # play with these parameters to get the best results
22 depth_decoder_temperature=0.6,
23 depth_decoder_top_k=0,
24 depth_decoder_top_p=0.9,
25 temperature=0.8,
26 top_k=50,
27 top_p=1.0,
28 #########################################################
29 output_audio=True
30)
31audio = audio_values[0].to(torch.float32).cpu().numpy()
32
33Audio(audio, rate=24000)