Redefine Creativity
AI Image Editor
Free browser-based tool for stunning visual creations
3 min to read
Sesame CSM 1B is an open-source speech model designed for lifelike AI-generated voices, enabling offline voice synthesis and cloning on local hardware. This guide provides a step-by-step approach to installing and running Sesame CSM 1B on a Windows machine, covering prerequisites, installation steps, testing, and troubleshooting.
Sesame CSM 1B is engineered to deliver high-quality voice generation and cloning capabilities. It can replicate voices with impressive accuracy and generate speech from text inputs. The model is particularly useful for applications such as voice assistants, content creation, and accessibility tools.
Ensure your system meets the following minimum requirements before installation:
Verify the installation:
python --version
Git is required to clone the Sesame CSM repository:
Verify the installation:
git --version
Hugging Face CLI is necessary for model authentication:
Authenticate by generating an access token from your Hugging Face account and running:
huggingface-cli login
Open Command Prompt and run:
pip install huggingface_hub
Follow these steps to install and configure Sesame CSM 1B on your Windows system:
Run:
git clone <REPOSITORY_URL>
Replace <REPOSITORY_URL>
with the URL of the Sesame CSM GitHub repository.
Activate the virtual environment:
.\venv\Scripts\activate
Create a virtual environment:
python -m venv venv
Navigate to the cloned repository folder:
cd sesame-csm
Run the following command to install all required libraries:
pip install -r requirements.txt
Ensure Hugging Face CLI is authenticated, then run the script provided in the repository to download necessary models:
python download_models.py
After installation, test the model using a sample script:
test.py
in the repository folder.output.wav
in your file explorer.Run the script:
python test.py
Add the following code:
from sesame_csm import generate_audio
text = "Hello from Sesame!"
audio_path = "output.wav"
generate_audio(text, audio_path)
print(f"Audio saved at {audio_path}")
To clone a voice:
speakers = [0, 1, 0, 0]
transcripts = [
"Hey how are you doing.",
"Pretty good, pretty good.",
"I'm great.",
"So happy to be speaking to you.",
]
audio_paths = [
"utterance_0.wav",
"utterance_1.wav",
"utterance_2.wav",
"utterance_3.wav",
]
def load_audio(audio_path):
audio_tensor, sample_rate = torchaudio.load(audio_path)
audio_tensor = torchaudio.functional.resample(
audio_tensor.squeeze(0), orig_freq=sample_rate, new_freq=generator.sample_rate
)
return audio_tensor
segments = [
Segment(text=transcript, speaker=speaker, audio=load_audio(audio_path))
for transcript, speaker, audio_path in zip(transcripts, speakers, audio_paths)
]
audio = generator.generate(
text="Me too, this is some cool stuff huh?",
speaker=1,
context=segments,
max_audio_length_ms=10_000,
)
torchaudio.save("audio.wav", audio.unsqueeze(0).cpu(), generator.sample_rate)
from generator import load_csm_1b
import torchaudio
import torch
if torch.backends.mps.is_available():
device = "mps"
elif torch.cuda.is_available():
device = "cuda"
else:
device = "cpu"
generator = load_csm_1b(device=device)
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)
Modify parameters such as sampling rate and voice tone in configuration files provided with the repository.
Use APIs or scripts to integrate Sesame CSM into larger projects like chatbots or multimedia tools.
Running Sesame CSM 1B on Windows enables powerful offline speech synthesis and voice cloning capabilities for personal projects or professional applications. By following this guide, you can set up and test the model efficiently while troubleshooting common issues along the way.
Need expert guidance? Connect with a top Codersera professional today!