Integrating Munsit with LiveKit Agents
This tutorial will guide you through integrating Munsit’s Arabic text-to-speech into your LiveKit voice agents, enabling natural-sounding Arabic conversations in your real-time applications.
Prerequisites
- A Munsit AI account
- Python 3.9 or higher installed
- Basic familiarity with LiveKit Agents framework
- A LiveKit Cloud account (or self-hosted LiveKit server)
API Key
Go to Munsit - API Keys, Generate an API key, then save it securely.
Your API key is only shown once. Save it securely.
Installation
Install the Munsit plugin for LiveKit Agents:
For development or testing from source:
Step 3: Set Up Your Environment
Create a .env.local file in your project directory to store your API keys securely:
Step 4: Create Your First Arabic Voice Agent
Create a file called arabic_agent.py:
Step 5: Run Your Agent
Development Mode
For local testing with LiveKit’s dev server:
This will:
- Start a local LiveKit server
- Launch your agent
- Provide a test URL you can open in your browser
Production Mode
For deployment with your LiveKit Cloud or self-hosted server:
Make sure your LiveKit credentials are properly configured in .env.local.
Step 6: Test Your Agent
- Open the provided URL in your web browser
- Allow microphone access when prompted
- Speak in Arabic - the agent will respond using Munsit’s natural-sounding voice
- Try different questions to test the conversation flow
Configuration Options
Available Voice IDs
To choose a voice for your agent:
- Visit the Munsit Voice Library
- Listen to different voices to find the one that best fits your use case
- Click “Copy Voice ID” button next to your chosen voice
- Use that voice ID in your code:
Model Selection
Choose between two models based on your needs:
Stability Parameter
The stability parameter controls voice consistency:
- 0.0 - 0.4: More expressive, creative, but can hallucinate
- 0.5 - 0.7: Balanced (recommended for most use cases)
- 0.8 - 1.0: Very consistent, less variation
Speed Parameter
The speed parameter controls speech rate:
- 0.7 - 0.9: Slower speech (clearer for complex content)
- 1.0: Normal speed (default)
- 1.1 - 1.2: Faster speech (for quick responses)
Dynamic Voice Switching
You can change voice settings during runtime:
Advanced Features
Bilingual Support
Create agents that can switch between Arabic and English:
Streaming for Low Latency
Munsit supports streaming for real-time applications:
Monitoring and Metrics
Track your agent’s performance:
Best Practices
1. API Key Security
✅ DO:
- Store API keys in
.env.local (not committed to Git)
- Use environment variables in production
- Rotate keys periodically
❌ DON’T:
- Hardcode API keys in source code
- Commit
.env files to version control
- Share API keys in chat or email
2. Stability Settings
- Chatbots: 0.6 - 0.8 (balanced and reliable)
- Professional Applications: 0.8 - 1.0 (very consistent)
- Creative Content: 0.3 - 0.5 (more expressive)
Troubleshooting
”Invalid API Key” Error
Solution: Double-check your API key in .env.local
”Payment Required” Error
Solution: Your Munsit account balance is low. Top up at app.munsit.com
”Rate Limit Exceeded”
Solution: You’re sending too many requests. Implement rate limiting or contact Munsit support to increase your limits.
No Audio Output
Checklist:
- ✅ API key is valid
- ✅ Network connection is stable
- ✅ Microphone permissions are granted
- ✅ Browser supports WebRTC
- ✅ Firewall allows WebSocket connections
Poor Audio Quality
Solutions:
- Switch to
faseeh-v1-preview (full model)
- Increase stability to 0.8 or higher
- Check your network connection
- Ensure proper audio codec support
Support
Need help?
License
This plugin is licensed under Apache License 2.0. See LICENSE for details.