Views
No views yet
[!NOTE] Usespeaker_id=4only
1import torch
2
3from peft import PeftModel
4from transformers import CsmForConditionalGeneration, AutoProcessor
5
6model_id = "sesame/csm-1b"
7device = "cuda" if torch.cuda.is_available() else "cpu"
8
9processor = AutoProcessor.from_pretrained(model_id)
10model = CsmForConditionalGeneration.from_pretrained(model_id, device_map=device)
11model = PeftModel.from_pretrained(model, "shb777/csm-maya-exp2")
12
13conversation = [
14 {"role": "4", "content": [{"type": "text", "text": "Hey there, I am Maya."}]},
15]
16
17inputs = processor.apply_chat_template(
18 conversation,
19 tokenize=True,
20 return_dict=True,
21).to(device)
22
23gen_kwargs = {
24 "max_new_tokens": 375,
25 # "do_sample": True,
26 # "temperature": 0.7,
27 # "depth_decoder_do_sample": True,
28 # "depth_decoder_temperature": 0.7,
29 # "depth_decoder_top_k": 20,
30 # "depth_decoder_top_p": 0.95,
31}
32
33audio = model.generate(**inputs, **gen_kwargs, output_audio=True)
34processor.save_audio(audio, "example.wav")40 onwards seems bad(and ) and " and " and ; and ?! and [ and ] and / (also seen in official demo, I guess this is due to the nature of sesame's preprocessing)attn + mlp in backbone and decoder excluding codec16321e-4 , 0.1 warmup with cosine scheduleradamw_torch_fused48