Skip to content

Commit 054677d

Browse files
YedPoolclaude
andcommitted
Add HuggingFace token support for Sesame CSM
- Update GitHub Actions to use HUGGINGFACE_TOKEN secret - Gracefully handle missing token with helpful error messages - Add proper token authentication to model loading - Provide clear setup instructions for model access 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 631e7d7 commit 054677d

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

.github/workflows/test-docker.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,21 @@ jobs:
365365
exit 1
366366
fi
367367
368-
- name: Test Sesame TTS container startup (without model loading)
368+
- name: Test Sesame TTS container startup
369369
run: |
370-
# Start Sesame TTS container (will fail without HF token but should start server)
371-
docker run -d --name sesame-tts-test \
372-
-p 8001:8001 \
373-
sesame-tts:test
370+
# Start Sesame TTS container with HuggingFace token if available
371+
if [ -n "${{ secrets.HUGGINGFACE_TOKEN }}" ]; then
372+
echo "🔑 Using HuggingFace token for model access"
373+
docker run -d --name sesame-tts-test \
374+
-p 8001:8001 \
375+
-e HUGGINGFACE_HUB_TOKEN=${{ secrets.HUGGINGFACE_TOKEN }} \
376+
sesame-tts:test
377+
else
378+
echo "⚠️ No HuggingFace token available - testing container startup only"
379+
docker run -d --name sesame-tts-test \
380+
-p 8001:8001 \
381+
sesame-tts:test
382+
fi
374383
375384
# Show immediate logs
376385
echo "📋 Initial Sesame TTS logs:"

sesame-tts/main.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,34 @@ def load_model(self):
7575
model_id = "sesame/csm-1b"
7676
logger.info(f"Loading Sesame CSM model: {model_id}")
7777

78+
# Check for HuggingFace token
79+
hf_token = os.getenv("HUGGINGFACE_HUB_TOKEN")
80+
if not hf_token:
81+
logger.warning("No HUGGINGFACE_HUB_TOKEN environment variable found")
82+
logger.warning("You may need to accept the model license and set your HF token")
83+
else:
84+
logger.info("✓ HuggingFace token found")
85+
7886
# Load processor and model
79-
self.processor = AutoProcessor.from_pretrained(model_id)
87+
self.processor = AutoProcessor.from_pretrained(
88+
model_id,
89+
token=hf_token
90+
)
8091
self.model = CsmForConditionalGeneration.from_pretrained(
8192
model_id,
8293
device_map=self.device,
83-
torch_dtype=torch.float16 if self.device == "cuda" else torch.float32
94+
torch_dtype=torch.float16 if self.device == "cuda" else torch.float32,
95+
token=hf_token
8496
)
8597

8698
logger.info("✓ Sesame CSM model loaded successfully")
8799
return True
88100

89101
except Exception as e:
90102
logger.error(f"Failed to load model: {e}")
103+
logger.error("Make sure you have:")
104+
logger.error("1. Accepted the license at https://huggingface.co/sesame/csm-1b")
105+
logger.error("2. Set HUGGINGFACE_HUB_TOKEN environment variable")
91106
return False
92107

93108
def generate_audio(self, text: str, speaker: int = 0, max_audio_length_ms: int = 10000):

0 commit comments

Comments
 (0)