Skip to content

Instantly share code, notes, and snippets.

@yoi-hibino
Created March 14, 2025 05:55
Show Gist options
  • Save yoi-hibino/d467f18f5f8b0a9fe0c4c61e509550ca to your computer and use it in GitHub Desktop.
Save yoi-hibino/d467f18f5f8b0a9fe0c4c61e509550ca to your computer and use it in GitHub Desktop.
CSM Sample
from huggingface_hub import hf_hub_download
from generator import load_csm_1b
import torchaudio
# need this to access to model.
# you also need to get access to https://huggingface.co/meta-llama/Llama-3.2-1B
from huggingface_hub import login
login("your_huggingface_token")
model_path = hf_hub_download(repo_id="sesame/csm-1b", filename="ckpt.pt")
generator = load_csm_1b(model_path, "cuda")
audio = generator.generate(
text="Hello from Sesame.",
speaker=0,
context=[],
max_audio_length_ms=10_000,
)
torchaudio.save("audio.wav", audio.unsqueeze(0).cpu(), generator.sample_rate)
@yoi-hibino
Copy link
Author

yoi-hibino commented Mar 14, 2025

https://github.com/SesameAILabs/csm

git clone [email protected]:SesameAILabs/csm.git
cd csm
python3.10 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

make sure you have ffmpeg installed as well

sudo apt update
sudo apt install ffmpeg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment