A newer version of the Gradio SDK is available:
6.0.2
ElevenLabs TTS Setup Instructions
Phase 2: Audio Hints Feature
The chatbot can now generate partial audio hints using ElevenLabs text-to-speech!
Features:
- Progressive Audio Hints: First syllable → First half → Rhythm pattern → Almost full
- Strategic Timing: Automatic at attempts 3, 5, 7, 10+ or when user asks
- Cost Effective: ~$0.003 per hint, cached for reuse
Setup Steps:
Get ElevenLabs API Key
- Sign up at https://elevenlabs.io/
- Get your API key from the dashboard
- Free tier: 10,000 characters/month (~3,000 audio hints)
Install Dependencies
pip install elevenlabs==0.2.26Add API Key to .env
# Add this line to your .env file ELEVENLABS_API_KEY=your_api_key_hereRestart Application
# Kill and restart both backend and frontend ./restart.sh
Testing:
- Start a game and make 3+ attempts
- Open the chatbot (? button)
- Ask: "Give me a hint" or "How does it sound?"
- Chatbot will provide text hint + audio file
Audio Hint Strategy:
- Attempt 3: First syllable (e.g., "Win" from "Wingardium Leviosa")
- Attempt 5: First half (e.g., "Wingardium")
- Attempt 7: Rhythm pattern (e.g., "Win ... gar ... di ... um ... Le ... vi ... o ... sa")
- Attempt 10+: Almost full (e.g., "Wingardium Leviosa" missing last syllable)
Costs:
- ElevenLabs pricing: $0.30 per 1,000 characters
- Average hint: 10 characters = $0.003 per hint
- 100 users/day with 2 hints each = $0.60/day = $18/month
- Caching reduces API calls by 70-90%
Status Check:
Check if ElevenLabs is configured:
from client.utils.elevenlabs_tts import get_status
print(get_status())
Troubleshooting:
Audio hints not working?
- Check .env file has
ELEVENLABS_API_KEY - Restart backend and frontend
- Check logs for "ElevenLabs configured: True"
- Verify API key is valid at elevenlabs.io
Cost too high?
- Audio hints are cached automatically
- Adjust
should_offer_audio_hint()logic inelevenlabs_tts.py - Reduce random chance after attempt 5 (currently 30%)
Files Modified:
client/utils/elevenlabs_tts.py- New TTS integration moduleclient/frontend/components/floating_chatbot.py- Audio hint generationrequirements.txt- Added elevenlabs dependency