Skip to content

Instantly share code, notes, and snippets.

@hathibelagal-dev
Created March 14, 2025 02:15
Show Gist options
  • Save hathibelagal-dev/f32cb04512c6da2caf2ceddf2d513cc6 to your computer and use it in GitHub Desktop.
Save hathibelagal-dev/f32cb04512c6da2caf2ceddf2d513cc6 to your computer and use it in GitHub Desktop.
SesameCSM-1B.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4",
"authorship_tag": "ABX9TyOuLGDxFOHJlZehFW5XlFWm",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/hathibelagal-dev/f32cb04512c6da2caf2ceddf2d513cc6/sesamecsm-1b.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "VMXpmdZp4KlV"
},
"outputs": [],
"source": [
"!git clone https://github.com/SesameAILabs/csm.git\n",
"!cd csm && pip install -r requirements.txt"
]
},
{
"cell_type": "code",
"source": [
"%cd csm"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "dMnBhAYh6L8v",
"outputId": "1c7473b1-6030-4563-98e2-9f1b93ceb1c2"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/csm\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"from huggingface_hub import hf_hub_download\n",
"from generator import load_csm_1b\n",
"import torchaudio\n",
"\n",
"model_path = hf_hub_download(repo_id=\"sesame/csm-1b\", filename=\"ckpt.pt\")\n",
"generator = load_csm_1b(model_path, \"cuda\")"
],
"metadata": {
"id": "jswLN14b6ALY"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"items = [\"\"\"\n",
"Great question, and it's one that's kept historians and archaeologists scratching their heads for decades. The Sea Peoples are tricky because we don't have their own written records. Just what their enemies, like the Egyptians, said about them. The term \"Sea Peoples\" comes from Egyptian inscriptions, especially those from Pharaoh Ramesses III around 1177 BCE, where they're described as a coalition of groups attacking from the sea. Names like the Sherden, the Peleset, the Tjeker, and the Lukka pop up, but pinning down who they were is tough. The latest thinking leans toward them being a loose confederation of different tribes, likely from the Aegean, western Anatolia, and maybe even parts of the central Mediterranean. Some scholars tie the Peleset to the Philistines in the Levant, and the Sherden might link to Sardinia, though that's debated. Were they a single organized force? Probably not. More likely, they were disparate groups—displaced by drought, famine, or earthquakes—who turned to raiding and migration when their own societies started crumbling. Think of them as a symptom of the collapse, not just the cause. The Bronze Age world was already on shaky ground—overstretched trade routes, internal revolts—and these \"Sea Peoples\" might've been the final push that tipped it over. It's less a grand invasion and more a chaotic free-for-all, fueled by desperation. What do you think about that angle, Bob?\n",
"\"\"\"]\n",
"items = [item.strip() for item in items]"
],
"metadata": {
"id": "XyoXLAazO0Zb"
},
"execution_count": 5,
"outputs": []
},
{
"cell_type": "code",
"source": [
"i = 0\n",
"for item in items:\n",
" audio = generator.generate(\n",
" text=item,\n",
" speaker=0,\n",
" context=[],\n",
" max_audio_length_ms=120000\n",
" )\n",
"\n",
" torchaudio.save(f\"{i}.wav\", audio.unsqueeze(0).cpu(), 24000)\n",
" print(generator.sample_rate)\n",
" i += 1"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "G5HJPFWq7OJu",
"outputId": "0666f53b-9bf6-4cb8-dd15-570d67015f90"
},
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"24000\n"
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment